Arbiter  0.0.0
macros.hpp
1 #pragma once
2 
3 #define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
4 #define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
5 
6 // SHA256.
7 #define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
8 #define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
9 #define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
10 #define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
11 #define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
12 #define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
13 
14 // MD5.
15 #define F(x,y,z) ((x & y) | (~x & z))
16 #define G(x,y,z) ((x & z) | (y & ~z))
17 #define H(x,y,z) (x ^ y ^ z)
18 #define I(x,y,z) (y ^ (x | ~z))
19 
20 #define FF(a,b,c,d,m,s,t) { a += F(b,c,d) + m + t; \
21  a = b + ROTLEFT(a,s); }
22 #define GG(a,b,c,d,m,s,t) { a += G(b,c,d) + m + t; \
23  a = b + ROTLEFT(a,s); }
24 #define HH(a,b,c,d,m,s,t) { a += H(b,c,d) + m + t; \
25  a = b + ROTLEFT(a,s); }
26 #define II(a,b,c,d,m,s,t) { a += I(b,c,d) + m + t; \
27  a = b + ROTLEFT(a,s); }
28