1 #ifndef blamka_round_ref_H
2 #define blamka_round_ref_H
3
4 #include "private/common.h"
5
6 /*designed by the Lyra PHC team */
7 static inline uint64_t
fBlaMka(uint64_t x,uint64_t y)8 fBlaMka(uint64_t x, uint64_t y)
9 {
10 const uint64_t m = UINT64_C(0xFFFFFFFF);
11 const uint64_t xy = (x & m) * (y & m);
12 return x + y + 2 * xy;
13 }
14
15 #define G(a, b, c, d) \
16 do { \
17 a = fBlaMka(a, b); \
18 d = ROTR64(d ^ a, 32); \
19 c = fBlaMka(c, d); \
20 b = ROTR64(b ^ c, 24); \
21 a = fBlaMka(a, b); \
22 d = ROTR64(d ^ a, 16); \
23 c = fBlaMka(c, d); \
24 b = ROTR64(b ^ c, 63); \
25 } while ((void) 0, 0)
26
27 #define BLAKE2_ROUND_NOMSG(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, \
28 v12, v13, v14, v15) \
29 do { \
30 G(v0, v4, v8, v12); \
31 G(v1, v5, v9, v13); \
32 G(v2, v6, v10, v14); \
33 G(v3, v7, v11, v15); \
34 G(v0, v5, v10, v15); \
35 G(v1, v6, v11, v12); \
36 G(v2, v7, v8, v13); \
37 G(v3, v4, v9, v14); \
38 } while ((void) 0, 0)
39
40 #endif
41