From: dmitry dulesov Date: Thu, 30 Jan 2020 00:42:48 +0000 (+0300) Subject: gosthash2012: Remove redundant `memset' form `init_gost2012_hash_ctx' X-Git-Tag: v3.0.0~222 X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=openssl-gost%2Fengine.git;a=commitdiff_plain;h=fd4a24ec4b104e59df7b73da8f0f6487a28865ee gosthash2012: Remove redundant `memset' form `init_gost2012_hash_ctx' `CTX' is already fully zeroed at the beginning of `init_gost2012_hash_ctx'. Committed-by: Vitaly Chikunov --- diff --git a/gosthash2012.c b/gosthash2012.c index e94273d..0233d0a 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -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)