From: dmitry dulesov Date: Thu, 30 Jan 2020 02:21:31 +0000 (+0300) Subject: gosthash2012: Remove temporary variable from `stage2' X-Git-Tag: v3.0.0~218 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=760a429ced769c5d7fc94c384165b00b77e7a7bd;p=openssl-gost%2Fengine.git gosthash2012: Remove temporary variable from `stage2' Now `stage2' will always get aligned data which is prepared in `gost2012_hash_block' by copying into `CTX->buffer'. This will allow to change `data' argument of `stage2' from `unsigned char *' pointer to `union uint512_u *'. Committed-by: Vitaly Chikunov --- diff --git a/gosthash2012.c b/gosthash2012.c index 68ee090..632c4bf 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -150,13 +150,10 @@ static void g(union uint512_u *h, const union uint512_u *N, static INLINE void stage2(gost2012_hash_ctx * CTX, const unsigned char *data) { - union uint512_u m; - - memcpy(&m, data, sizeof(m)); - g(&(CTX->h), &(CTX->N), (const unsigned char *)&m); + g(&(CTX->h), &(CTX->N), data); add512(&(CTX->N), &buffer512); - add512(&(CTX->Sigma), &m); + add512(&(CTX->Sigma), (const union uint512_u *)data); } static INLINE void stage3(gost2012_hash_ctx * CTX) @@ -196,7 +193,8 @@ void gost2012_hash_block(gost2012_hash_ctx * CTX, size_t chunksize; while (len > 63 && CTX->bufsize == 0) { - stage2(CTX, data); + memcpy(&CTX->buffer[0], data, 64); + stage2(CTX, &CTX->buffer[0]); data += 64; len -= 64;