summaryrefslogtreecommitdiffstats
path: root/crypto/hmac
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2018-12-19 00:36:40 +0100
committerKurt Roeckx <kurt@roeckx.be>2019-06-06 17:41:42 +0200
commit7ed66e2634e6cfbb16a1ef975572e79a479217a8 (patch)
treecc09cf68cd6e72fe61d428842284a1f584a58a19 /crypto/hmac
parentbe5fc053ed40bb714944f93e2d35265d2096f71f (diff)
Change EVP_MAC method from copy to dup
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> GH: #7651
Diffstat (limited to 'crypto/hmac')
-rw-r--r--crypto/hmac/hm_meth.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/crypto/hmac/hm_meth.c b/crypto/hmac/hm_meth.c
index 705bf7fd2a..db9af95cb7 100644
--- a/crypto/hmac/hm_meth.c
+++ b/crypto/hmac/hm_meth.c
@@ -45,14 +45,23 @@ static void hmac_free(EVP_MAC_IMPL *hctx)
}
}
-static int hmac_copy(EVP_MAC_IMPL *hdst, EVP_MAC_IMPL *hsrc)
+static EVP_MAC_IMPL *hmac_dup(const EVP_MAC_IMPL *hsrc)
{
- if (!HMAC_CTX_copy(hdst->ctx, hsrc->ctx))
- return 0;
+ EVP_MAC_IMPL *hdst;
+
+ hdst = hmac_new();
+ if (hdst == NULL)
+ return NULL;
+
+ if (!HMAC_CTX_copy(hdst->ctx, hsrc->ctx)) {
+ hmac_free(hdst);
+ return NULL;
+ }
hdst->tmpengine = hsrc->tmpengine;
hdst->tmpmd = hsrc->tmpmd;
- return 1;
+
+ return hdst;
}
static size_t hmac_size(EVP_MAC_IMPL *hctx)
@@ -162,7 +171,7 @@ static int hmac_ctrl_str(EVP_MAC_IMPL *hctx, const char *type,
const EVP_MAC hmac_meth = {
EVP_MAC_HMAC,
hmac_new,
- hmac_copy,
+ hmac_dup,
hmac_free,
hmac_size,
hmac_init,