Change EVP_MAC method from copy to dup
[openssl.git] / crypto / cmac / cm_meth.c
index 3f20e6c..07acf05 100644 (file)
@@ -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;
 
     cdst->tmpengine = csrc->tmpengine;
     cdst->tmpcipher = csrc->tmpcipher;
-    return 1;
+
+    return cdst;
 }
 
 static size_t cmac_size(EVP_MAC_IMPL *cctx)
 }
 
 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,
 const EVP_MAC cmac_meth = {
     EVP_MAC_CMAC,
     cmac_new,
-    cmac_copy,
+    cmac_dup,
     cmac_free,
     cmac_size,
     cmac_init,
     cmac_free,
     cmac_size,
     cmac_init,