]> git.codecow.com Git - Monocypher.git/commitdiff
used += increment in blake2b rounds
authorLoup Vaillant <loup@loup-vaillant.fr>
Fri, 30 Dec 2016 10:46:27 +0000 (11:46 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Fri, 30 Dec 2016 10:46:27 +0000 (11:46 +0100)
blake2b.c

index e693ad2dc7b2610c10c4bc4cc62c53b703d309b3..3c33f9e8d7d7c23a7efe3890997d122d5cfde291 100644 (file)
--- a/blake2b.c
+++ b/blake2b.c
@@ -3,14 +3,13 @@
 #include "blake2b.h"
 
 // Cyclic right rotation.
-
-uint64_t
+static uint64_t
 rotr64(uint64_t x, uint64_t y)
 {
     return (x >> y) ^ (x << (64 - y));
 }
 
-uint64_t
+static uint64_t
 load64_le(uint8_t *p)
 {
     return
@@ -66,11 +65,11 @@ blake2b_compress(crypto_blake2b_ctx *ctx, int last)
         m[i] = load64_le(&ctx->b[8 * i]);
     }
     for (i = 0; i < 12; i++) {          // twelve rounds
-#define B2B_G(a, b, c, d, x, y)                                         \
-        v[a] = v[a] + v[b] + x;   v[d] = rotr64(v[d] ^ v[a], 32);       \
-        v[c] = v[c] + v[d]    ;   v[b] = rotr64(v[b] ^ v[c], 24);       \
-        v[a] = v[a] + v[b] + y;   v[d] = rotr64(v[d] ^ v[a], 16);       \
-        v[c] = v[c] + v[d]    ;   v[b] = rotr64(v[b] ^ v[c], 63)
+#define B2B_G(a, b, c, d, x, y)                                   \
+        v[a] += v[b] + x;   v[d] = rotr64(v[d] ^ v[a], 32);       \
+        v[c] += v[d]    ;   v[b] = rotr64(v[b] ^ v[c], 24);       \
+        v[a] += v[b] + y;   v[d] = rotr64(v[d] ^ v[a], 16);       \
+        v[c] += v[d]    ;   v[b] = rotr64(v[b] ^ v[c], 63)
 
         B2B_G( 0, 4,  8, 12, m[sigma[i][ 0]], m[sigma[i][ 1]]);
         B2B_G( 1, 5,  9, 13, m[sigma[i][ 2]], m[sigma[i][ 3]]);