9 #ifndef MEDIA_BASE_AES_DECRYPTOR_H_
10 #define MEDIA_BASE_AES_DECRYPTOR_H_
15 #include "packager/base/memory/scoped_ptr.h"
16 #include "packager/base/stl_util.h"
17 #include "packager/media/base/aes_encryptor.h"
20 typedef struct aes_key_st AES_KEY;
22 namespace edash_packager {
30 virtual bool InitializeWithIv(
const std::vector<uint8_t>& key,
31 const std::vector<uint8_t>& iv) = 0;
36 virtual bool Decrypt(
const uint8_t* ciphertext,
37 size_t ciphertext_size,
38 uint8_t* plaintext) = 0;
40 virtual bool Decrypt(
const std::vector<uint8_t>& ciphertext,
41 std::vector<uint8_t>* plaintext) = 0;
43 virtual bool Decrypt(
const std::string& ciphertext,
44 std::string* plaintext) = 0;
49 virtual bool SetIv(
const std::vector<uint8_t>& iv) = 0;
51 const std::vector<uint8_t>& iv()
const {
return iv_; }
55 std::vector<uint8_t> iv_;
57 scoped_ptr<AES_KEY> aes_key_;
71 bool InitializeWithIv(
const std::vector<uint8_t>& key,
72 const std::vector<uint8_t>& iv)
override;
74 bool Decrypt(
const uint8_t* ciphertext,
75 size_t ciphertext_size,
76 uint8_t* plaintext)
override;
78 bool Decrypt(
const std::vector<uint8_t>& ciphertext,
79 std::vector<uint8_t>* plaintext)
override;
81 bool Decrypt(
const std::string& ciphertext, std::string* plaintext)
override;
83 bool SetIv(
const std::vector<uint8_t>& iv)
override;
86 uint32_t block_offset()
const {
return encryptor_->block_offset(); }
89 scoped_ptr<AesCtrEncryptor> encryptor_;
103 bool InitializeWithIv(
const std::vector<uint8_t>& key,
104 const std::vector<uint8_t>& iv)
override;
106 bool Decrypt(
const uint8_t* ciphertext,
107 size_t ciphertext_size,
108 uint8_t* plaintext)
override;
110 bool Decrypt(
const std::vector<uint8_t>& ciphertext,
111 std::vector<uint8_t>* plaintext)
override;
113 bool Decrypt(
const std::string& ciphertext, std::string* plaintext)
override;
115 bool SetIv(
const std::vector<uint8_t>& iv)
override;
131 bool InitializeWithIv(
const std::vector<uint8_t>& key,
132 const std::vector<uint8_t>& iv)
override;
134 bool Decrypt(
const uint8_t* ciphertext,
135 size_t ciphertext_size,
136 uint8_t* plaintext)
override;
138 bool Decrypt(
const std::vector<uint8_t>& ciphertext,
139 std::vector<uint8_t>* plaintext)
override;
141 bool Decrypt(
const std::string& ciphertext, std::string* plaintext)
override;
143 bool SetIv(
const std::vector<uint8_t>& iv)
override;
153 #endif // MEDIA_BASE_AES_DECRYPTOR_H_