]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
gosthash2012: Remove redundant `memset' form `init_gost2012_hash_ctx'
authordmitry dulesov <dmitry.dulesov@gmail.com>
Thu, 30 Jan 2020 00:42:48 +0000 (03:42 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sun, 2 Feb 2020 18:05:29 +0000 (21:05 +0300)
`CTX' is already fully zeroed at the beginning of
`init_gost2012_hash_ctx'.

Committed-by: Vitaly Chikunov <vt@altlinux.org>
gosthash2012.c

index e94273df0635022fa38c99e921fc97a76b178629..0233d0ababa8e675a95e8139396546b87919ea22 100644 (file)
@@ -35,10 +35,15 @@ void init_gost2012_hash_ctx(gost2012_hash_ctx * CTX,
     memset(CTX, 0, sizeof(gost2012_hash_ctx));
 
     CTX->digest_size = digest_size;
+    /*
+     * IV for 512-bit hash should be 0^512
+     * IV for 256-bit hash should be (00000001)^64
+     *
+     * It's already zeroed when CTX is cleared above, so we only
+     * need to set it to 0x01-s for 256-bit hash.
+     */
     if (digest_size == 256)
         memset(&CTX->h, 0x01, sizeof(uint512_u));
-    else
-        memset(&CTX->h, 0x00, sizeof(uint512_u));
 }
 
 static INLINE void pad(gost2012_hash_ctx * CTX)