Skip to content

Commit

Permalink
address some feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed Jul 6, 2023
1 parent 0818719 commit da098c5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packager/media/base/aes_encryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ bool AesCbcEncryptor::CryptInternal(const uint8_t* plaintext,
size_t* ciphertext_size) {

const size_t num_padding_bytes = NumPaddingBytes(plaintext_size);
// mbedtls requires a buffer large enough for one extra block.
const size_t required_ciphertext_size =
plaintext_size + num_padding_bytes + AES_BLOCK_SIZE;

if (*ciphertext_size < required_ciphertext_size) {
VLOG(1) << "Expected output size of at least "
<< required_ciphertext_size << " bytes. Using teporary buffer.";
<< required_ciphertext_size << " bytes. Using temporary buffer.";

std::unique_ptr<uint8_t[]> ciphertext_buffer(new uint8_t[required_ciphertext_size]);
auto result = CryptInternal0(plaintext, plaintext_size, ciphertext_buffer.get(), ciphertext_size);
Expand Down

0 comments on commit da098c5

Please sign in to comment.