From: Vitaly Chikunov Date: Wed, 1 Aug 2018 21:03:06 +0000 (+0300) Subject: Fix EVP_MD_CTX_copy_ex for OMAC X-Git-Tag: v3.0.0~387 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=636dd0c1f36872f0abcb4f8a465e837929ed19d1;p=openssl-gost%2Fengine.git Fix EVP_MD_CTX_copy_ex for OMAC Openssl copies a state between valid contexts. But, EVP_MD_CTX_copy_ex just memcpy-s private data (md_data), which points to OMAC_CTX), which have pointer to CMAC_CTX. Copying pointer makes CMAC context just the same on the both sides. As a consequence, we can not do normal copy of a state between CMAC contexts. As a fix, we just clone it if it's equal between copy sides. Reported-by: Gleb Fotengauer-Malinovskiy --- diff --git a/gost_omac.c b/gost_omac.c index c4e8111..af6eb2a 100644 --- a/gost_omac.c +++ b/gost_omac.c @@ -91,7 +91,7 @@ int omac_imit_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from) } if (c_to->cmac_ctx == c_from->cmac_ctx) { - return 1; + c_to->cmac_ctx = CMAC_CTX_new(); } return CMAC_CTX_copy(c_to->cmac_ctx, c_from->cmac_ctx); }