diff options
| author | Trust-Worthy <[email protected]> | 2026-09-30 00:08:19 +0200 |
|---|---|---|
| committer | Tomas Mraz <[email protected]> | 2026-10-21 18:59:44 +0200 |
| commit | 2c92eba8fbdaddb23497e1f18619a949ce0e1bc2 (patch) | |
| tree | 244884da3adc5ac304373bc82694a62c148aff7d | |
| parent | AES-OCB: reject a NULL input to update (diff) | |
| download | openssl-2c92eba8fbdaddb23497e1f18619a949ce0e1bc2.tar.gz openssl-2c92eba8fbdaddb23497e1f18619a949ce0e1bc2.zip | |
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 <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
Merge-date: Wed Oct 21 16:59:57 2026
Merged-from: https://github.com/openssl/openssl/pull/33157
6 files changed, 31 insertions, 0 deletions
diff --git a/providers/implementations/ciphers/cipher_aes_gcm_siv.c b/providers/implementations/ciphers/cipher_aes_gcm_siv.c index ea343eb810c..371caddb1d8 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 3c358f33e10..bce0666c218 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 281c5c2ca7b..d4ae002ad82 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 5b8e68af098..d813cf28da6 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 30ec95daad3..3ed25e4a8ea 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 c5c12703285..805fa6d9d4a 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; |
