}
}
-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)
const EVP_MAC cmac_meth = {
EVP_MAC_CMAC,
cmac_new,
- cmac_copy,
+ cmac_dup,
cmac_free,
cmac_size,
cmac_init,