]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Allow EVP_MD_CTX_copy_ex OMAC before key is set
authorVitaly Chikunov <vt@altlinux.org>
Thu, 2 Aug 2018 18:41:02 +0000 (21:41 +0300)
committerVitaly Chikunov <vt@altlinux.org>
Wed, 8 Aug 2018 18:15:25 +0000 (21:15 +0300)
Reported-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
gost_omac.c

index d1f897a15c2227b8936e51625eeb73f818b433a3..e78fd9d7c5de76e3e7b00c80e7a18a1e5b26eeb9 100644 (file)
@@ -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();