Skip to content

Commit

Permalink
apply clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed Jul 6, 2023
1 parent da098c5 commit e93d6fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
19 changes: 10 additions & 9 deletions packager/media/base/aes_encryptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,19 @@ bool AesCbcEncryptor::CryptInternal(const uint8_t* plaintext,
size_t plaintext_size,
uint8_t* ciphertext,
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 temporary buffer.";
VLOG(1) << "Expected output size of at least " << 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);
std::unique_ptr<uint8_t[]> ciphertext_buffer(
new uint8_t[required_ciphertext_size]);
auto result = CryptInternal0(plaintext, plaintext_size,
ciphertext_buffer.get(), ciphertext_size);
if (result) {
memcpy(ciphertext, ciphertext_buffer.get(), *ciphertext_size);
}
Expand All @@ -151,15 +152,15 @@ bool AesCbcEncryptor::CryptInternal(const uint8_t* plaintext,
}

bool AesCbcEncryptor::CryptInternal0(const uint8_t* plaintext,
size_t plaintext_size,
uint8_t* ciphertext,
size_t* ciphertext_size) {
size_t plaintext_size,
uint8_t* ciphertext,
size_t* ciphertext_size) {
const size_t residual_block_size = plaintext_size % AES_BLOCK_SIZE;
const size_t num_padding_bytes = NumPaddingBytes(plaintext_size);
// mbedtls requires a buffer large enough for one extra block.
if (*ciphertext_size < plaintext_size + num_padding_bytes) {
LOG(ERROR) << "Expecting output size of at least "
<< plaintext_size + num_padding_bytes << " bytes.";
<< plaintext_size + num_padding_bytes << " bytes.";
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions packager/media/base/aes_encryptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class AesCbcEncryptor : public AesCryptor {
uint8_t* ciphertext,
size_t* ciphertext_size) override;
bool CryptInternal0(const uint8_t* plaintext,
size_t plaintext_size,
uint8_t* ciphertext,
size_t* ciphertext_size);
size_t plaintext_size,
uint8_t* ciphertext,
size_t* ciphertext_size);
void SetIvInternal() override;
size_t NumPaddingBytes(size_t size) const override;

Expand Down
2 changes: 1 addition & 1 deletion packager/media/crypto/encryption_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ void EncryptionHandler::EncryptBytes(const uint8_t* source,
DCHECK(dest);
DCHECK(encryptor_);
CHECK(encryptor_->Crypt(source, source_size, dest, &source_size));
//bzd CHECK(encryptor_->Crypt(source, dest));
// bzd CHECK(encryptor_->Crypt(source, dest));
}

void EncryptionHandler::InjectSubsampleGeneratorForTesting(
Expand Down

0 comments on commit e93d6fa

Please sign in to comment.