diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/cmac/cm_pmeth.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/lib/libcrypto/cmac/cm_pmeth.c b/src/lib/libcrypto/cmac/cm_pmeth.c index fa2d53e53d..03538e204e 100644 --- a/src/lib/libcrypto/cmac/cm_pmeth.c +++ b/src/lib/libcrypto/cmac/cm_pmeth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: cm_pmeth.c,v 1.11 2023/11/29 21:35:57 tb Exp $ */ | 1 | /* $OpenBSD: cm_pmeth.c,v 1.12 2023/12/28 21:56:12 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2010. | 3 | * project 2010. |
4 | */ | 4 | */ |
@@ -92,18 +92,23 @@ pkey_cmac_cleanup(EVP_PKEY_CTX *ctx) | |||
92 | static int | 92 | static int |
93 | pkey_cmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) | 93 | pkey_cmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) |
94 | { | 94 | { |
95 | CMAC_CTX *cmkey = CMAC_CTX_new(); | 95 | CMAC_CTX *cmkey; |
96 | CMAC_CTX *cmctx = ctx->data; | 96 | int ret = 0; |
97 | 97 | ||
98 | if (!cmkey) | 98 | if ((cmkey = CMAC_CTX_new()) == NULL) |
99 | return 0; | 99 | goto err; |
100 | if (!CMAC_CTX_copy(cmkey, cmctx)) { | 100 | if (!CMAC_CTX_copy(cmkey, ctx->data)) |
101 | CMAC_CTX_free(cmkey); | 101 | goto err; |
102 | return 0; | 102 | if (!EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey)) |
103 | } | 103 | goto err; |
104 | EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey); | 104 | cmkey = NULL; |
105 | 105 | ||
106 | return 1; | 106 | ret = 1; |
107 | |||
108 | err: | ||
109 | CMAC_CTX_free(cmkey); | ||
110 | |||
111 | return ret; | ||
107 | } | 112 | } |
108 | 113 | ||
109 | static int | 114 | static int |