Correct the maximum output size in cipher_test.cc

EVP_CIPH_NO_PADDING is a no-op when block_size is one, yet we sized the
output expecting it to always add a byte of padding. (I don't think this
makes a difference because most call sites of DoCipher set
EVP_CIPH_NO_PADDING.)

Bug: 494
Change-Id: Ic75e48a60e669270a093416b862ec03706e1d6ef
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55386
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
fips-20230428
David Benjamin 2 years ago committed by Boringssl LUCI CQ
parent e0d601a57f
commit 7f7599a726
  1. 5
      crypto/cipher_extra/cipher_test.cc

@ -126,9 +126,10 @@ static bool DoCipher(EVP_CIPHER_CTX *ctx, std::vector<uint8_t> *out,
bssl::Span<const uint8_t> in, size_t chunk,
bool in_place) {
size_t max_out = in.size();
if ((EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_NO_PADDING) == 0 &&
size_t block_size = EVP_CIPHER_CTX_block_size(ctx);
if (block_size > 1 &&
(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_NO_PADDING) == 0 &&
EVP_CIPHER_CTX_encrypting(ctx)) {
unsigned block_size = EVP_CIPHER_CTX_block_size(ctx);
max_out += block_size - (max_out % block_size);
}
out->resize(max_out);

Loading…
Cancel
Save