diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2018-12-19 00:36:40 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2019-06-06 17:41:42 +0200 |
commit | 7ed66e2634e6cfbb16a1ef975572e79a479217a8 (patch) | |
tree | cc09cf68cd6e72fe61d428842284a1f584a58a19 /crypto/cmac | |
parent | be5fc053ed40bb714944f93e2d35265d2096f71f (diff) |
Change EVP_MAC method from copy to dup
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
GH: #7651
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, |