]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
gosthash2012: Remove temporary variable from `stage2'
authordmitry dulesov <dmitry.dulesov@gmail.com>
Thu, 30 Jan 2020 02:21:31 +0000 (05:21 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sun, 2 Feb 2020 18:05:29 +0000 (21:05 +0300)
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 <vt@altlinux.org>
gosthash2012.c

index 68ee0901875aaf782a3214ce4119eb631f2af44b..632c4bfde4c9e106412b5369968cc6ef83de1c16 100644 (file)
@@ -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;