9 #ifndef MEDIA_BASE_AES_ENCRYPTOR_H_
10 #define MEDIA_BASE_AES_ENCRYPTOR_H_
15 #include "packager/base/memory/scoped_ptr.h"
16 #include "packager/base/stl_util.h"
19 typedef struct aes_key_st AES_KEY;
21 namespace edash_packager {
38 const std::vector<uint8_t>& iv) = 0;
40 virtual size_t NumPaddingBytes(
size_t size) = 0;
45 virtual bool EncryptData(
const uint8_t* plaintext,
46 size_t plaintext_size,
47 uint8_t* ciphertext) = 0;
49 bool Encrypt(
const std::vector<uint8_t>& plaintext,
50 std::vector<uint8_t>* ciphertext);
52 bool Encrypt(
const std::string& plaintext, std::string* ciphertext);
63 virtual bool SetIv(
const std::vector<uint8_t>& iv) = 0;
65 const std::vector<uint8_t>& iv()
const {
return iv_; }
69 std::vector<uint8_t> iv_;
71 scoped_ptr<AES_KEY> aes_key_;
89 const std::vector<uint8_t>& iv)
override;
91 size_t NumPaddingBytes(
size_t size)
override;
93 bool EncryptData(
const uint8_t* plaintext,
94 size_t plaintext_size,
95 uint8_t* ciphertext)
override;
103 bool SetIv(
const std::vector<uint8_t>& iv)
override;
106 uint32_t block_offset()
const {
return block_offset_; }
110 uint32_t block_offset_;
112 std::vector<uint8_t> counter_;
114 std::vector<uint8_t> encrypted_counter_;
116 bool counter_overflow_;
131 const std::vector<uint8_t>& iv)
override;
133 size_t NumPaddingBytes(
size_t size)
override;
135 bool EncryptData(
const uint8_t* plaintext,
136 size_t plaintext_size,
137 uint8_t* ciphertext)
override;
141 bool SetIv(
const std::vector<uint8_t>& iv)
override;
158 const std::vector<uint8_t>& iv)
override;
160 size_t NumPaddingBytes(
size_t size)
override;
162 bool EncryptData(
const uint8_t* plaintext,
163 size_t plaintext_size,
164 uint8_t* ciphertext)
override;
168 bool SetIv(
const std::vector<uint8_t>& iv)
override;
178 #endif // MEDIA_BASE_AES_ENCRYPTOR_H_