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"
15 #include "packager/media/base/fourccs.h"
18 typedef struct aes_key_st AES_KEY;
20 namespace edash_packager {
33 const std::vector<uint8_t>&
iv) = 0;
40 bool Crypt(
const std::vector<uint8_t>& text,
41 std::vector<uint8_t>* crypt_text);
42 bool Crypt(
const std::string& text, std::string* crypt_text);
44 bool Crypt(
const uint8_t* text,
size_t text_size, uint8_t* crypt_text) {
45 size_t crypt_text_size = text_size;
46 return CryptInternal(text, text_size, crypt_text, &crypt_text_size);
52 virtual bool SetIv(
const std::vector<uint8_t>& iv) = 0;
60 const std::vector<uint8_t>&
iv()
const {
return iv_; }
67 std::vector<uint8_t>* iv);
70 void set_iv(
const std::vector<uint8_t>& iv) { iv_ =
iv; }
71 const AES_KEY* aes_key()
const {
return aes_key_.get(); }
72 AES_KEY* mutable_aes_key() {
return aes_key_.get(); }
85 virtual bool CryptInternal(
const uint8_t* text,
88 size_t* crypt_text_size) = 0;
93 virtual size_t NumPaddingBytes(
size_t size)
const;
96 std::vector<uint8_t> iv_;
98 scoped_ptr<AES_KEY> aes_key_;
100 DISALLOW_COPY_AND_ASSIGN(AesCryptor);
106 #endif // PACKAGER_MEDIA_BASE_AES_CRYPTOR_H_