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>
diff --git a/crypto/cipher_extra/cipher_test.cc b/crypto/cipher_extra/cipher_test.cc index 44c3570..1cbda56 100644 --- a/crypto/cipher_extra/cipher_test.cc +++ b/crypto/cipher_extra/cipher_test.cc
@@ -126,9 +126,10 @@ 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);