2 * Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow (danshu@microsoft.com)
3 * Distributed under the MIT Software License.
4 * See accompanying file LICENSE.txt or copy at
5 * https://opensource.org/licenses/MIT
9 #include "sha1dc/sha1.h"
10 #include "sha1dc/ubc_check.h"
14 Because Little-Endian architectures are most common,
15 we only set SHA1DC_BIGENDIAN if one of these conditions is met.
16 Note that all MSFT platforms are little endian,
17 so none of these will be defined under the MSC compiler.
18 If you are compiling on a big endian platform and your compiler does not define one of these,
19 you will have to add whatever macros your tool chain defines to indicate Big-Endianness.
21 #if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
22 (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \
23 defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
24 defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
26 #define SHA1DC_BIGENDIAN 1
28 #undef SHA1DC_BIGENDIAN
29 #endif /*ENDIANNESS SELECTION*/
31 #define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
32 #define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))
34 #define sha1_bswap32(x) \
35 {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
37 #define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
39 #if defined(SHA1DC_BIGENDIAN)
40 #define sha1_load(m, t, temp) { temp = m[t]; }
42 #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
43 #endif /* !defined(SHA1DC_BIGENDIAN) */
45 #define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
47 #define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
48 #define sha1_f2(b,c,d) ((b)^(c)^(d))
49 #define sha1_f3(b,c,d) (((b)&(c))+((d)&((b)^(c))))
50 #define sha1_f4(b,c,d) ((b)^(c)^(d))
52 #define HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, m, t) \
53 { e += rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; b = rotate_left(b, 30); }
54 #define HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, m, t) \
55 { e += rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; b = rotate_left(b, 30); }
56 #define HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, m, t) \
57 { e += rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; b = rotate_left(b, 30); }
58 #define HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, m, t) \
59 { e += rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; b = rotate_left(b, 30); }
61 #define HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, m, t) \
62 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; }
63 #define HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, m, t) \
64 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; }
65 #define HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, m, t) \
66 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; }
67 #define HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, m, t) \
68 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; }
70 #define SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, t, temp) \
71 {sha1_load(m, t, temp); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999; b = rotate_left(b, 30);}
73 #define SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(a, b, c, d, e, W, t, temp) \
74 {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999; b = rotate_left(b, 30); }
76 #define SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, t, temp) \
77 {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1; b = rotate_left(b, 30); }
79 #define SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, t, temp) \
80 {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC; b = rotate_left(b, 30); }
82 #define SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, t, temp) \
83 {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6; b = rotate_left(b, 30); }
86 #define SHA1_STORE_STATE(i) states[i][0] = a; states[i][1] = b; states[i][2] = c; states[i][3] = d; states[i][4] = e;
88 #ifdef BUILDNOCOLLDETECTSHA1COMPRESSION
89 void sha1_compression(uint32_t ihv
[5], const uint32_t m
[16])
96 for (i
= 16; i
< 80; ++i
)
97 W
[i
] = sha1_mix(W
, i
);
99 a
= ihv
[0]; b
= ihv
[1]; c
= ihv
[2]; d
= ihv
[3]; e
= ihv
[4];
101 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 0);
102 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 1);
103 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 2);
104 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 3);
105 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 4);
106 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 5);
107 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 6);
108 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 7);
109 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 8);
110 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 9);
111 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 10);
112 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 11);
113 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 12);
114 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 13);
115 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 14);
116 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 15);
117 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 16);
118 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 17);
119 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 18);
120 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 19);
122 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 20);
123 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 21);
124 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 22);
125 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 23);
126 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 24);
127 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 25);
128 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 26);
129 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 27);
130 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 28);
131 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 29);
132 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 30);
133 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 31);
134 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 32);
135 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 33);
136 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 34);
137 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 35);
138 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 36);
139 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 37);
140 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 38);
141 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 39);
143 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 40);
144 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 41);
145 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 42);
146 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 43);
147 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 44);
148 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 45);
149 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 46);
150 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 47);
151 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 48);
152 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 49);
153 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 50);
154 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 51);
155 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 52);
156 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 53);
157 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 54);
158 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 55);
159 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 56);
160 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 57);
161 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 58);
162 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 59);
164 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 60);
165 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 61);
166 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 62);
167 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 63);
168 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 64);
169 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 65);
170 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 66);
171 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 67);
172 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 68);
173 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 69);
174 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 70);
175 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 71);
176 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 72);
177 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 73);
178 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 74);
179 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 75);
180 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 76);
181 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 77);
182 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 78);
183 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 79);
185 ihv
[0] += a
; ihv
[1] += b
; ihv
[2] += c
; ihv
[3] += d
; ihv
[4] += e
;
187 #endif /*BUILDNOCOLLDETECTSHA1COMPRESSION*/
190 static void sha1_compression_W(uint32_t ihv
[5], const uint32_t W
[80])
192 uint32_t a
= ihv
[0], b
= ihv
[1], c
= ihv
[2], d
= ihv
[3], e
= ihv
[4];
194 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 0);
195 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 1);
196 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 2);
197 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 3);
198 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 4);
199 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 5);
200 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 6);
201 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 7);
202 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 8);
203 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 9);
204 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 10);
205 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 11);
206 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 12);
207 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 13);
208 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 14);
209 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a
, b
, c
, d
, e
, W
, 15);
210 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e
, a
, b
, c
, d
, W
, 16);
211 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d
, e
, a
, b
, c
, W
, 17);
212 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c
, d
, e
, a
, b
, W
, 18);
213 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b
, c
, d
, e
, a
, W
, 19);
215 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 20);
216 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 21);
217 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 22);
218 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 23);
219 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 24);
220 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 25);
221 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 26);
222 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 27);
223 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 28);
224 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 29);
225 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 30);
226 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 31);
227 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 32);
228 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 33);
229 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 34);
230 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 35);
231 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 36);
232 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 37);
233 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 38);
234 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 39);
236 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 40);
237 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 41);
238 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 42);
239 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 43);
240 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 44);
241 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 45);
242 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 46);
243 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 47);
244 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 48);
245 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 49);
246 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 50);
247 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 51);
248 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 52);
249 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 53);
250 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 54);
251 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 55);
252 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 56);
253 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 57);
254 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 58);
255 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 59);
257 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 60);
258 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 61);
259 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 62);
260 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 63);
261 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 64);
262 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 65);
263 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 66);
264 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 67);
265 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 68);
266 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 69);
267 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 70);
268 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 71);
269 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 72);
270 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 73);
271 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 74);
272 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 75);
273 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 76);
274 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 77);
275 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 78);
276 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 79);
278 ihv
[0] += a
; ihv
[1] += b
; ihv
[2] += c
; ihv
[3] += d
; ihv
[4] += e
;
283 void sha1_compression_states(uint32_t ihv
[5], const uint32_t m
[16], uint32_t W
[80], uint32_t states
[80][5])
285 uint32_t a
= ihv
[0], b
= ihv
[1], c
= ihv
[2], d
= ihv
[3], e
= ihv
[4];
288 #ifdef DOSTORESTATE00
291 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a
, b
, c
, d
, e
, m
, W
, 0, temp
);
293 #ifdef DOSTORESTATE01
296 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e
, a
, b
, c
, d
, m
, W
, 1, temp
);
298 #ifdef DOSTORESTATE02
301 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d
, e
, a
, b
, c
, m
, W
, 2, temp
);
303 #ifdef DOSTORESTATE03
306 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c
, d
, e
, a
, b
, m
, W
, 3, temp
);
308 #ifdef DOSTORESTATE04
311 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b
, c
, d
, e
, a
, m
, W
, 4, temp
);
313 #ifdef DOSTORESTATE05
316 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a
, b
, c
, d
, e
, m
, W
, 5, temp
);
318 #ifdef DOSTORESTATE06
321 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e
, a
, b
, c
, d
, m
, W
, 6, temp
);
323 #ifdef DOSTORESTATE07
326 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d
, e
, a
, b
, c
, m
, W
, 7, temp
);
328 #ifdef DOSTORESTATE08
331 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c
, d
, e
, a
, b
, m
, W
, 8, temp
);
333 #ifdef DOSTORESTATE09
336 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b
, c
, d
, e
, a
, m
, W
, 9, temp
);
338 #ifdef DOSTORESTATE10
341 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a
, b
, c
, d
, e
, m
, W
, 10, temp
);
343 #ifdef DOSTORESTATE11
346 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e
, a
, b
, c
, d
, m
, W
, 11, temp
);
348 #ifdef DOSTORESTATE12
351 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d
, e
, a
, b
, c
, m
, W
, 12, temp
);
353 #ifdef DOSTORESTATE13
356 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c
, d
, e
, a
, b
, m
, W
, 13, temp
);
358 #ifdef DOSTORESTATE14
361 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b
, c
, d
, e
, a
, m
, W
, 14, temp
);
363 #ifdef DOSTORESTATE15
366 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a
, b
, c
, d
, e
, m
, W
, 15, temp
);
368 #ifdef DOSTORESTATE16
371 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(e
, a
, b
, c
, d
, W
, 16, temp
);
373 #ifdef DOSTORESTATE17
376 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(d
, e
, a
, b
, c
, W
, 17, temp
);
378 #ifdef DOSTORESTATE18
381 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(c
, d
, e
, a
, b
, W
, 18, temp
);
383 #ifdef DOSTORESTATE19
386 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(b
, c
, d
, e
, a
, W
, 19, temp
);
390 #ifdef DOSTORESTATE20
393 SHA1COMPRESS_FULL_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 20, temp
);
395 #ifdef DOSTORESTATE21
398 SHA1COMPRESS_FULL_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 21, temp
);
400 #ifdef DOSTORESTATE22
403 SHA1COMPRESS_FULL_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 22, temp
);
405 #ifdef DOSTORESTATE23
408 SHA1COMPRESS_FULL_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 23, temp
);
410 #ifdef DOSTORESTATE24
413 SHA1COMPRESS_FULL_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 24, temp
);
415 #ifdef DOSTORESTATE25
418 SHA1COMPRESS_FULL_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 25, temp
);
420 #ifdef DOSTORESTATE26
423 SHA1COMPRESS_FULL_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 26, temp
);
425 #ifdef DOSTORESTATE27
428 SHA1COMPRESS_FULL_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 27, temp
);
430 #ifdef DOSTORESTATE28
433 SHA1COMPRESS_FULL_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 28, temp
);
435 #ifdef DOSTORESTATE29
438 SHA1COMPRESS_FULL_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 29, temp
);
440 #ifdef DOSTORESTATE30
443 SHA1COMPRESS_FULL_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 30, temp
);
445 #ifdef DOSTORESTATE31
448 SHA1COMPRESS_FULL_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 31, temp
);
450 #ifdef DOSTORESTATE32
453 SHA1COMPRESS_FULL_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 32, temp
);
455 #ifdef DOSTORESTATE33
458 SHA1COMPRESS_FULL_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 33, temp
);
460 #ifdef DOSTORESTATE34
463 SHA1COMPRESS_FULL_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 34, temp
);
465 #ifdef DOSTORESTATE35
468 SHA1COMPRESS_FULL_ROUND2_STEP(a
, b
, c
, d
, e
, W
, 35, temp
);
470 #ifdef DOSTORESTATE36
473 SHA1COMPRESS_FULL_ROUND2_STEP(e
, a
, b
, c
, d
, W
, 36, temp
);
475 #ifdef DOSTORESTATE37
478 SHA1COMPRESS_FULL_ROUND2_STEP(d
, e
, a
, b
, c
, W
, 37, temp
);
480 #ifdef DOSTORESTATE38
483 SHA1COMPRESS_FULL_ROUND2_STEP(c
, d
, e
, a
, b
, W
, 38, temp
);
485 #ifdef DOSTORESTATE39
488 SHA1COMPRESS_FULL_ROUND2_STEP(b
, c
, d
, e
, a
, W
, 39, temp
);
492 #ifdef DOSTORESTATE40
495 SHA1COMPRESS_FULL_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 40, temp
);
497 #ifdef DOSTORESTATE41
500 SHA1COMPRESS_FULL_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 41, temp
);
502 #ifdef DOSTORESTATE42
505 SHA1COMPRESS_FULL_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 42, temp
);
507 #ifdef DOSTORESTATE43
510 SHA1COMPRESS_FULL_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 43, temp
);
512 #ifdef DOSTORESTATE44
515 SHA1COMPRESS_FULL_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 44, temp
);
517 #ifdef DOSTORESTATE45
520 SHA1COMPRESS_FULL_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 45, temp
);
522 #ifdef DOSTORESTATE46
525 SHA1COMPRESS_FULL_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 46, temp
);
527 #ifdef DOSTORESTATE47
530 SHA1COMPRESS_FULL_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 47, temp
);
532 #ifdef DOSTORESTATE48
535 SHA1COMPRESS_FULL_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 48, temp
);
537 #ifdef DOSTORESTATE49
540 SHA1COMPRESS_FULL_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 49, temp
);
542 #ifdef DOSTORESTATE50
545 SHA1COMPRESS_FULL_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 50, temp
);
547 #ifdef DOSTORESTATE51
550 SHA1COMPRESS_FULL_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 51, temp
);
552 #ifdef DOSTORESTATE52
555 SHA1COMPRESS_FULL_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 52, temp
);
557 #ifdef DOSTORESTATE53
560 SHA1COMPRESS_FULL_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 53, temp
);
562 #ifdef DOSTORESTATE54
565 SHA1COMPRESS_FULL_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 54, temp
);
567 #ifdef DOSTORESTATE55
570 SHA1COMPRESS_FULL_ROUND3_STEP(a
, b
, c
, d
, e
, W
, 55, temp
);
572 #ifdef DOSTORESTATE56
575 SHA1COMPRESS_FULL_ROUND3_STEP(e
, a
, b
, c
, d
, W
, 56, temp
);
577 #ifdef DOSTORESTATE57
580 SHA1COMPRESS_FULL_ROUND3_STEP(d
, e
, a
, b
, c
, W
, 57, temp
);
582 #ifdef DOSTORESTATE58
585 SHA1COMPRESS_FULL_ROUND3_STEP(c
, d
, e
, a
, b
, W
, 58, temp
);
587 #ifdef DOSTORESTATE59
590 SHA1COMPRESS_FULL_ROUND3_STEP(b
, c
, d
, e
, a
, W
, 59, temp
);
595 #ifdef DOSTORESTATE60
598 SHA1COMPRESS_FULL_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 60, temp
);
600 #ifdef DOSTORESTATE61
603 SHA1COMPRESS_FULL_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 61, temp
);
605 #ifdef DOSTORESTATE62
608 SHA1COMPRESS_FULL_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 62, temp
);
610 #ifdef DOSTORESTATE63
613 SHA1COMPRESS_FULL_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 63, temp
);
615 #ifdef DOSTORESTATE64
618 SHA1COMPRESS_FULL_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 64, temp
);
620 #ifdef DOSTORESTATE65
623 SHA1COMPRESS_FULL_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 65, temp
);
625 #ifdef DOSTORESTATE66
628 SHA1COMPRESS_FULL_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 66, temp
);
630 #ifdef DOSTORESTATE67
633 SHA1COMPRESS_FULL_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 67, temp
);
635 #ifdef DOSTORESTATE68
638 SHA1COMPRESS_FULL_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 68, temp
);
640 #ifdef DOSTORESTATE69
643 SHA1COMPRESS_FULL_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 69, temp
);
645 #ifdef DOSTORESTATE70
648 SHA1COMPRESS_FULL_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 70, temp
);
650 #ifdef DOSTORESTATE71
653 SHA1COMPRESS_FULL_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 71, temp
);
655 #ifdef DOSTORESTATE72
658 SHA1COMPRESS_FULL_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 72, temp
);
660 #ifdef DOSTORESTATE73
663 SHA1COMPRESS_FULL_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 73, temp
);
665 #ifdef DOSTORESTATE74
668 SHA1COMPRESS_FULL_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 74, temp
);
670 #ifdef DOSTORESTATE75
673 SHA1COMPRESS_FULL_ROUND4_STEP(a
, b
, c
, d
, e
, W
, 75, temp
);
675 #ifdef DOSTORESTATE76
678 SHA1COMPRESS_FULL_ROUND4_STEP(e
, a
, b
, c
, d
, W
, 76, temp
);
680 #ifdef DOSTORESTATE77
683 SHA1COMPRESS_FULL_ROUND4_STEP(d
, e
, a
, b
, c
, W
, 77, temp
);
685 #ifdef DOSTORESTATE78
688 SHA1COMPRESS_FULL_ROUND4_STEP(c
, d
, e
, a
, b
, W
, 78, temp
);
690 #ifdef DOSTORESTATE79
693 SHA1COMPRESS_FULL_ROUND4_STEP(b
, c
, d
, e
, a
, W
, 79, temp
);
697 ihv
[0] += a
; ihv
[1] += b
; ihv
[2] += c
; ihv
[3] += d
; ihv
[4] += e
;
703 #define SHA1_RECOMPRESS(t) \
704 static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) \
706 uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; \
707 if (t > 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 79); \
708 if (t > 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 78); \
709 if (t > 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 77); \
710 if (t > 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 76); \
711 if (t > 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 75); \
712 if (t > 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 74); \
713 if (t > 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 73); \
714 if (t > 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 72); \
715 if (t > 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 71); \
716 if (t > 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 70); \
717 if (t > 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 69); \
718 if (t > 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 68); \
719 if (t > 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 67); \
720 if (t > 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 66); \
721 if (t > 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 65); \
722 if (t > 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 64); \
723 if (t > 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 63); \
724 if (t > 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 62); \
725 if (t > 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 61); \
726 if (t > 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 60); \
727 if (t > 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 59); \
728 if (t > 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 58); \
729 if (t > 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 57); \
730 if (t > 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 56); \
731 if (t > 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 55); \
732 if (t > 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 54); \
733 if (t > 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 53); \
734 if (t > 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 52); \
735 if (t > 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 51); \
736 if (t > 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 50); \
737 if (t > 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 49); \
738 if (t > 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 48); \
739 if (t > 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 47); \
740 if (t > 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 46); \
741 if (t > 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 45); \
742 if (t > 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 44); \
743 if (t > 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 43); \
744 if (t > 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 42); \
745 if (t > 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 41); \
746 if (t > 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 40); \
747 if (t > 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 39); \
748 if (t > 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 38); \
749 if (t > 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 37); \
750 if (t > 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 36); \
751 if (t > 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 35); \
752 if (t > 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 34); \
753 if (t > 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 33); \
754 if (t > 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 32); \
755 if (t > 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 31); \
756 if (t > 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 30); \
757 if (t > 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 29); \
758 if (t > 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 28); \
759 if (t > 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 27); \
760 if (t > 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 26); \
761 if (t > 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 25); \
762 if (t > 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 24); \
763 if (t > 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 23); \
764 if (t > 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 22); \
765 if (t > 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 21); \
766 if (t > 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 20); \
767 if (t > 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 19); \
768 if (t > 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 18); \
769 if (t > 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 17); \
770 if (t > 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 16); \
771 if (t > 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 15); \
772 if (t > 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 14); \
773 if (t > 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 13); \
774 if (t > 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 12); \
775 if (t > 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 11); \
776 if (t > 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 10); \
777 if (t > 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 9); \
778 if (t > 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 8); \
779 if (t > 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 7); \
780 if (t > 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 6); \
781 if (t > 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 5); \
782 if (t > 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 4); \
783 if (t > 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 3); \
784 if (t > 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 2); \
785 if (t > 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 1); \
786 if (t > 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 0); \
787 ihvin[0] = a; ihvin[1] = b; ihvin[2] = c; ihvin[3] = d; ihvin[4] = e; \
788 a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; \
789 if (t <= 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 0); \
790 if (t <= 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 1); \
791 if (t <= 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 2); \
792 if (t <= 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 3); \
793 if (t <= 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 4); \
794 if (t <= 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 5); \
795 if (t <= 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 6); \
796 if (t <= 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 7); \
797 if (t <= 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 8); \
798 if (t <= 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 9); \
799 if (t <= 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 10); \
800 if (t <= 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 11); \
801 if (t <= 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 12); \
802 if (t <= 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 13); \
803 if (t <= 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 14); \
804 if (t <= 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 15); \
805 if (t <= 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 16); \
806 if (t <= 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 17); \
807 if (t <= 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 18); \
808 if (t <= 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 19); \
809 if (t <= 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 20); \
810 if (t <= 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 21); \
811 if (t <= 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 22); \
812 if (t <= 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 23); \
813 if (t <= 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 24); \
814 if (t <= 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 25); \
815 if (t <= 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 26); \
816 if (t <= 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 27); \
817 if (t <= 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 28); \
818 if (t <= 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 29); \
819 if (t <= 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 30); \
820 if (t <= 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 31); \
821 if (t <= 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 32); \
822 if (t <= 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 33); \
823 if (t <= 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 34); \
824 if (t <= 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 35); \
825 if (t <= 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 36); \
826 if (t <= 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 37); \
827 if (t <= 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 38); \
828 if (t <= 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 39); \
829 if (t <= 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 40); \
830 if (t <= 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 41); \
831 if (t <= 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 42); \
832 if (t <= 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 43); \
833 if (t <= 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 44); \
834 if (t <= 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 45); \
835 if (t <= 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 46); \
836 if (t <= 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 47); \
837 if (t <= 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 48); \
838 if (t <= 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 49); \
839 if (t <= 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 50); \
840 if (t <= 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 51); \
841 if (t <= 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 52); \
842 if (t <= 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 53); \
843 if (t <= 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 54); \
844 if (t <= 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 55); \
845 if (t <= 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 56); \
846 if (t <= 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 57); \
847 if (t <= 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 58); \
848 if (t <= 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 59); \
849 if (t <= 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 60); \
850 if (t <= 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 61); \
851 if (t <= 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 62); \
852 if (t <= 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 63); \
853 if (t <= 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 64); \
854 if (t <= 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 65); \
855 if (t <= 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 66); \
856 if (t <= 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 67); \
857 if (t <= 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 68); \
858 if (t <= 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 69); \
859 if (t <= 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 70); \
860 if (t <= 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 71); \
861 if (t <= 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 72); \
862 if (t <= 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 73); \
863 if (t <= 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 74); \
864 if (t <= 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 75); \
865 if (t <= 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 76); \
866 if (t <= 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 77); \
867 if (t <= 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \
868 if (t <= 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \
869 ihvout[0] = ihvin[0] + a; ihvout[1] = ihvin[1] + b; ihvout[2] = ihvin[2] + c; ihvout[3] = ihvin[3] + d; ihvout[4] = ihvin[4] + e; \
912 #ifdef DOSTORESTATE10
916 #ifdef DOSTORESTATE11
920 #ifdef DOSTORESTATE12
924 #ifdef DOSTORESTATE13
928 #ifdef DOSTORESTATE14
932 #ifdef DOSTORESTATE15
936 #ifdef DOSTORESTATE16
940 #ifdef DOSTORESTATE17
944 #ifdef DOSTORESTATE18
948 #ifdef DOSTORESTATE19
952 #ifdef DOSTORESTATE20
956 #ifdef DOSTORESTATE21
960 #ifdef DOSTORESTATE22
964 #ifdef DOSTORESTATE23
968 #ifdef DOSTORESTATE24
972 #ifdef DOSTORESTATE25
976 #ifdef DOSTORESTATE26
980 #ifdef DOSTORESTATE27
984 #ifdef DOSTORESTATE28
988 #ifdef DOSTORESTATE29
992 #ifdef DOSTORESTATE30
996 #ifdef DOSTORESTATE31
1000 #ifdef DOSTORESTATE32
1004 #ifdef DOSTORESTATE33
1008 #ifdef DOSTORESTATE34
1012 #ifdef DOSTORESTATE35
1016 #ifdef DOSTORESTATE36
1020 #ifdef DOSTORESTATE37
1024 #ifdef DOSTORESTATE38
1028 #ifdef DOSTORESTATE39
1032 #ifdef DOSTORESTATE40
1036 #ifdef DOSTORESTATE41
1040 #ifdef DOSTORESTATE42
1044 #ifdef DOSTORESTATE43
1048 #ifdef DOSTORESTATE44
1052 #ifdef DOSTORESTATE45
1056 #ifdef DOSTORESTATE46
1060 #ifdef DOSTORESTATE47
1064 #ifdef DOSTORESTATE48
1068 #ifdef DOSTORESTATE49
1072 #ifdef DOSTORESTATE50
1076 #ifdef DOSTORESTATE51
1080 #ifdef DOSTORESTATE52
1084 #ifdef DOSTORESTATE53
1088 #ifdef DOSTORESTATE54
1092 #ifdef DOSTORESTATE55
1096 #ifdef DOSTORESTATE56
1100 #ifdef DOSTORESTATE57
1104 #ifdef DOSTORESTATE58
1108 #ifdef DOSTORESTATE59
1112 #ifdef DOSTORESTATE60
1116 #ifdef DOSTORESTATE61
1120 #ifdef DOSTORESTATE62
1124 #ifdef DOSTORESTATE63
1128 #ifdef DOSTORESTATE64
1132 #ifdef DOSTORESTATE65
1136 #ifdef DOSTORESTATE66
1140 #ifdef DOSTORESTATE67
1144 #ifdef DOSTORESTATE68
1148 #ifdef DOSTORESTATE69
1152 #ifdef DOSTORESTATE70
1156 #ifdef DOSTORESTATE71
1160 #ifdef DOSTORESTATE72
1164 #ifdef DOSTORESTATE73
1168 #ifdef DOSTORESTATE74
1172 #ifdef DOSTORESTATE75
1176 #ifdef DOSTORESTATE76
1180 #ifdef DOSTORESTATE77
1184 #ifdef DOSTORESTATE78
1188 #ifdef DOSTORESTATE79
1192 static void sha1_recompression_step(uint32_t step
, uint32_t ihvin
[5], uint32_t ihvout
[5], const uint32_t me2
[80], const uint32_t state
[5])
1196 #ifdef DOSTORESTATE0
1198 sha1recompress_fast_0(ihvin
, ihvout
, me2
, state
);
1201 #ifdef DOSTORESTATE1
1203 sha1recompress_fast_1(ihvin
, ihvout
, me2
, state
);
1206 #ifdef DOSTORESTATE2
1208 sha1recompress_fast_2(ihvin
, ihvout
, me2
, state
);
1211 #ifdef DOSTORESTATE3
1213 sha1recompress_fast_3(ihvin
, ihvout
, me2
, state
);
1216 #ifdef DOSTORESTATE4
1218 sha1recompress_fast_4(ihvin
, ihvout
, me2
, state
);
1221 #ifdef DOSTORESTATE5
1223 sha1recompress_fast_5(ihvin
, ihvout
, me2
, state
);
1226 #ifdef DOSTORESTATE6
1228 sha1recompress_fast_6(ihvin
, ihvout
, me2
, state
);
1231 #ifdef DOSTORESTATE7
1233 sha1recompress_fast_7(ihvin
, ihvout
, me2
, state
);
1236 #ifdef DOSTORESTATE8
1238 sha1recompress_fast_8(ihvin
, ihvout
, me2
, state
);
1241 #ifdef DOSTORESTATE9
1243 sha1recompress_fast_9(ihvin
, ihvout
, me2
, state
);
1246 #ifdef DOSTORESTATE10
1248 sha1recompress_fast_10(ihvin
, ihvout
, me2
, state
);
1251 #ifdef DOSTORESTATE11
1253 sha1recompress_fast_11(ihvin
, ihvout
, me2
, state
);
1256 #ifdef DOSTORESTATE12
1258 sha1recompress_fast_12(ihvin
, ihvout
, me2
, state
);
1261 #ifdef DOSTORESTATE13
1263 sha1recompress_fast_13(ihvin
, ihvout
, me2
, state
);
1266 #ifdef DOSTORESTATE14
1268 sha1recompress_fast_14(ihvin
, ihvout
, me2
, state
);
1271 #ifdef DOSTORESTATE15
1273 sha1recompress_fast_15(ihvin
, ihvout
, me2
, state
);
1276 #ifdef DOSTORESTATE16
1278 sha1recompress_fast_16(ihvin
, ihvout
, me2
, state
);
1281 #ifdef DOSTORESTATE17
1283 sha1recompress_fast_17(ihvin
, ihvout
, me2
, state
);
1286 #ifdef DOSTORESTATE18
1288 sha1recompress_fast_18(ihvin
, ihvout
, me2
, state
);
1291 #ifdef DOSTORESTATE19
1293 sha1recompress_fast_19(ihvin
, ihvout
, me2
, state
);
1296 #ifdef DOSTORESTATE20
1298 sha1recompress_fast_20(ihvin
, ihvout
, me2
, state
);
1301 #ifdef DOSTORESTATE21
1303 sha1recompress_fast_21(ihvin
, ihvout
, me2
, state
);
1306 #ifdef DOSTORESTATE22
1308 sha1recompress_fast_22(ihvin
, ihvout
, me2
, state
);
1311 #ifdef DOSTORESTATE23
1313 sha1recompress_fast_23(ihvin
, ihvout
, me2
, state
);
1316 #ifdef DOSTORESTATE24
1318 sha1recompress_fast_24(ihvin
, ihvout
, me2
, state
);
1321 #ifdef DOSTORESTATE25
1323 sha1recompress_fast_25(ihvin
, ihvout
, me2
, state
);
1326 #ifdef DOSTORESTATE26
1328 sha1recompress_fast_26(ihvin
, ihvout
, me2
, state
);
1331 #ifdef DOSTORESTATE27
1333 sha1recompress_fast_27(ihvin
, ihvout
, me2
, state
);
1336 #ifdef DOSTORESTATE28
1338 sha1recompress_fast_28(ihvin
, ihvout
, me2
, state
);
1341 #ifdef DOSTORESTATE29
1343 sha1recompress_fast_29(ihvin
, ihvout
, me2
, state
);
1346 #ifdef DOSTORESTATE30
1348 sha1recompress_fast_30(ihvin
, ihvout
, me2
, state
);
1351 #ifdef DOSTORESTATE31
1353 sha1recompress_fast_31(ihvin
, ihvout
, me2
, state
);
1356 #ifdef DOSTORESTATE32
1358 sha1recompress_fast_32(ihvin
, ihvout
, me2
, state
);
1361 #ifdef DOSTORESTATE33
1363 sha1recompress_fast_33(ihvin
, ihvout
, me2
, state
);
1366 #ifdef DOSTORESTATE34
1368 sha1recompress_fast_34(ihvin
, ihvout
, me2
, state
);
1371 #ifdef DOSTORESTATE35
1373 sha1recompress_fast_35(ihvin
, ihvout
, me2
, state
);
1376 #ifdef DOSTORESTATE36
1378 sha1recompress_fast_36(ihvin
, ihvout
, me2
, state
);
1381 #ifdef DOSTORESTATE37
1383 sha1recompress_fast_37(ihvin
, ihvout
, me2
, state
);
1386 #ifdef DOSTORESTATE38
1388 sha1recompress_fast_38(ihvin
, ihvout
, me2
, state
);
1391 #ifdef DOSTORESTATE39
1393 sha1recompress_fast_39(ihvin
, ihvout
, me2
, state
);
1396 #ifdef DOSTORESTATE40
1398 sha1recompress_fast_40(ihvin
, ihvout
, me2
, state
);
1401 #ifdef DOSTORESTATE41
1403 sha1recompress_fast_41(ihvin
, ihvout
, me2
, state
);
1406 #ifdef DOSTORESTATE42
1408 sha1recompress_fast_42(ihvin
, ihvout
, me2
, state
);
1411 #ifdef DOSTORESTATE43
1413 sha1recompress_fast_43(ihvin
, ihvout
, me2
, state
);
1416 #ifdef DOSTORESTATE44
1418 sha1recompress_fast_44(ihvin
, ihvout
, me2
, state
);
1421 #ifdef DOSTORESTATE45
1423 sha1recompress_fast_45(ihvin
, ihvout
, me2
, state
);
1426 #ifdef DOSTORESTATE46
1428 sha1recompress_fast_46(ihvin
, ihvout
, me2
, state
);
1431 #ifdef DOSTORESTATE47
1433 sha1recompress_fast_47(ihvin
, ihvout
, me2
, state
);
1436 #ifdef DOSTORESTATE48
1438 sha1recompress_fast_48(ihvin
, ihvout
, me2
, state
);
1441 #ifdef DOSTORESTATE49
1443 sha1recompress_fast_49(ihvin
, ihvout
, me2
, state
);
1446 #ifdef DOSTORESTATE50
1448 sha1recompress_fast_50(ihvin
, ihvout
, me2
, state
);
1451 #ifdef DOSTORESTATE51
1453 sha1recompress_fast_51(ihvin
, ihvout
, me2
, state
);
1456 #ifdef DOSTORESTATE52
1458 sha1recompress_fast_52(ihvin
, ihvout
, me2
, state
);
1461 #ifdef DOSTORESTATE53
1463 sha1recompress_fast_53(ihvin
, ihvout
, me2
, state
);
1466 #ifdef DOSTORESTATE54
1468 sha1recompress_fast_54(ihvin
, ihvout
, me2
, state
);
1471 #ifdef DOSTORESTATE55
1473 sha1recompress_fast_55(ihvin
, ihvout
, me2
, state
);
1476 #ifdef DOSTORESTATE56
1478 sha1recompress_fast_56(ihvin
, ihvout
, me2
, state
);
1481 #ifdef DOSTORESTATE57
1483 sha1recompress_fast_57(ihvin
, ihvout
, me2
, state
);
1486 #ifdef DOSTORESTATE58
1488 sha1recompress_fast_58(ihvin
, ihvout
, me2
, state
);
1491 #ifdef DOSTORESTATE59
1493 sha1recompress_fast_59(ihvin
, ihvout
, me2
, state
);
1496 #ifdef DOSTORESTATE60
1498 sha1recompress_fast_60(ihvin
, ihvout
, me2
, state
);
1501 #ifdef DOSTORESTATE61
1503 sha1recompress_fast_61(ihvin
, ihvout
, me2
, state
);
1506 #ifdef DOSTORESTATE62
1508 sha1recompress_fast_62(ihvin
, ihvout
, me2
, state
);
1511 #ifdef DOSTORESTATE63
1513 sha1recompress_fast_63(ihvin
, ihvout
, me2
, state
);
1516 #ifdef DOSTORESTATE64
1518 sha1recompress_fast_64(ihvin
, ihvout
, me2
, state
);
1521 #ifdef DOSTORESTATE65
1523 sha1recompress_fast_65(ihvin
, ihvout
, me2
, state
);
1526 #ifdef DOSTORESTATE66
1528 sha1recompress_fast_66(ihvin
, ihvout
, me2
, state
);
1531 #ifdef DOSTORESTATE67
1533 sha1recompress_fast_67(ihvin
, ihvout
, me2
, state
);
1536 #ifdef DOSTORESTATE68
1538 sha1recompress_fast_68(ihvin
, ihvout
, me2
, state
);
1541 #ifdef DOSTORESTATE69
1543 sha1recompress_fast_69(ihvin
, ihvout
, me2
, state
);
1546 #ifdef DOSTORESTATE70
1548 sha1recompress_fast_70(ihvin
, ihvout
, me2
, state
);
1551 #ifdef DOSTORESTATE71
1553 sha1recompress_fast_71(ihvin
, ihvout
, me2
, state
);
1556 #ifdef DOSTORESTATE72
1558 sha1recompress_fast_72(ihvin
, ihvout
, me2
, state
);
1561 #ifdef DOSTORESTATE73
1563 sha1recompress_fast_73(ihvin
, ihvout
, me2
, state
);
1566 #ifdef DOSTORESTATE74
1568 sha1recompress_fast_74(ihvin
, ihvout
, me2
, state
);
1571 #ifdef DOSTORESTATE75
1573 sha1recompress_fast_75(ihvin
, ihvout
, me2
, state
);
1576 #ifdef DOSTORESTATE76
1578 sha1recompress_fast_76(ihvin
, ihvout
, me2
, state
);
1581 #ifdef DOSTORESTATE77
1583 sha1recompress_fast_77(ihvin
, ihvout
, me2
, state
);
1586 #ifdef DOSTORESTATE78
1588 sha1recompress_fast_78(ihvin
, ihvout
, me2
, state
);
1591 #ifdef DOSTORESTATE79
1593 sha1recompress_fast_79(ihvin
, ihvout
, me2
, state
);
1604 static void sha1_process(SHA1_CTX
* ctx
, const uint32_t block
[16])
1607 uint32_t ubc_dv_mask
[DVMASKSIZE
] = { 0xFFFFFFFF };
1610 ctx
->ihv1
[0] = ctx
->ihv
[0];
1611 ctx
->ihv1
[1] = ctx
->ihv
[1];
1612 ctx
->ihv1
[2] = ctx
->ihv
[2];
1613 ctx
->ihv1
[3] = ctx
->ihv
[3];
1614 ctx
->ihv1
[4] = ctx
->ihv
[4];
1616 sha1_compression_states(ctx
->ihv
, block
, ctx
->m1
, ctx
->states
);
1618 if (ctx
->detect_coll
)
1622 ubc_check(ctx
->m1
, ubc_dv_mask
);
1625 if (ubc_dv_mask
[0] != 0)
1627 for (i
= 0; sha1_dvs
[i
].dvType
!= 0; ++i
)
1629 if (ubc_dv_mask
[0] & ((uint32_t)(1) << sha1_dvs
[i
].maskb
))
1631 for (j
= 0; j
< 80; ++j
)
1632 ctx
->m2
[j
] = ctx
->m1
[j
] ^ sha1_dvs
[i
].dm
[j
];
1634 sha1_recompression_step(sha1_dvs
[i
].testt
, ctx
->ihv2
, ihvtmp
, ctx
->m2
, ctx
->states
[sha1_dvs
[i
].testt
]);
1636 /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */
1637 if ((0 == ((ihvtmp
[0] ^ ctx
->ihv
[0]) | (ihvtmp
[1] ^ ctx
->ihv
[1]) | (ihvtmp
[2] ^ ctx
->ihv
[2]) | (ihvtmp
[3] ^ ctx
->ihv
[3]) | (ihvtmp
[4] ^ ctx
->ihv
[4])))
1638 || (ctx
->reduced_round_coll
&& 0==((ctx
->ihv1
[0] ^ ctx
->ihv2
[0]) | (ctx
->ihv1
[1] ^ ctx
->ihv2
[1]) | (ctx
->ihv1
[2] ^ ctx
->ihv2
[2]) | (ctx
->ihv1
[3] ^ ctx
->ihv2
[3]) | (ctx
->ihv1
[4] ^ ctx
->ihv2
[4]))))
1640 ctx
->found_collision
= 1;
1644 sha1_compression_W(ctx
->ihv
, ctx
->m1
);
1645 sha1_compression_W(ctx
->ihv
, ctx
->m1
);
1656 void SHA1DCInit(SHA1_CTX
* ctx
)
1659 ctx
->ihv
[0] = 0x67452301;
1660 ctx
->ihv
[1] = 0xEFCDAB89;
1661 ctx
->ihv
[2] = 0x98BADCFE;
1662 ctx
->ihv
[3] = 0x10325476;
1663 ctx
->ihv
[4] = 0xC3D2E1F0;
1664 ctx
->found_collision
= 0;
1667 ctx
->detect_coll
= 1;
1668 ctx
->reduced_round_coll
= 0;
1669 ctx
->callback
= NULL
;
1672 void SHA1DCSetSafeHash(SHA1_CTX
* ctx
, int safehash
)
1681 void SHA1DCSetUseUBC(SHA1_CTX
* ctx
, int ubc_check
)
1689 void SHA1DCSetUseDetectColl(SHA1_CTX
* ctx
, int detect_coll
)
1692 ctx
->detect_coll
= 1;
1694 ctx
->detect_coll
= 0;
1697 void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX
* ctx
, int reduced_round_coll
)
1699 if (reduced_round_coll
)
1700 ctx
->reduced_round_coll
= 1;
1702 ctx
->reduced_round_coll
= 0;
1705 void SHA1DCSetCallback(SHA1_CTX
* ctx
, collision_block_callback callback
)
1707 ctx
->callback
= callback
;
1710 void SHA1DCUpdate(SHA1_CTX
* ctx
, const char* buf
, size_t len
)
1712 unsigned left
, fill
;
1716 left
= ctx
->total
& 63;
1719 if (left
&& len
>= fill
)
1722 memcpy(ctx
->buffer
+ left
, buf
, fill
);
1723 sha1_process(ctx
, (uint32_t*)(ctx
->buffer
));
1731 sha1_process(ctx
, (uint32_t*)(buf
));
1738 memcpy(ctx
->buffer
+ left
, buf
, len
);
1742 static const unsigned char sha1_padding
[64] =
1744 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1745 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1746 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1747 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1750 int SHA1DCFinal(unsigned char output
[20], SHA1_CTX
*ctx
)
1752 uint32_t last
= ctx
->total
& 63;
1753 uint32_t padn
= (last
< 56) ? (56 - last
) : (120 - last
);
1755 SHA1DCUpdate(ctx
, (const char*)(sha1_padding
), padn
);
1757 total
= ctx
->total
- padn
;
1759 ctx
->buffer
[56] = (unsigned char)(total
>> 56);
1760 ctx
->buffer
[57] = (unsigned char)(total
>> 48);
1761 ctx
->buffer
[58] = (unsigned char)(total
>> 40);
1762 ctx
->buffer
[59] = (unsigned char)(total
>> 32);
1763 ctx
->buffer
[60] = (unsigned char)(total
>> 24);
1764 ctx
->buffer
[61] = (unsigned char)(total
>> 16);
1765 ctx
->buffer
[62] = (unsigned char)(total
>> 8);
1766 ctx
->buffer
[63] = (unsigned char)(total
);
1767 sha1_process(ctx
, (uint32_t*)(ctx
->buffer
));
1768 output
[0] = (unsigned char)(ctx
->ihv
[0] >> 24);
1769 output
[1] = (unsigned char)(ctx
->ihv
[0] >> 16);
1770 output
[2] = (unsigned char)(ctx
->ihv
[0] >> 8);
1771 output
[3] = (unsigned char)(ctx
->ihv
[0]);
1772 output
[4] = (unsigned char)(ctx
->ihv
[1] >> 24);
1773 output
[5] = (unsigned char)(ctx
->ihv
[1] >> 16);
1774 output
[6] = (unsigned char)(ctx
->ihv
[1] >> 8);
1775 output
[7] = (unsigned char)(ctx
->ihv
[1]);
1776 output
[8] = (unsigned char)(ctx
->ihv
[2] >> 24);
1777 output
[9] = (unsigned char)(ctx
->ihv
[2] >> 16);
1778 output
[10] = (unsigned char)(ctx
->ihv
[2] >> 8);
1779 output
[11] = (unsigned char)(ctx
->ihv
[2]);
1780 output
[12] = (unsigned char)(ctx
->ihv
[3] >> 24);
1781 output
[13] = (unsigned char)(ctx
->ihv
[3] >> 16);
1782 output
[14] = (unsigned char)(ctx
->ihv
[3] >> 8);
1783 output
[15] = (unsigned char)(ctx
->ihv
[3]);
1784 output
[16] = (unsigned char)(ctx
->ihv
[4] >> 24);
1785 output
[17] = (unsigned char)(ctx
->ihv
[4] >> 16);
1786 output
[18] = (unsigned char)(ctx
->ihv
[4] >> 8);
1787 output
[19] = (unsigned char)(ctx
->ihv
[4]);
1788 return ctx
->found_collision
;
1791 void git_SHA1DCFinal(unsigned char hash
[20], SHA1_CTX
*ctx
)
1793 if (!SHA1DCFinal(hash
, ctx
))
1795 die("SHA-1 appears to be part of a collision attack: %s",
1799 void git_SHA1DCUpdate(SHA1_CTX
*ctx
, const void *vdata
, unsigned long len
)
1801 const char *data
= vdata
;
1802 /* We expect an unsigned long, but sha1dc only takes an int */
1803 while (len
> INT_MAX
) {
1804 SHA1DCUpdate(ctx
, data
, INT_MAX
);
1808 SHA1DCUpdate(ctx
, data
, len
);