[PATCH 3/4] gost28147: do not use GOST28147_CONTEXT outside of GOST 28147 calculation

dbaryshkov at gmail.com dbaryshkov at gmail.com
Tue Nov 12 14:50:04 CET 2019


From: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>

* cipher/gost28147.c (_gcry_gost_enc_data): remove unused context
  argument
* cipher/gostr3411-94.c (GOSTR3411_CONTEXT, gostr3411_init,
  do_hash_step): remove unused GOST 28147-89 context.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
 cipher/gost.h         | 2 +-
 cipher/gost28147.c    | 2 +-
 cipher/gostr3411-94.c | 4 +---
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/cipher/gost.h b/cipher/gost.h
index 025119c90656..04c2f85e57d2 100644
--- a/cipher/gost.h
+++ b/cipher/gost.h
@@ -26,7 +26,7 @@ typedef struct {
 } GOST28147_context;
 
 /* This is a simple interface that will be used by GOST R 34.11-94 */
-unsigned int _gcry_gost_enc_data (GOST28147_context *c, const u32 *key,
+unsigned int _gcry_gost_enc_data (const u32 *key,
     u32 *o1, u32 *o2, u32 n1, u32 n2, int cryptopro);
 
 #endif
diff --git a/cipher/gost28147.c b/cipher/gost28147.c
index 85d398d7b7de..db7e9412c7cd 100644
--- a/cipher/gost28147.c
+++ b/cipher/gost28147.c
@@ -120,7 +120,7 @@ gost_encrypt_block (void *c, byte *outbuf, const byte *inbuf)
   return /* burn_stack */ burn + 6*sizeof(void*) /* func call */;
 }
 
-unsigned int _gcry_gost_enc_data (GOST28147_context *c, const u32 *key,
+unsigned int _gcry_gost_enc_data (const u32 *key,
     u32 *o1, u32 *o2, u32 n1, u32 n2, int cryptopro)
 {
   const u32 *sbox;
diff --git a/cipher/gostr3411-94.c b/cipher/gostr3411-94.c
index c5a0aef63de3..7cf0637e26ed 100644
--- a/cipher/gostr3411-94.c
+++ b/cipher/gostr3411-94.c
@@ -35,7 +35,6 @@
 
 typedef struct {
   gcry_md_block_ctx_t bctx;
-  GOST28147_context hd;
   union {
     u32 h[8];
     byte result[32];
@@ -55,7 +54,6 @@ gost3411_init (void *context, unsigned int flags)
 
   (void)flags;
 
-  memset (&hd->hd, 0, sizeof(hd->hd));
   memset (hd->h, 0, 32);
   memset (hd->sigma, 0, 32);
 
@@ -228,7 +226,7 @@ do_hash_step (GOSTR3411_CONTEXT *hd, u32 *h, u32 *m)
   for (i = 0; i < 4; i++) {
     do_p (k, u, v);
 
-    burn = _gcry_gost_enc_data (&hd->hd, k, &s[2*i], &s[2*i+1], h[2*i], h[2*i+1], hd->cryptopro);
+    burn = _gcry_gost_enc_data (k, &s[2*i], &s[2*i+1], h[2*i], h[2*i+1], hd->cryptopro);
 
     do_a (u);
     if (i == 1)
-- 
2.24.0




More information about the Gcrypt-devel mailing list