Encrypt audio when requested by Moonlight

This commit is contained in:
loki
2021-07-08 22:44:35 +02:00
parent 7f9467d759
commit cbd2a8269c
3 changed files with 137 additions and 27 deletions
+20
View File
@@ -67,6 +67,9 @@ private:
};
namespace cipher {
constexpr std::size_t round_to_pkcs7_padded(std::size_t size) {
return ((size + 15) / 16) * 16;
}
class cipher_t {
public:
@@ -105,6 +108,23 @@ public:
aes_t iv;
};
class cbc_t : public cipher_t {
public:
cbc_t() = default;
cbc_t(cbc_t &&) noexcept = default;
cbc_t &operator=(cbc_t &&) noexcept = default;
cbc_t(const crypto::aes_t &key, bool padding = true);
/**
* length of cipher must be at least: round_to_pkcs7_padded(plaintext.size())
*
* return -1 on error
* return bytes written on success
*/
int encrypt(const std::string_view &plaintext, std::uint8_t *cipher, aes_t *iv);
};
} // namespace cipher
} // namespace crypto