]> git.ipfire.org Git - thirdparty/openssl.git/commit
evp-cmac: do not seg-fault when getting mac-size before init
authorJames Muir <james@openssl.org>
Wed, 29 Nov 2023 03:43:52 +0000 (22:43 -0500)
committerTomas Mraz <tomas@openssl.org>
Fri, 1 Dec 2023 10:55:40 +0000 (11:55 +0100)
commit6c1d383fc3f58156105a92c51ddfa8d3eae69710
tree95e5146ecbca34953b859a3eaebd80ca7ef0c7f5
parent4ffa17248736300dcbca58ba57aa0badac80c388
evp-cmac: do not seg-fault when getting mac-size before init

Add null check to cmac_size().  This avoids a seg-fault encountered
with cmac when EVP_MAC_CTX_get_mac_size() is called before init.

Extend mac testing in evp_test.c to check that the sizes returned by
EVP_MAC_CTX_get_mac_size() before and after init make sense (this also
ensures that we no longer seg-fault).

Fixes #22842

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22858)

(cherry picked from commit ff181969e28c1503b077b47a9ded3683524b3fd8)
providers/implementations/macs/cmac_prov.c
test/evp_test.c