summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-11-04 11:06:26 +0100
committerTomas Mraz <tomas@openssl.org>2021-11-12 16:41:15 +0100
commit33665a9389e216b5a1f64fa48c8795dc78973621 (patch)
tree26c88815fec180fd57b741a1252068b100a5bdaa /providers
parent32b172b0b5ee8f3ba9efffb13b3f612024b9e13d (diff)
do_sigver_init: Allow reinitialization of an existing operation.
Fixes #16936 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16964) (cherry picked from commit ae6b68b761b9c5f30897747487ea943ccfab53ba)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/signature/mac_legacy_sig.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/providers/implementations/signature/mac_legacy_sig.c b/providers/implementations/signature/mac_legacy_sig.c
index 06f79505ff..0866e68d9b 100644
--- a/providers/implementations/signature/mac_legacy_sig.c
+++ b/providers/implementations/signature/mac_legacy_sig.c
@@ -101,13 +101,16 @@ static int mac_digest_sign_init(void *vpmacctx, const char *mdname, void *vkey,
const char *ciphername = NULL, *engine = NULL;
if (!ossl_prov_is_running()
- || pmacctx == NULL
- || vkey == NULL
- || !ossl_mac_key_up_ref(vkey))
+ || pmacctx == NULL
+ || (pmacctx->key == NULL && vkey == NULL))
return 0;
- ossl_mac_key_free(pmacctx->key);
- pmacctx->key = vkey;
+ if (vkey != NULL) {
+ if (!ossl_mac_key_up_ref(vkey))
+ return 0;
+ ossl_mac_key_free(pmacctx->key);
+ pmacctx->key = vkey;
+ }
if (pmacctx->key->cipher.cipher != NULL)
ciphername = (char *)EVP_CIPHER_get0_name(pmacctx->key->cipher.cipher);