]> git.codecow.com Git - Monocypher.git/commitdiff
More readable Chacha20 quarter rounds
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 14 Feb 2018 19:37:25 +0000 (20:37 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 14 Feb 2018 19:38:15 +0000 (20:38 +0100)
src/monocypher.c

index 9a49137531d807080d1f54ec0004d2f2d0d55e51..222d7b8f0a89fdc5cdf918737cb3451453152af5 100644 (file)
@@ -101,11 +101,11 @@ void crypto_wipe(void *secret, size_t size)
 /////////////////
 /// Chacha 20 ///
 /////////////////
-#define QUARTERROUND(a, b, c, d)          \
-    a += b;  d ^= a;  d = rotl32(d, 16);  \
-    c += d;  b ^= c;  b = rotl32(b, 12);  \
-    a += b;  d ^= a;  d = rotl32(d,  8);  \
-    c += d;  b ^= c;  b = rotl32(b,  7)
+#define QUARTERROUND(a, b, c, d)     \
+    a += b;  d = rotl32(d ^ a, 16);  \
+    c += d;  b = rotl32(b ^ c, 12);  \
+    a += b;  d = rotl32(d ^ a,  8);  \
+    c += d;  b = rotl32(b ^ c,  7)
 
 static void chacha20_rounds(u32 out[16], const u32 in[16])
 {