Commits

David Lazar committed bb08929

Reformat code: more consistent whitespace.

Comments (0)

Files changed (1)

blake512/blake512.c

 #include "blake512.h"
 
 #define U8TO32(p) \
-  (((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \
-   ((uint32_t)((p)[2]) <<  8) | ((uint32_t)((p)[3])      ))
+    (((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \
+     ((uint32_t)((p)[2]) <<  8) | ((uint32_t)((p)[3])      ))
 #define U8TO64(p) \
-  (((uint64_t)U8TO32(p) << 32) | (uint64_t)U8TO32((p) + 4))
+    (((uint64_t)U8TO32(p) << 32) | (uint64_t)U8TO32((p) + 4))
 #define U32TO8(p, v) \
     (p)[0] = (uint8_t)((v) >> 24); (p)[1] = (uint8_t)((v) >> 16); \
     (p)[2] = (uint8_t)((v) >>  8); (p)[3] = (uint8_t)((v)      );
     U32TO8((p) + 4, (uint32_t)((v)      ));
 
 const uint8_t sigma[][16] = {
-    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 },
-    {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3 },
-    {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4 },
-    { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8 },
-    { 9, 0, 5, 7, 2, 4,10,15,14, 1,11,12, 6, 8, 3,13 },
-    { 2,12, 6,10, 0,11, 8, 3, 4,13, 7, 5,15,14, 1, 9 },
-    {12, 5, 1,15,14,13, 4,10, 0, 7, 6, 3, 9, 2, 8,11 },
-    {13,11, 7,14,12, 1, 3, 9, 5, 0,15, 4, 8, 6, 2,10 },
-    { 6,15,14, 9,11, 3, 0, 8,12, 2,13, 7, 1, 4,10, 5 },
-    {10, 2, 8, 4, 7, 6, 1, 5,15,11, 9,14, 3,12,13 ,0 },
-    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15 },
-    {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3 },
-    {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4 },
-    { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8 },
-    { 9, 0, 5, 7, 2, 4,10,15,14, 1,11,12, 6, 8, 3,13 },
-    { 2,12, 6,10, 0,11, 8, 3, 4,13, 7, 5,15,14, 1, 9 }
+    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15},
+    {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3},
+    {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4},
+    { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8},
+    { 9, 0, 5, 7, 2, 4,10,15,14, 1,11,12, 6, 8, 3,13},
+    { 2,12, 6,10, 0,11, 8, 3, 4,13, 7, 5,15,14, 1, 9},
+    {12, 5, 1,15,14,13, 4,10, 0, 7, 6, 3, 9, 2, 8,11},
+    {13,11, 7,14,12, 1, 3, 9, 5, 0,15, 4, 8, 6, 2,10},
+    { 6,15,14, 9,11, 3, 0, 8,12, 2,13, 7, 1, 4,10, 5},
+    {10, 2, 8, 4, 7, 6, 1, 5,15,11, 9,14, 3,12,13, 0},
+    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15},
+    {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3},
+    {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4},
+    { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8},
+    { 9, 0, 5, 7, 2, 4,10,15,14, 1,11,12, 6, 8, 3,13},
+    { 2,12, 6,10, 0,11, 8, 3, 4,13, 7, 5,15,14, 1, 9}
 };
 
 const uint64_t cst[16] = {
-    0x243F6A8885A308D3ULL,0x13198A2E03707344ULL,0xA4093822299F31D0ULL,0x082EFA98EC4E6C89ULL,
-    0x452821E638D01377ULL,0xBE5466CF34E90C6CULL,0xC0AC29B7C97C50DDULL,0x3F84D5B5B5470917ULL,
-    0x9216D5D98979FB1BULL,0xD1310BA698DFB5ACULL,0x2FFD72DBD01ADFB7ULL,0xB8E1AFED6A267E96ULL,
-    0xBA7C9045F12C7F99ULL,0x24A19947B3916CF7ULL,0x0801F2E2858EFC16ULL,0x636920D871574E69ULL
+    0x243F6A8885A308D3ULL, 0x13198A2E03707344ULL, 0xA4093822299F31D0ULL, 0x082EFA98EC4E6C89ULL,
+    0x452821E638D01377ULL, 0xBE5466CF34E90C6CULL, 0xC0AC29B7C97C50DDULL, 0x3F84D5B5B5470917ULL,
+    0x9216D5D98979FB1BULL, 0xD1310BA698DFB5ACULL, 0x2FFD72DBD01ADFB7ULL, 0xB8E1AFED6A267E96ULL,
+    0xBA7C9045F12C7F99ULL, 0x24A19947B3916CF7ULL, 0x0801F2E2858EFC16ULL, 0x636920D871574E69ULL
 };
 
 static const uint8_t padding[129] = {
     }
 
     for (i = 0; i < 16; ++i) {
-        G( 0, 4, 8,12, 0);
-        G( 1, 5, 9,13, 2);
-        G( 2, 6,10,14, 4);
-        G( 3, 7,11,15, 6);
-        G( 3, 4, 9,14,14);
-        G( 2, 7, 8,13,12);
-        G( 0, 5,10,15, 8);
-        G( 1, 6,11,12,10);
+        G(0, 4,  8, 12,  0);
+        G(1, 5,  9, 13,  2);
+        G(2, 6, 10, 14,  4);
+        G(3, 7, 11, 15,  6);
+        G(3, 4,  9, 14, 14);
+        G(2, 7,  8, 13, 12);
+        G(0, 5, 10, 15,  8);
+        G(1, 6, 11, 12, 10);
     }
 
-    for(i = 0; i < 16; ++i)  S->h[i % 8] ^= v[i];
-    for(i = 0; i < 8;  ++i)  S->h[i] ^= S->s[i % 4];
+    for (i = 0; i < 16; ++i) S->h[i % 8] ^= v[i];
+    for (i = 0; i < 8;  ++i) S->h[i] ^= S->s[i % 4];
 }
 
 void blake512_init(state *S) {
         S->t[0] += 1024;
         blake512_compress(S, S->buf);
         data += fill;
-        datalen  -= (fill << 3);
+        datalen -= (fill << 3);
         left = 0;
     }
 
     while (datalen >= 1024) {
         S->t[0] += 1024;
-        blake512_compress( S, data );
+        blake512_compress(S, data);
         data += 128;
-        datalen  -= 1024;
+        datalen -= 1024;
     }
 
     if (datalen > 0) {
     S->t[0] -= 128;
     blake512_update(S, msglen, 128);
 
-    U64TO8(digest + 0, S->h[0]);
-    U64TO8(digest + 8, S->h[1]);
-    U64TO8(digest +16, S->h[2]);
-    U64TO8(digest +24, S->h[3]);
-    U64TO8(digest +32, S->h[4]);
-    U64TO8(digest +40, S->h[5]);
-    U64TO8(digest +48, S->h[6]);
-    U64TO8(digest +56, S->h[7]);
+    U64TO8(digest +  0, S->h[0]);
+    U64TO8(digest +  8, S->h[1]);
+    U64TO8(digest + 16, S->h[2]);
+    U64TO8(digest + 24, S->h[3]);
+    U64TO8(digest + 32, S->h[4]);
+    U64TO8(digest + 40, S->h[5]);
+    U64TO8(digest + 48, S->h[6]);
+    U64TO8(digest + 56, S->h[7]);
 }
 
 // inlen = number of bytes