[PATCH 6/7] Remove extra buffer flush at begining of digest final functions

Jussi Kivilinna jussi.kivilinna at iki.fi
Fri Apr 5 19:26:10 CEST 2019


* cipher/md2.c (md2_final): Remove _gcry_md_block_write flush call
from entry.
* cipher/md4.c (md4_final): Ditto.
* cipher/md5.c (md5_final): Ditto.
* cipher/rmd160.c (rmd160_final): Ditto.
* cipher/sha1.c (sha1_final): Ditto.
* cipher/sha256.c (sha256_final): Ditto.
* cipher/sha512.c (sha512_final): Ditto.
* cipher/sm3.c (sm3_final): Ditto.
* cipher/stribog.c (stribog_final): Ditto.
* cipher/tiger.c (tiger_final): Ditto.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 0 files changed

diff --git a/cipher/md2.c b/cipher/md2.c
index b6f7e94f4..bf2fbee4c 100644
--- a/cipher/md2.c
+++ b/cipher/md2.c
@@ -146,8 +146,6 @@ md2_final (void *context)
   MD2_CONTEXT *hd = context;
   unsigned int burn;
 
-  _gcry_md_block_write(hd, NULL, 0); /* flush */;
-
   /* pad */
   memset (hd->bctx.buf + hd->bctx.count,
           16 - hd->bctx.count, 16 - hd->bctx.count);
diff --git a/cipher/md4.c b/cipher/md4.c
index 997dbe0ce..f6258893e 100644
--- a/cipher/md4.c
+++ b/cipher/md4.c
@@ -213,8 +213,6 @@ md4_final( void *context )
   byte *p;
   unsigned int burn;
 
-  _gcry_md_block_write(hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
diff --git a/cipher/md5.c b/cipher/md5.c
index c432502ff..67511ba01 100644
--- a/cipher/md5.c
+++ b/cipher/md5.c
@@ -237,8 +237,6 @@ md5_final( void *context)
   byte *p;
   unsigned int burn;
 
-  _gcry_md_block_write(hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
diff --git a/cipher/rmd160.c b/cipher/rmd160.c
index 231640d27..f15eec225 100644
--- a/cipher/rmd160.c
+++ b/cipher/rmd160.c
@@ -410,8 +410,6 @@ rmd160_final( void *context )
   byte *p;
   unsigned int burn;
 
-  _gcry_md_block_write(hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
diff --git a/cipher/sha1.c b/cipher/sha1.c
index affabfb07..23aceef32 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -511,8 +511,6 @@ sha1_final(void *context)
   unsigned char *p;
   unsigned int burn;
 
-  _gcry_md_block_write (hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
@@ -532,7 +530,7 @@ sha1_final(void *context)
   msb <<= 3;
   msb |= t >> 29;
 
-  if( hd->bctx.count < 56 )  /* enough room */
+  if (hd->bctx.count < 56)  /* enough room */
     {
       hd->bctx.buf[hd->bctx.count++] = 0x80; /* pad */
       if (hd->bctx.count < 56)
diff --git a/cipher/sha256.c b/cipher/sha256.c
index 327e1029f..6c6833482 100644
--- a/cipher/sha256.c
+++ b/cipher/sha256.c
@@ -477,8 +477,6 @@ sha256_final(void *context)
   byte *p;
   unsigned int burn;
 
-  _gcry_md_block_write (hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
diff --git a/cipher/sha512.c b/cipher/sha512.c
index 615b55357..59e65f07a 100644
--- a/cipher/sha512.c
+++ b/cipher/sha512.c
@@ -635,8 +635,6 @@ sha512_final (void *context)
   u64 t, th, msb, lsb;
   byte *p;
 
-  _gcry_md_block_write (context, NULL, 0); /* flush */ ;
-
   t = hd->bctx.nblocks;
   /* if (sizeof t == sizeof hd->bctx.nblocks) */
   th = hd->bctx.nblocks_high;
diff --git a/cipher/sm3.c b/cipher/sm3.c
index 7bfb37b95..e76f32297 100644
--- a/cipher/sm3.c
+++ b/cipher/sm3.c
@@ -270,8 +270,6 @@ sm3_final(void *context)
   byte *p;
   unsigned int burn;
 
-  _gcry_md_block_write (hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;
diff --git a/cipher/stribog.c b/cipher/stribog.c
index d31dddd37..3eb077356 100644
--- a/cipher/stribog.c
+++ b/cipher/stribog.c
@@ -1287,7 +1287,6 @@ stribog_final (void *context)
   u64 Z[8] = {};
   int i;
 
-  _gcry_md_block_write (context, NULL, 0); /* flush */ ;
   /* PAD. It does not count towards message length */
   i = hd->bctx.count;
   /* After flush we have at least one byte free) */
diff --git a/cipher/tiger.c b/cipher/tiger.c
index 0319b7115..c78e3ac35 100644
--- a/cipher/tiger.c
+++ b/cipher/tiger.c
@@ -736,8 +736,6 @@ tiger_final( void *context )
   unsigned int burn;
   byte pad = hd->variant == 2? 0x80 : 0x01;
 
-  _gcry_md_block_write(hd, NULL, 0); /* flush */;
-
   t = hd->bctx.nblocks;
   if (sizeof t == sizeof hd->bctx.nblocks)
     th = hd->bctx.nblocks_high;




More information about the Gcrypt-devel mailing list