Shaka Packager SDK
|
Public Types | |
enum | ConstantIvFlag { kUseConstantIv , kDontUseConstantIv } |
Public Member Functions | |
AesCryptor (ConstantIvFlag constant_iv_flag) | |
virtual bool | InitializeWithIv (const std::vector< uint8_t > &key, const std::vector< uint8_t > &iv)=0 |
virtual size_t | RequiredOutputSize (size_t plaintext_size) |
bool | SetIv (const std::vector< uint8_t > &iv) |
void | UpdateIv () |
const std::vector< uint8_t > & | iv () const |
bool | use_constant_iv () const |
Various forms of crypt (Encrypt/Decrypt) calls. | |
It is an Encrypt function for encryptor and a Decrypt function for decryptor. The text and crypt_text pointers can be the same address for in place encryption/decryption. | |
bool | Crypt (const std::vector< uint8_t > &text, std::vector< uint8_t > *crypt_text) |
bool | Crypt (const std::string &text, std::string *crypt_text) |
bool | Crypt (const uint8_t *text, size_t text_size, uint8_t *crypt_text) |
bool | Crypt (const uint8_t *text, size_t text_size, uint8_t *crypt_text, size_t *crypt_text_size) |
Static Public Member Functions | |
static bool | GenerateRandomIv (FourCC protection_scheme, std::vector< uint8_t > *iv) |
Protected Types | |
enum | CipherMode { kCtrMode , kCbcMode } |
Protected Member Functions | |
bool | SetupCipher (size_t key_size, CipherMode mode) |
Protected Attributes | |
mbedtls_cipher_context_t | cipher_ctx_ |
Definition at line 24 of file aes_cryptor.h.
|
explicit |
constant_iv_flag | indicates whether a constant iv is used, kUseConstantIv means that the same iv is used for all Crypt calls until iv is changed via SetIv; otherwise, iv can be incremented (for counter mode) or chained (for cipher block chaining mode) internally inside Crypt call, i.e. iv will be updated across Crypt calls. |
Definition at line 32 of file aes_cryptor.cc.
|
inline |
crypt_text | should have at least text_size bytes. |
Definition at line 58 of file aes_cryptor.h.
|
static |
protection_scheme | specifies the protection scheme: 'cenc', 'cens', 'cbc1', 'cbcs', which is useful to determine the random iv size. |
iv | points to generated initialization vector. |
Definition at line 110 of file aes_cryptor.cc.
|
pure virtual |
Initialize the cryptor with specified key and IV.
Implemented in shaka::media::SampleAesEc3Cryptor, shaka::media::AesPatternCryptor, shaka::media::AesCbcEncryptor, shaka::media::AesCtrEncryptor, and shaka::media::AesCbcDecryptor.
|
inline |
Definition at line 85 of file aes_cryptor.h.
bool shaka::media::AesCryptor::SetIv | ( | const std::vector< uint8_t > & | iv | ) |
Set IV. SetIv() implementation guarantees that the iv passed to SetIv() is set to iv() and then calls SetIvInternal().
Definition at line 70 of file aes_cryptor.cc.
void shaka::media::AesCryptor::UpdateIv | ( | ) |
Update IV for next sample. As recommended in ISO/IEC 23001-7: IV need to be updated per sample for CENC. This is used by encryptors only. It is a NOP if using kUseConstantIv.
Definition at line 81 of file aes_cryptor.cc.
|
inline |
Definition at line 88 of file aes_cryptor.h.