Commit dffc5e3a5e for openssl.org
commit dffc5e3a5e65fe3fe9e8a610fbb4b8aff9332fdc
Author: Billy Brumley <bbb@iki.fi>
Date: Thu Oct 22 03:37:34 2026 -0400
AES-SIV: fix NULL pointer dereference on an unkeyed context
Supplying associated data to a context that has never been keyed
dereferenced a NULL MAC context, only created when a key is set.
Finalization on such a context also reported success.
Refuse to operate without a key, as the other AEADs do.
Assisted-by: Claude:claude-fable-5-1
Reviewed-by: Richard Levitte <levitte@openssl.foundation>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Merge-date: Sun Nov 8 21:43:13 2026
Merged-from: https://github.com/openssl/openssl/pull/33116
diff --git a/providers/implementations/ciphers/cipher_aes_siv.c b/providers/implementations/ciphers/cipher_aes_siv.c
index bce0666c21..3b501bccdc 100644
--- a/providers/implementations/ciphers/cipher_aes_siv.c
+++ b/providers/implementations/ciphers/cipher_aes_siv.c
@@ -119,6 +119,12 @@ static int siv_cipher(void *vctx, unsigned char *out, size_t *outl,
if (!ossl_prov_is_running())
return 0;
+ /* no key set: the MAC context only exists once a key has been set */
+ if (ctx->siv.mac_ctx_init == NULL) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
+ return 0;
+ }
+
if (in == NULL && inl != 0) {
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
return 0;
@@ -145,6 +151,12 @@ static int siv_stream_final(void *vctx, unsigned char *out, size_t *outl,
if (!ossl_prov_is_running())
return 0;
+ /* no key set: the MAC context only exists once a key has been set */
+ if (ctx->siv.mac_ctx_init == NULL) {
+ ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
+ return 0;
+ }
+
if (!ctx->hw->cipher(vctx, out, NULL, 0))
return 0;