From e0816ed2014bad0e5293cafcce2c07a66a4f1cb0 Mon Sep 17 00:00:00 2001 From: Vitaly Chikunov Date: Thu, 2 Aug 2018 21:41:02 +0300 Subject: [PATCH] Allow EVP_MD_CTX_copy_ex OMAC before key is set Reported-by: Gleb Fotengauer-Malinovskiy --- gost_omac.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gost_omac.c b/gost_omac.c index d1f897a..e78fd9d 100644 --- a/gost_omac.c +++ b/gost_omac.c @@ -92,6 +92,13 @@ int omac_imit_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from) { return 0; } + if (!c_from->cmac_ctx) { + if (c_to->cmac_ctx) { + CMAC_CTX_free(c_to->cmac_ctx); + c_to->cmac_ctx = NULL; + } + return 1; + } if (c_to->cmac_ctx == c_from->cmac_ctx) { c_to->cmac_ctx = CMAC_CTX_new(); -- 2.39.2