diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2018-11-04 19:16:20 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2019-06-06 17:41:41 +0200 |
commit | be5fc053ed40bb714944f93e2d35265d2096f71f (patch) | |
tree | c3cf4d433e820288944c7f4eeb04bfccd9f2d86c /crypto/evp/mac_lib.c | |
parent | e6071f29c24cd22ac7857bf88917598265cc90a9 (diff) |
Replace EVP_MAC_CTX_copy() by EVP_MAC_CTX_dup()
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
GH: #7651
Diffstat (limited to 'crypto/evp/mac_lib.c')
-rw-r--r-- | crypto/evp/mac_lib.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index 39efff0842..d11fae099c 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -48,18 +48,28 @@ void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx) OPENSSL_free(ctx); } -int EVP_MAC_CTX_copy(EVP_MAC_CTX *dst, const EVP_MAC_CTX *src) +EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src) { - EVP_MAC_IMPL *macdata; + EVP_MAC_CTX *dst = EVP_MAC_CTX_new(src->meth); - if (src->data != NULL && !dst->meth->copy(dst->data, src->data)) - return 0; + if (dst == NULL) + return NULL; + + dst = OPENSSL_malloc(sizeof(*dst)); + if (dst == NULL) { + EVPerr(EVP_F_EVP_MAC_CTX_DUP, ERR_R_MALLOC_FAILURE); + return NULL; + } - macdata = dst->data; *dst = *src; - dst->data = macdata; - return 1; + dst->data = src->meth->dup(src->data); + if (dst->data == NULL) { + EVP_MAC_CTX_free(dst); + return NULL; + } + + return dst; } const EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx) |