93
for (i = 0; i < 16; i++)
96
87
/* load the state into our registers */
97
88
a=state[0]; b=state[1]; c=state[2]; d=state[3];
98
89
e=state[4]; f=state[5]; g=state[6]; h=state[7];
100
#define SHA512_0_15(i, a, b, c, d, e, f, g, h) \
101
t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[i]; \
102
t2 = e0(a) + Maj(a, b, c); \
106
#define SHA512_16_79(i, a, b, c, d, e, f, g, h) \
108
t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \
109
t2 = e0(a) + Maj(a, b, c); \
113
for (i = 0; i < 16; i += 8) {
114
SHA512_0_15(i, a, b, c, d, e, f, g, h);
115
SHA512_0_15(i + 1, h, a, b, c, d, e, f, g);
116
SHA512_0_15(i + 2, g, h, a, b, c, d, e, f);
117
SHA512_0_15(i + 3, f, g, h, a, b, c, d, e);
118
SHA512_0_15(i + 4, e, f, g, h, a, b, c, d);
119
SHA512_0_15(i + 5, d, e, f, g, h, a, b, c);
120
SHA512_0_15(i + 6, c, d, e, f, g, h, a, b);
121
SHA512_0_15(i + 7, b, c, d, e, f, g, h, a);
123
for (i = 16; i < 80; i += 8) {
124
SHA512_16_79(i, a, b, c, d, e, f, g, h);
125
SHA512_16_79(i + 1, h, a, b, c, d, e, f, g);
126
SHA512_16_79(i + 2, g, h, a, b, c, d, e, f);
127
SHA512_16_79(i + 3, f, g, h, a, b, c, d, e);
128
SHA512_16_79(i + 4, e, f, g, h, a, b, c, d);
129
SHA512_16_79(i + 5, d, e, f, g, h, a, b, c);
130
SHA512_16_79(i + 6, c, d, e, f, g, h, a, b);
131
SHA512_16_79(i + 7, b, c, d, e, f, g, h, a);
92
for (i=0; i<80; i+=8) {
98
for (j = 0; j < 16; j++)
99
LOAD_OP(i + j, W, input);
101
for (j = 0; j < 16; j++) {
107
t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[(i & 15)];
108
t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
109
t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[(i & 15) + 1];
110
t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
111
t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[(i & 15) + 2];
112
t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
113
t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[(i & 15) + 3];
114
t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
115
t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[(i & 15) + 4];
116
t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
117
t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[(i & 15) + 5];
118
t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
119
t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[(i & 15) + 6];
120
t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
121
t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[(i & 15) + 7];
122
t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
134
125
state[0] += a; state[1] += b; state[2] += c; state[3] += d;