7 #ifndef PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_ 8 #define PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_ 14 #include "packager/base/macros.h" 15 #include "packager/media/base/fourccs.h" 18 typedef struct aes_key_st AES_KEY;
38 explicit AesCryptor(ConstantIvFlag constant_iv_flag);
44 const std::vector<uint8_t>&
iv) = 0;
51 bool Crypt(
const std::vector<uint8_t>& text,
52 std::vector<uint8_t>* crypt_text);
53 bool Crypt(
const std::string& text, std::string* crypt_text);
55 bool Crypt(
const uint8_t* text,
size_t text_size, uint8_t* crypt_text) {
56 size_t crypt_text_size = text_size;
57 return Crypt(text, text_size, crypt_text, &crypt_text_size);
59 bool Crypt(
const uint8_t* text,
62 size_t* crypt_text_size) {
63 if (constant_iv_flag_ == kUseConstantIv)
66 num_crypt_bytes_ += text_size;
67 return CryptInternal(text, text_size, crypt_text, crypt_text_size);
74 bool SetIv(
const std::vector<uint8_t>& iv);
82 const std::vector<uint8_t>&
iv()
const {
return iv_; }
92 std::vector<uint8_t>* iv);
95 const AES_KEY* aes_key()
const {
return aes_key_.get(); }
96 AES_KEY* mutable_aes_key() {
return aes_key_.get(); }
109 virtual bool CryptInternal(
const uint8_t* text,
112 size_t* crypt_text_size) = 0;
115 virtual void SetIvInternal() = 0;
120 virtual size_t NumPaddingBytes(
size_t size)
const;
123 std::unique_ptr<AES_KEY> aes_key_;
127 const ConstantIvFlag constant_iv_flag_;
130 std::vector<uint8_t> iv_;
133 size_t num_crypt_bytes_;
141 #endif // PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_
All the methods that are virtual are virtual for mocking.