diff options
Diffstat (limited to 'crypto/cmac')
-rw-r--r-- | crypto/cmac/cm_meth.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crypto/cmac/cm_meth.c b/crypto/cmac/cm_meth.c index 3f20e6ce06..07acf050b3 100644 --- a/crypto/cmac/cm_meth.c +++ b/crypto/cmac/cm_meth.c @@ -46,14 +46,22 @@ static void cmac_free(EVP_MAC_IMPL *cctx) } } -static int cmac_copy(EVP_MAC_IMPL *cdst, EVP_MAC_IMPL *csrc) +static EVP_MAC_IMPL *cmac_dup(const EVP_MAC_IMPL *csrc) { - if (!CMAC_CTX_copy(cdst->ctx, csrc->ctx)) - return 0; + EVP_MAC_IMPL *cdst = cmac_new(); + + if (cdst == NULL) + return NULL; + + if (!CMAC_CTX_copy(cdst->ctx, csrc->ctx)) { + cmac_free(cdst); + return NULL; + } cdst->tmpengine = csrc->tmpengine; cdst->tmpcipher = csrc->tmpcipher; - return 1; + + return cdst; } static size_t cmac_size(EVP_MAC_IMPL *cctx) @@ -153,7 +161,7 @@ static int cmac_ctrl_str(EVP_MAC_IMPL *cctx, const char *type, const EVP_MAC cmac_meth = { EVP_MAC_CMAC, cmac_new, - cmac_copy, + cmac_dup, cmac_free, cmac_size, cmac_init, |