Avoid undefined behavior of provided macs on EVP_MAC reinitialization
authorTomas Mraz <tomas@openssl.org>
Tue, 12 Apr 2022 15:58:23 +0000 (17:58 +0200)
committerTomas Mraz <tomas@openssl.org>
Tue, 19 Apr 2022 12:06:38 +0000 (14:06 +0200)
commitc9ddc5af5199909d196ee80ccd7abcff2eb42a34
treecfb0a7fa61fc59ebacb79b78ab4d65a6c464c04b
parente58ba181de6b0dfad0dc371f8d962c82138a906e
Avoid undefined behavior of provided macs on EVP_MAC reinitialization

When the context is reinitialized, i.e. the same key should be used
we must properly reinitialize the underlying implementation.

However in POLY1305 case it does not make sense as this special MAC
should not reuse keys. We fail with this provided implementation
when reinitialization happens.

Fixes #17811

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18100)
providers/implementations/macs/cmac_prov.c
providers/implementations/macs/gmac_prov.c
providers/implementations/macs/hmac_prov.c
providers/implementations/macs/poly1305_prov.c
providers/implementations/macs/siphash_prov.c