aboutsummaryrefslogtreecommitdiff
path: root/gost_omac.c
diff options
context:
space:
mode:
authorVitaly Chikunov <vt@altlinux.org>2018-08-02 00:03:06 +0300
committerVitaly Chikunov <vt@altlinux.org>2018-08-02 01:18:05 +0300
commit636dd0c1f36872f0abcb4f8a465e837929ed19d1 (patch)
treee0332f14b008b6eacfce8b2c83e38d94d4d02c01 /gost_omac.c
parentae390d45207aadb69eb96d8c11c1ee888f70815f (diff)
downloadgost-engine-636dd0c1f36872f0abcb4f8a465e837929ed19d1.zip
gost-engine-636dd0c1f36872f0abcb4f8a465e837929ed19d1.tar.gz
gost-engine-636dd0c1f36872f0abcb4f8a465e837929ed19d1.tar.bz2
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 <glebfm@altlinux.org>
Diffstat (limited to 'gost_omac.c')
-rw-r--r--gost_omac.c2
1 files changed, 1 insertions, 1 deletions
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);
}