Commit 78b1eabec7 for openssl.org
commit 78b1eabec7ee25e38a31517c2592d31077c951cf
Author: Trust-Worthy <jondeveloper0@gmail.com>
Date: Wed Oct 21 18:42:19 2026 -0400
providers/implementations/ciphers/cipher_aes_ocb.c: handle AAD in EVP_Cipher()
EVP_Cipher() takes AAD as input with a NULL output. The AES-OCB
one-shot function had no case for this, so the AAD was encrypted
as payload and written to the NULL output, which crashed the caller.
Pass a NULL output to the same code Update uses for AAD. EVP_Cipher()
then gives the same ciphertext and tag as Update and Final. The other
AEADs already handle a NULL output this way.
Fixes: 3837c202b5e9 "Add aes_ocb cipher to providers"
Assisted-by: Claude:claude-opus-5-5
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Billy Bob Brumley <bbb@iki.fi>
Merge-date: Sun Nov 22 15:26:44 2026
Merged-from: https://github.com/openssl/openssl/pull/33312
diff --git a/providers/implementations/ciphers/cipher_aes_ocb.c b/providers/implementations/ciphers/cipher_aes_ocb.c
index bb7231dd8a..aab6f6994d 100644
--- a/providers/implementations/ciphers/cipher_aes_ocb.c
+++ b/providers/implementations/ciphers/cipher_aes_ocb.c
@@ -517,6 +517,10 @@ static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl,
if (in == NULL)
return aes_ocb_block_final(vctx, out, outl, outsize);
+ /* A NULL output passes AAD, as with Update */
+ if (out == NULL)
+ return aes_ocb_block_update(vctx, out, outl, outsize, in, inl);
+
if (outsize < inl) {
ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
return 0;