From 760a429ced769c5d7fc94c384165b00b77e7a7bd Mon Sep 17 00:00:00 2001 From: dmitry dulesov Date: Thu, 30 Jan 2020 05:21:31 +0300 Subject: [PATCH] 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 --- gosthash2012.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; -- 2.39.2