Commit 2c92eba8fb for openssl.org

commit 2c92eba8fbdaddb23497e1f18619a949ce0e1bc2
Author: Trust-Worthy <jondeveloper0@gmail.com>
Date:   Tue Sep 29 18:08:19 2026 -0400

    Reject a NULL input to update in the other AEADs

    An update with no input buffer and a nonzero length was accepted by
    the GCM, CCM, SIV, GCM-SIV, ChaCha20-Poly1305 and ASCON implementations.
    Reject it, except for the CCM message length, which is passed with no
    input and no output.

    Assisted-by: Claude:claude-opus-5-5
    Reviewed-by: Paul Dale <paul.dale@oracle.com>
    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Merge-date: Wed Oct 21 16:59:57 2026
    Merged-from: https://github.com/openssl/openssl/pull/33157

diff --git a/providers/implementations/ciphers/cipher_aes_gcm_siv.c b/providers/implementations/ciphers/cipher_aes_gcm_siv.c
index ea343eb810..371caddb1d 100644
--- a/providers/implementations/ciphers/cipher_aes_gcm_siv.c
+++ b/providers/implementations/ciphers/cipher_aes_gcm_siv.c
@@ -145,6 +145,11 @@ static int ossl_aes_gcm_siv_cipher(void *vctx, unsigned char *out, size_t *outl,
     if (!ossl_prov_is_running())
         return 0;

+    if (in == NULL && inl != 0) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     if (outsize < inl) {
         ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
         return 0;
diff --git a/providers/implementations/ciphers/cipher_aes_siv.c b/providers/implementations/ciphers/cipher_aes_siv.c
index 3c358f33e1..bce0666c21 100644
--- a/providers/implementations/ciphers/cipher_aes_siv.c
+++ b/providers/implementations/ciphers/cipher_aes_siv.c
@@ -119,6 +119,11 @@ static int siv_cipher(void *vctx, unsigned char *out, size_t *outl,
     if (!ossl_prov_is_running())
         return 0;

+    if (in == NULL && inl != 0) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     if (out != NULL && outsize < inl) {
         ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
         return 0;
diff --git a/providers/implementations/ciphers/cipher_ascon_aead128.c b/providers/implementations/ciphers/cipher_ascon_aead128.c
index 281c5c2ca7..d4ae002ad8 100644
--- a/providers/implementations/ciphers/cipher_ascon_aead128.c
+++ b/providers/implementations/ciphers/cipher_ascon_aead128.c
@@ -229,6 +229,11 @@ static int ascon_aead128_update(void *vctx, unsigned char *out, size_t *outl,
         return 0;
     }

+    if (in == NULL && inl != 0) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     /* Handle AAD operation (out == NULL) - process associated data */
     if (out == NULL) {
         /* Can only add AAD before encryption/decryption updates start */
diff --git a/providers/implementations/ciphers/cipher_chacha20_poly1305.c b/providers/implementations/ciphers/cipher_chacha20_poly1305.c
index 5b8e68af09..d813cf28da 100644
--- a/providers/implementations/ciphers/cipher_chacha20_poly1305.c
+++ b/providers/implementations/ciphers/cipher_chacha20_poly1305.c
@@ -320,6 +320,11 @@ static int chacha20_poly1305_update(void *vctx, unsigned char *out,
         return 1;
     }

+    if (in == NULL) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     return chacha20_poly1305_cipher(vctx, out, outl, outsize, in, inl);
 }

diff --git a/providers/implementations/ciphers/ciphercommon_ccm.c b/providers/implementations/ciphers/ciphercommon_ccm.c
index 30ec95daad..3ed25e4a8e 100644
--- a/providers/implementations/ciphers/ciphercommon_ccm.c
+++ b/providers/implementations/ciphers/ciphercommon_ccm.c
@@ -267,6 +267,12 @@ int ossl_ccm_stream_update(void *vctx, unsigned char *out, size_t *outl,
 {
     PROV_CCM_CTX *ctx = (PROV_CCM_CTX *)vctx;

+    /* A NULL input is only valid as the message length, with no output. */
+    if (in == NULL && out != NULL && inl != 0) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     if (outsize < inl) {
         ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
         return 0;
diff --git a/providers/implementations/ciphers/ciphercommon_gcm.c b/providers/implementations/ciphers/ciphercommon_gcm.c
index c5c1270328..805fa6d9d4 100644
--- a/providers/implementations/ciphers/ciphercommon_gcm.c
+++ b/providers/implementations/ciphers/ciphercommon_gcm.c
@@ -359,6 +359,11 @@ int ossl_gcm_stream_update(void *vctx, unsigned char *out, size_t *outl,
         return 1;
     }

+    if (in == NULL) {
+        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     if (outsize < inl) {
         ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
         return 0;