7 #ifndef PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_
8 #define PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_
13 #include "packager/base/macros.h"
14 #include "packager/base/memory/scoped_ptr.h"
17 typedef struct aes_key_st AES_KEY;
19 namespace edash_packager {
32 const std::vector<uint8_t>&
iv) = 0;
39 bool Crypt(
const std::vector<uint8_t>& text,
40 std::vector<uint8_t>* crypt_text);
41 bool Crypt(
const std::string& text, std::string* crypt_text);
43 bool Crypt(
const uint8_t* text,
size_t text_size, uint8_t* crypt_text) {
44 size_t crypt_text_size = text_size;
45 return CryptInternal(text, text_size, crypt_text, &crypt_text_size);
51 virtual bool SetIv(
const std::vector<uint8_t>& iv) = 0;
59 const std::vector<uint8_t>&
iv()
const {
return iv_; }
62 void set_iv(
const std::vector<uint8_t>& iv) { iv_ =
iv; }
63 const AES_KEY* aes_key()
const {
return aes_key_.get(); }
64 AES_KEY* mutable_aes_key() {
return aes_key_.get(); }
77 virtual bool CryptInternal(
const uint8_t* text,
80 size_t* crypt_text_size) = 0;
85 virtual size_t NumPaddingBytes(
size_t size)
const;
88 std::vector<uint8_t> iv_;
90 scoped_ptr<AES_KEY> aes_key_;
92 DISALLOW_COPY_AND_ASSIGN(AesCryptor);
98 #endif // PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_