]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Portability fixes for sha3-permute: long long constants, no zero shift to ROTL64.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 15 Nov 2012 16:20:24 +0000 (17:20 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 15 Nov 2012 16:20:24 +0000 (17:20 +0100)
ChangeLog
sha3-permute.c

index ca63f91b134f4b8245b37b691bcca8c9f31bfdec..df8063e975abdc1a2a0b9eafbe02efa6842b18fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-11-15  Niels Möller  <nisse@lysator.liu.se>
 
+       * sha3-permute.c (sha3_permute): Use ULL suffix on round
+       constants. Avoid passing shift count 0 to ROTL64.
+
        * sha3.c (sha3_absorb): Fixed big-endian code. Need macros.h.
 
        * macros.h (LE_READ_UINT64): New macro.
index e3714a2e3c7bc39d3fa4a8d5499d5b76efdcb2d5..5c291c6b93e3a7d2fa7e3e906e83d2edc01bb91e 100644 (file)
@@ -57,18 +57,18 @@ sha3_permute (struct sha3_state *state)
     };
 
   static const uint64_t rc[SHA3_ROUNDS] = {
-    0x0000000000000001, 0x0000000000008082,
-    0x800000000000808A, 0x8000000080008000,
-    0x000000000000808B, 0x0000000080000001,
-    0x8000000080008081, 0x8000000000008009,
-    0x000000000000008A, 0x0000000000000088,
-    0x0000000080008009, 0x000000008000000A,
-    0x000000008000808B, 0x800000000000008B,
-    0x8000000000008089, 0x8000000000008003,
-    0x8000000000008002, 0x8000000000000080,
-    0x000000000000800A, 0x800000008000000A,
-    0x8000000080008081, 0x8000000000008080,
-    0x0000000080000001, 0x8000000080008008,
+    0x0000000000000001ULL, 0X0000000000008082ULL,
+    0X800000000000808AULL, 0X8000000080008000ULL,
+    0X000000000000808BULL, 0X0000000080000001ULL,
+    0X8000000080008081ULL, 0X8000000000008009ULL,
+    0X000000000000008AULL, 0X0000000000000088ULL,
+    0X0000000080008009ULL, 0X000000008000000AULL,
+    0X000000008000808BULL, 0X800000000000008BULL,
+    0X8000000000008089ULL, 0X8000000000008003ULL,
+    0X8000000000008002ULL, 0X8000000000000080ULL,
+    0X000000000000800AULL, 0X800000008000000AULL,
+    0X8000000080008081ULL, 0X8000000000008080ULL,
+    0X0000000080000001ULL, 0X8000000080008008ULL,
   };
   unsigned i;
 
@@ -97,7 +97,8 @@ sha3_permute (struct sha3_state *state)
          A[y + x] ^= D[x];
 
       /* rho and pi steps */
-      for (x = 0; x < 25; x++)
+      B[0] = A[0]; /* NOTE: ROTL64 doesn't work with shift count 0 */
+      for (x = 1; x < 25; x++)
        B[perm[x]] = ROTL64 (rot[x], A[x]);
 
       /* chi step */