[PATCH] Stribog endianness fixup

Dmitry Eremin-Solenikov dbaryshkov at gmail.com
Fri Jun 6 20:48:27 CEST 2014


Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
---
 cipher/gost28147.c    | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++
 cipher/mac-internal.h |   9 ++++
 cipher/mac.c          |   3 ++
 cipher/stribog.c      |  10 ++--
 src/gcrypt.h.in       |   1 +
 tests/basic.c         |   7 +++
 6 files changed, 155 insertions(+), 5 deletions(-)

diff --git a/cipher/stribog.c b/cipher/stribog.c
index 1456fee..fa16cfe 100644
--- a/cipher/stribog.c
+++ b/cipher/stribog.c
@@ -1242,12 +1242,12 @@ transform_bits (STRIBOG_CONTEXT *hd, const unsigned char *data, unsigned count)
         }
     }
 
-  hd->Sigma[0] += M[0];
-  for (i = 1; i < 8; i++)
-    if (hd->Sigma[i-1] < M[i-1])
-      hd->Sigma[i] += M[i] + 1;
+  hd->Sigma[7] += M[7];
+  for (i = 7; i >= 1; i--)
+    if (hd->Sigma[i] < M[i])
+      hd->Sigma[i-1] += M[i-1] + 1;
     else
-      hd->Sigma[i] += M[i];
+      hd->Sigma[i-1] += M[i-1];
 }
 
 static unsigned int



More information about the Gcrypt-devel mailing list