1/***
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
6***/
7
8#ifndef SHA1DC_NO_STANDARD_INCLUDES
9#include <string.h>
10#include <memory.h>
11#include <stdio.h>
12#include <stdlib.h>
13#endif
14
15#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C
16#include SHA1DC_CUSTOM_INCLUDE_SHA1_C
17#endif
18
19#ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT
20#define SHA1DC_INIT_SAFE_HASH_DEFAULT 1
21#endif
22
23#include "sha1.h"
24#include "ubc_check.h"
25
26
27/*
28 Because Little-Endian architectures are most common,
29 we only set SHA1DC_BIGENDIAN if one of these conditions is met.
30 Note that all MSFT platforms are little endian,
31 so none of these will be defined under the MSC compiler.
32 If you are compiling on a big endian platform and your compiler does not define one of these,
33 you will have to add whatever macros your tool chain defines to indicate Big-Endianness.
34 */
35#ifdef SHA1DC_BIGENDIAN
36#undef SHA1DC_BIGENDIAN
37#endif
38#if (!defined SHA1DC_FORCE_LITTLEENDIAN) && \
39 ((defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
40 (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \
41 defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
42 defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(SHA1DC_FORCE_BIGENDIAN))
43
44#define SHA1DC_BIGENDIAN
45
46#endif /*ENDIANNESS SELECTION*/
47
48#if (defined SHA1DC_FORCE_UNALIGNED_ACCESS || \
49 defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \
50 defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \
51 defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \
52 defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \
53 defined(__386) || defined(_M_X64) || defined(_M_AMD64))
54
55#define SHA1DC_ALLOW_UNALIGNED_ACCESS
56
57#endif /*UNALIGNMENT DETECTION*/
58
59
60#define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
61#define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))
62
63#define sha1_bswap32(x) \
64 {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
65
66#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
67
68#ifdef SHA1DC_BIGENDIAN
69 #define sha1_load(m, t, temp) { temp = m[t]; }
70#else
71 #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
72#endif
73
74#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
75
76#define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
77#define sha1_f2(b,c,d) ((b)^(c)^(d))
78#define sha1_f3(b,c,d) (((b)&(c))+((d)&((b)^(c))))
79#define sha1_f4(b,c,d) ((b)^(c)^(d))
80
81#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, m, t) \
82 { e += rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; b = rotate_left(b, 30); }
83#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, m, t) \
84 { e += rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; b = rotate_left(b, 30); }
85#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, m, t) \
86 { e += rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; b = rotate_left(b, 30); }
87#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, m, t) \
88 { e += rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; b = rotate_left(b, 30); }
89
90#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, m, t) \
91 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; }
92#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, m, t) \
93 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; }
94#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, m, t) \
95 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; }
96#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, m, t) \
97 { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; }
98
99#define SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, t, temp) \
100 {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);}
101
102#define SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(a, b, c, d, e, W, t, temp) \
103 {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); }
104
105#define SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, t, temp) \
106 {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); }
107
108#define SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, t, temp) \
109 {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); }
110
111#define SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, t, temp) \
112 {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); }
113
114
115#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;
116
117#ifdef BUILDNOCOLLDETECTSHA1COMPRESSION
118void sha1_compression(uint32_t ihv[5], const uint32_t m[16])
119{
120 uint32_t W[80];
121 uint32_t a,b,c,d,e;
122 unsigned i;
123
124 memcpy(W, m, 16 * 4);
125 for (i = 16; i < 80; ++i)
126 W[i] = sha1_mix(W, i);
127
128 a = ihv[0]; b = ihv[1]; c = ihv[2]; d = ihv[3]; e = ihv[4];
129
130 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0);
131 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1);
132 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2);
133 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3);
134 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4);
135 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5);
136 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6);
137 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7);
138 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8);
139 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9);
140 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10);
141 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11);
142 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12);
143 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13);
144 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14);
145 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15);
146 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16);
147 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17);
148 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18);
149 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19);
150
151 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20);
152 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
153 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
154 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23);
155 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24);
156 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25);
157 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26);
158 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
159 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
160 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
161 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
162 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
163 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32);
164 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
165 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34);
166 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
167 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
168 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
169 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
170 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39);
171
172 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40);
173 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41);
174 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42);
175 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43);
176 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44);
177 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45);
178 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46);
179 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47);
180 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48);
181 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49);
182 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50);
183 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51);
184 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52);
185 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53);
186 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54);
187 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55);
188 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56);
189 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57);
190 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58);
191 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
192
193 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60);
194 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61);
195 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62);
196 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63);
197 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64);
198 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65);
199 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66);
200 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67);
201 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68);
202 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69);
203 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70);
204 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71);
205 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72);
206 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73);
207 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74);
208 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75);
209 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76);
210 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77);
211 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
212 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
213
214 ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
215}
216#endif /*BUILDNOCOLLDETECTSHA1COMPRESSION*/
217
218
219static void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80])
220{
221 uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4];
222
223 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0);
224 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1);
225 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2);
226 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3);
227 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4);
228 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5);
229 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6);
230 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7);
231 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8);
232 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9);
233 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10);
234 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11);
235 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12);
236 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13);
237 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14);
238 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15);
239 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16);
240 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17);
241 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18);
242 HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19);
243
244 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20);
245 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
246 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
247 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23);
248 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24);
249 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25);
250 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26);
251 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
252 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
253 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
254 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
255 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
256 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32);
257 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
258 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34);
259 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
260 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
261 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
262 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
263 HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39);
264
265 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40);
266 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41);
267 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42);
268 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43);
269 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44);
270 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45);
271 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46);
272 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47);
273 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48);
274 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49);
275 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50);
276 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51);
277 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52);
278 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53);
279 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54);
280 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55);
281 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56);
282 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57);
283 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58);
284 HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
285
286 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60);
287 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61);
288 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62);
289 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63);
290 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64);
291 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65);
292 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66);
293 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67);
294 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68);
295 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69);
296 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70);
297 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71);
298 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72);
299 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73);
300 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74);
301 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75);
302 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76);
303 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77);
304 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
305 HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
306
307 ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
308}
309
310
311
312void sha1_compression_states(uint32_t ihv[5], const uint32_t m[16], uint32_t W[80], uint32_t states[80][5])
313{
314 uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4];
315 uint32_t temp;
316
317#ifdef DOSTORESTATE00
318 SHA1_STORE_STATE(0)
319#endif
320 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 0, temp);
321
322#ifdef DOSTORESTATE01
323 SHA1_STORE_STATE(1)
324#endif
325 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 1, temp);
326
327#ifdef DOSTORESTATE02
328 SHA1_STORE_STATE(2)
329#endif
330 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 2, temp);
331
332#ifdef DOSTORESTATE03
333 SHA1_STORE_STATE(3)
334#endif
335 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 3, temp);
336
337#ifdef DOSTORESTATE04
338 SHA1_STORE_STATE(4)
339#endif
340 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 4, temp);
341
342#ifdef DOSTORESTATE05
343 SHA1_STORE_STATE(5)
344#endif
345 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 5, temp);
346
347#ifdef DOSTORESTATE06
348 SHA1_STORE_STATE(6)
349#endif
350 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 6, temp);
351
352#ifdef DOSTORESTATE07
353 SHA1_STORE_STATE(7)
354#endif
355 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 7, temp);
356
357#ifdef DOSTORESTATE08
358 SHA1_STORE_STATE(8)
359#endif
360 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 8, temp);
361
362#ifdef DOSTORESTATE09
363 SHA1_STORE_STATE(9)
364#endif
365 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 9, temp);
366
367#ifdef DOSTORESTATE10
368 SHA1_STORE_STATE(10)
369#endif
370 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 10, temp);
371
372#ifdef DOSTORESTATE11
373 SHA1_STORE_STATE(11)
374#endif
375 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 11, temp);
376
377#ifdef DOSTORESTATE12
378 SHA1_STORE_STATE(12)
379#endif
380 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 12, temp);
381
382#ifdef DOSTORESTATE13
383 SHA1_STORE_STATE(13)
384#endif
385 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 13, temp);
386
387#ifdef DOSTORESTATE14
388 SHA1_STORE_STATE(14)
389#endif
390 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 14, temp);
391
392#ifdef DOSTORESTATE15
393 SHA1_STORE_STATE(15)
394#endif
395 SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 15, temp);
396
397#ifdef DOSTORESTATE16
398 SHA1_STORE_STATE(16)
399#endif
400 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(e, a, b, c, d, W, 16, temp);
401
402#ifdef DOSTORESTATE17
403 SHA1_STORE_STATE(17)
404#endif
405 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(d, e, a, b, c, W, 17, temp);
406
407#ifdef DOSTORESTATE18
408 SHA1_STORE_STATE(18)
409#endif
410 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(c, d, e, a, b, W, 18, temp);
411
412#ifdef DOSTORESTATE19
413 SHA1_STORE_STATE(19)
414#endif
415 SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(b, c, d, e, a, W, 19, temp);
416
417
418
419#ifdef DOSTORESTATE20
420 SHA1_STORE_STATE(20)
421#endif
422 SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 20, temp);
423
424#ifdef DOSTORESTATE21
425 SHA1_STORE_STATE(21)
426#endif
427 SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 21, temp);
428
429#ifdef DOSTORESTATE22
430 SHA1_STORE_STATE(22)
431#endif
432 SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 22, temp);
433
434#ifdef DOSTORESTATE23
435 SHA1_STORE_STATE(23)
436#endif
437 SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 23, temp);
438
439#ifdef DOSTORESTATE24
440 SHA1_STORE_STATE(24)
441#endif
442 SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 24, temp);
443
444#ifdef DOSTORESTATE25
445 SHA1_STORE_STATE(25)
446#endif
447 SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 25, temp);
448
449#ifdef DOSTORESTATE26
450 SHA1_STORE_STATE(26)
451#endif
452 SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 26, temp);
453
454#ifdef DOSTORESTATE27
455 SHA1_STORE_STATE(27)
456#endif
457 SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 27, temp);
458
459#ifdef DOSTORESTATE28
460 SHA1_STORE_STATE(28)
461#endif
462 SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 28, temp);
463
464#ifdef DOSTORESTATE29
465 SHA1_STORE_STATE(29)
466#endif
467 SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 29, temp);
468
469#ifdef DOSTORESTATE30
470 SHA1_STORE_STATE(30)
471#endif
472 SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 30, temp);
473
474#ifdef DOSTORESTATE31
475 SHA1_STORE_STATE(31)
476#endif
477 SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 31, temp);
478
479#ifdef DOSTORESTATE32
480 SHA1_STORE_STATE(32)
481#endif
482 SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 32, temp);
483
484#ifdef DOSTORESTATE33
485 SHA1_STORE_STATE(33)
486#endif
487 SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 33, temp);
488
489#ifdef DOSTORESTATE34
490 SHA1_STORE_STATE(34)
491#endif
492 SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 34, temp);
493
494#ifdef DOSTORESTATE35
495 SHA1_STORE_STATE(35)
496#endif
497 SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 35, temp);
498
499#ifdef DOSTORESTATE36
500 SHA1_STORE_STATE(36)
501#endif
502 SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 36, temp);
503
504#ifdef DOSTORESTATE37
505 SHA1_STORE_STATE(37)
506#endif
507 SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 37, temp);
508
509#ifdef DOSTORESTATE38
510 SHA1_STORE_STATE(38)
511#endif
512 SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 38, temp);
513
514#ifdef DOSTORESTATE39
515 SHA1_STORE_STATE(39)
516#endif
517 SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 39, temp);
518
519
520
521#ifdef DOSTORESTATE40
522 SHA1_STORE_STATE(40)
523#endif
524 SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 40, temp);
525
526#ifdef DOSTORESTATE41
527 SHA1_STORE_STATE(41)
528#endif
529 SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 41, temp);
530
531#ifdef DOSTORESTATE42
532 SHA1_STORE_STATE(42)
533#endif
534 SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 42, temp);
535
536#ifdef DOSTORESTATE43
537 SHA1_STORE_STATE(43)
538#endif
539 SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 43, temp);
540
541#ifdef DOSTORESTATE44
542 SHA1_STORE_STATE(44)
543#endif
544 SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 44, temp);
545
546#ifdef DOSTORESTATE45
547 SHA1_STORE_STATE(45)
548#endif
549 SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 45, temp);
550
551#ifdef DOSTORESTATE46
552 SHA1_STORE_STATE(46)
553#endif
554 SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 46, temp);
555
556#ifdef DOSTORESTATE47
557 SHA1_STORE_STATE(47)
558#endif
559 SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 47, temp);
560
561#ifdef DOSTORESTATE48
562 SHA1_STORE_STATE(48)
563#endif
564 SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 48, temp);
565
566#ifdef DOSTORESTATE49
567 SHA1_STORE_STATE(49)
568#endif
569 SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 49, temp);
570
571#ifdef DOSTORESTATE50
572 SHA1_STORE_STATE(50)
573#endif
574 SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 50, temp);
575
576#ifdef DOSTORESTATE51
577 SHA1_STORE_STATE(51)
578#endif
579 SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 51, temp);
580
581#ifdef DOSTORESTATE52
582 SHA1_STORE_STATE(52)
583#endif
584 SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 52, temp);
585
586#ifdef DOSTORESTATE53
587 SHA1_STORE_STATE(53)
588#endif
589 SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 53, temp);
590
591#ifdef DOSTORESTATE54
592 SHA1_STORE_STATE(54)
593#endif
594 SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 54, temp);
595
596#ifdef DOSTORESTATE55
597 SHA1_STORE_STATE(55)
598#endif
599 SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 55, temp);
600
601#ifdef DOSTORESTATE56
602 SHA1_STORE_STATE(56)
603#endif
604 SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 56, temp);
605
606#ifdef DOSTORESTATE57
607 SHA1_STORE_STATE(57)
608#endif
609 SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 57, temp);
610
611#ifdef DOSTORESTATE58
612 SHA1_STORE_STATE(58)
613#endif
614 SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 58, temp);
615
616#ifdef DOSTORESTATE59
617 SHA1_STORE_STATE(59)
618#endif
619 SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 59, temp);
620
621
622
623
624#ifdef DOSTORESTATE60
625 SHA1_STORE_STATE(60)
626#endif
627 SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 60, temp);
628
629#ifdef DOSTORESTATE61
630 SHA1_STORE_STATE(61)
631#endif
632 SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 61, temp);
633
634#ifdef DOSTORESTATE62
635 SHA1_STORE_STATE(62)
636#endif
637 SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 62, temp);
638
639#ifdef DOSTORESTATE63
640 SHA1_STORE_STATE(63)
641#endif
642 SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 63, temp);
643
644#ifdef DOSTORESTATE64
645 SHA1_STORE_STATE(64)
646#endif
647 SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 64, temp);
648
649#ifdef DOSTORESTATE65
650 SHA1_STORE_STATE(65)
651#endif
652 SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 65, temp);
653
654#ifdef DOSTORESTATE66
655 SHA1_STORE_STATE(66)
656#endif
657 SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 66, temp);
658
659#ifdef DOSTORESTATE67
660 SHA1_STORE_STATE(67)
661#endif
662 SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 67, temp);
663
664#ifdef DOSTORESTATE68
665 SHA1_STORE_STATE(68)
666#endif
667 SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 68, temp);
668
669#ifdef DOSTORESTATE69
670 SHA1_STORE_STATE(69)
671#endif
672 SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 69, temp);
673
674#ifdef DOSTORESTATE70
675 SHA1_STORE_STATE(70)
676#endif
677 SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 70, temp);
678
679#ifdef DOSTORESTATE71
680 SHA1_STORE_STATE(71)
681#endif
682 SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 71, temp);
683
684#ifdef DOSTORESTATE72
685 SHA1_STORE_STATE(72)
686#endif
687 SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 72, temp);
688
689#ifdef DOSTORESTATE73
690 SHA1_STORE_STATE(73)
691#endif
692 SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 73, temp);
693
694#ifdef DOSTORESTATE74
695 SHA1_STORE_STATE(74)
696#endif
697 SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 74, temp);
698
699#ifdef DOSTORESTATE75
700 SHA1_STORE_STATE(75)
701#endif
702 SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 75, temp);
703
704#ifdef DOSTORESTATE76
705 SHA1_STORE_STATE(76)
706#endif
707 SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 76, temp);
708
709#ifdef DOSTORESTATE77
710 SHA1_STORE_STATE(77)
711#endif
712 SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 77, temp);
713
714#ifdef DOSTORESTATE78
715 SHA1_STORE_STATE(78)
716#endif
717 SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 78, temp);
718
719#ifdef DOSTORESTATE79
720 SHA1_STORE_STATE(79)
721#endif
722 SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 79, temp);
723
724
725
726 ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
727}
728
729
730
731
732#define SHA1_RECOMPRESS(t) \
733static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) \
734{ \
735 uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; \
736 if (t > 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 79); \
737 if (t > 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 78); \
738 if (t > 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 77); \
739 if (t > 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 76); \
740 if (t > 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 75); \
741 if (t > 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 74); \
742 if (t > 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 73); \
743 if (t > 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 72); \
744 if (t > 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 71); \
745 if (t > 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 70); \
746 if (t > 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 69); \
747 if (t > 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 68); \
748 if (t > 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 67); \
749 if (t > 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 66); \
750 if (t > 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 65); \
751 if (t > 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 64); \
752 if (t > 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 63); \
753 if (t > 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 62); \
754 if (t > 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 61); \
755 if (t > 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 60); \
756 if (t > 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 59); \
757 if (t > 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 58); \
758 if (t > 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 57); \
759 if (t > 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 56); \
760 if (t > 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 55); \
761 if (t > 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 54); \
762 if (t > 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 53); \
763 if (t > 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 52); \
764 if (t > 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 51); \
765 if (t > 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 50); \
766 if (t > 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 49); \
767 if (t > 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 48); \
768 if (t > 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 47); \
769 if (t > 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 46); \
770 if (t > 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 45); \
771 if (t > 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 44); \
772 if (t > 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 43); \
773 if (t > 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 42); \
774 if (t > 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 41); \
775 if (t > 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 40); \
776 if (t > 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 39); \
777 if (t > 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 38); \
778 if (t > 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 37); \
779 if (t > 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 36); \
780 if (t > 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 35); \
781 if (t > 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 34); \
782 if (t > 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 33); \
783 if (t > 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 32); \
784 if (t > 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 31); \
785 if (t > 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 30); \
786 if (t > 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 29); \
787 if (t > 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 28); \
788 if (t > 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 27); \
789 if (t > 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 26); \
790 if (t > 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 25); \
791 if (t > 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 24); \
792 if (t > 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 23); \
793 if (t > 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 22); \
794 if (t > 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 21); \
795 if (t > 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 20); \
796 if (t > 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 19); \
797 if (t > 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 18); \
798 if (t > 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 17); \
799 if (t > 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 16); \
800 if (t > 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 15); \
801 if (t > 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 14); \
802 if (t > 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 13); \
803 if (t > 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 12); \
804 if (t > 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 11); \
805 if (t > 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 10); \
806 if (t > 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 9); \
807 if (t > 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 8); \
808 if (t > 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 7); \
809 if (t > 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 6); \
810 if (t > 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 5); \
811 if (t > 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 4); \
812 if (t > 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 3); \
813 if (t > 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 2); \
814 if (t > 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 1); \
815 if (t > 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 0); \
816 ihvin[0] = a; ihvin[1] = b; ihvin[2] = c; ihvin[3] = d; ihvin[4] = e; \
817 a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; \
818 if (t <= 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 0); \
819 if (t <= 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 1); \
820 if (t <= 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 2); \
821 if (t <= 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 3); \
822 if (t <= 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 4); \
823 if (t <= 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 5); \
824 if (t <= 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 6); \
825 if (t <= 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 7); \
826 if (t <= 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 8); \
827 if (t <= 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 9); \
828 if (t <= 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 10); \
829 if (t <= 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 11); \
830 if (t <= 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 12); \
831 if (t <= 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 13); \
832 if (t <= 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 14); \
833 if (t <= 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 15); \
834 if (t <= 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 16); \
835 if (t <= 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 17); \
836 if (t <= 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 18); \
837 if (t <= 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 19); \
838 if (t <= 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 20); \
839 if (t <= 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 21); \
840 if (t <= 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 22); \
841 if (t <= 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 23); \
842 if (t <= 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 24); \
843 if (t <= 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 25); \
844 if (t <= 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 26); \
845 if (t <= 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 27); \
846 if (t <= 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 28); \
847 if (t <= 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 29); \
848 if (t <= 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 30); \
849 if (t <= 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 31); \
850 if (t <= 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 32); \
851 if (t <= 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 33); \
852 if (t <= 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 34); \
853 if (t <= 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 35); \
854 if (t <= 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 36); \
855 if (t <= 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 37); \
856 if (t <= 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 38); \
857 if (t <= 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 39); \
858 if (t <= 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 40); \
859 if (t <= 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 41); \
860 if (t <= 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 42); \
861 if (t <= 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 43); \
862 if (t <= 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 44); \
863 if (t <= 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 45); \
864 if (t <= 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 46); \
865 if (t <= 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 47); \
866 if (t <= 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 48); \
867 if (t <= 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 49); \
868 if (t <= 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 50); \
869 if (t <= 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 51); \
870 if (t <= 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 52); \
871 if (t <= 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 53); \
872 if (t <= 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 54); \
873 if (t <= 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 55); \
874 if (t <= 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 56); \
875 if (t <= 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 57); \
876 if (t <= 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 58); \
877 if (t <= 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 59); \
878 if (t <= 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 60); \
879 if (t <= 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 61); \
880 if (t <= 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 62); \
881 if (t <= 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 63); \
882 if (t <= 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 64); \
883 if (t <= 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 65); \
884 if (t <= 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 66); \
885 if (t <= 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 67); \
886 if (t <= 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 68); \
887 if (t <= 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 69); \
888 if (t <= 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 70); \
889 if (t <= 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 71); \
890 if (t <= 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 72); \
891 if (t <= 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 73); \
892 if (t <= 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 74); \
893 if (t <= 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 75); \
894 if (t <= 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 76); \
895 if (t <= 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 77); \
896 if (t <= 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \
897 if (t <= 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \
898 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; \
899}
900
901#ifdef _MSC_VER
902#pragma warning(push)
903#pragma warning(disable: 4127) /* Complier complains about the checks in the above macro being constant. */
904#endif
905
906#ifdef DOSTORESTATE0
907SHA1_RECOMPRESS(0)
908#endif
909
910#ifdef DOSTORESTATE1
911SHA1_RECOMPRESS(1)
912#endif
913
914#ifdef DOSTORESTATE2
915SHA1_RECOMPRESS(2)
916#endif
917
918#ifdef DOSTORESTATE3
919SHA1_RECOMPRESS(3)
920#endif
921
922#ifdef DOSTORESTATE4
923SHA1_RECOMPRESS(4)
924#endif
925
926#ifdef DOSTORESTATE5
927SHA1_RECOMPRESS(5)
928#endif
929
930#ifdef DOSTORESTATE6
931SHA1_RECOMPRESS(6)
932#endif
933
934#ifdef DOSTORESTATE7
935SHA1_RECOMPRESS(7)
936#endif
937
938#ifdef DOSTORESTATE8
939SHA1_RECOMPRESS(8)
940#endif
941
942#ifdef DOSTORESTATE9
943SHA1_RECOMPRESS(9)
944#endif
945
946#ifdef DOSTORESTATE10
947SHA1_RECOMPRESS(10)
948#endif
949
950#ifdef DOSTORESTATE11
951SHA1_RECOMPRESS(11)
952#endif
953
954#ifdef DOSTORESTATE12
955SHA1_RECOMPRESS(12)
956#endif
957
958#ifdef DOSTORESTATE13
959SHA1_RECOMPRESS(13)
960#endif
961
962#ifdef DOSTORESTATE14
963SHA1_RECOMPRESS(14)
964#endif
965
966#ifdef DOSTORESTATE15
967SHA1_RECOMPRESS(15)
968#endif
969
970#ifdef DOSTORESTATE16
971SHA1_RECOMPRESS(16)
972#endif
973
974#ifdef DOSTORESTATE17
975SHA1_RECOMPRESS(17)
976#endif
977
978#ifdef DOSTORESTATE18
979SHA1_RECOMPRESS(18)
980#endif
981
982#ifdef DOSTORESTATE19
983SHA1_RECOMPRESS(19)
984#endif
985
986#ifdef DOSTORESTATE20
987SHA1_RECOMPRESS(20)
988#endif
989
990#ifdef DOSTORESTATE21
991SHA1_RECOMPRESS(21)
992#endif
993
994#ifdef DOSTORESTATE22
995SHA1_RECOMPRESS(22)
996#endif
997
998#ifdef DOSTORESTATE23
999SHA1_RECOMPRESS(23)
1000#endif
1001
1002#ifdef DOSTORESTATE24
1003SHA1_RECOMPRESS(24)
1004#endif
1005
1006#ifdef DOSTORESTATE25
1007SHA1_RECOMPRESS(25)
1008#endif
1009
1010#ifdef DOSTORESTATE26
1011SHA1_RECOMPRESS(26)
1012#endif
1013
1014#ifdef DOSTORESTATE27
1015SHA1_RECOMPRESS(27)
1016#endif
1017
1018#ifdef DOSTORESTATE28
1019SHA1_RECOMPRESS(28)
1020#endif
1021
1022#ifdef DOSTORESTATE29
1023SHA1_RECOMPRESS(29)
1024#endif
1025
1026#ifdef DOSTORESTATE30
1027SHA1_RECOMPRESS(30)
1028#endif
1029
1030#ifdef DOSTORESTATE31
1031SHA1_RECOMPRESS(31)
1032#endif
1033
1034#ifdef DOSTORESTATE32
1035SHA1_RECOMPRESS(32)
1036#endif
1037
1038#ifdef DOSTORESTATE33
1039SHA1_RECOMPRESS(33)
1040#endif
1041
1042#ifdef DOSTORESTATE34
1043SHA1_RECOMPRESS(34)
1044#endif
1045
1046#ifdef DOSTORESTATE35
1047SHA1_RECOMPRESS(35)
1048#endif
1049
1050#ifdef DOSTORESTATE36
1051SHA1_RECOMPRESS(36)
1052#endif
1053
1054#ifdef DOSTORESTATE37
1055SHA1_RECOMPRESS(37)
1056#endif
1057
1058#ifdef DOSTORESTATE38
1059SHA1_RECOMPRESS(38)
1060#endif
1061
1062#ifdef DOSTORESTATE39
1063SHA1_RECOMPRESS(39)
1064#endif
1065
1066#ifdef DOSTORESTATE40
1067SHA1_RECOMPRESS(40)
1068#endif
1069
1070#ifdef DOSTORESTATE41
1071SHA1_RECOMPRESS(41)
1072#endif
1073
1074#ifdef DOSTORESTATE42
1075SHA1_RECOMPRESS(42)
1076#endif
1077
1078#ifdef DOSTORESTATE43
1079SHA1_RECOMPRESS(43)
1080#endif
1081
1082#ifdef DOSTORESTATE44
1083SHA1_RECOMPRESS(44)
1084#endif
1085
1086#ifdef DOSTORESTATE45
1087SHA1_RECOMPRESS(45)
1088#endif
1089
1090#ifdef DOSTORESTATE46
1091SHA1_RECOMPRESS(46)
1092#endif
1093
1094#ifdef DOSTORESTATE47
1095SHA1_RECOMPRESS(47)
1096#endif
1097
1098#ifdef DOSTORESTATE48
1099SHA1_RECOMPRESS(48)
1100#endif
1101
1102#ifdef DOSTORESTATE49
1103SHA1_RECOMPRESS(49)
1104#endif
1105
1106#ifdef DOSTORESTATE50
1107SHA1_RECOMPRESS(50)
1108#endif
1109
1110#ifdef DOSTORESTATE51
1111SHA1_RECOMPRESS(51)
1112#endif
1113
1114#ifdef DOSTORESTATE52
1115SHA1_RECOMPRESS(52)
1116#endif
1117
1118#ifdef DOSTORESTATE53
1119SHA1_RECOMPRESS(53)
1120#endif
1121
1122#ifdef DOSTORESTATE54
1123SHA1_RECOMPRESS(54)
1124#endif
1125
1126#ifdef DOSTORESTATE55
1127SHA1_RECOMPRESS(55)
1128#endif
1129
1130#ifdef DOSTORESTATE56
1131SHA1_RECOMPRESS(56)
1132#endif
1133
1134#ifdef DOSTORESTATE57
1135SHA1_RECOMPRESS(57)
1136#endif
1137
1138#ifdef DOSTORESTATE58
1139SHA1_RECOMPRESS(58)
1140#endif
1141
1142#ifdef DOSTORESTATE59
1143SHA1_RECOMPRESS(59)
1144#endif
1145
1146#ifdef DOSTORESTATE60
1147SHA1_RECOMPRESS(60)
1148#endif
1149
1150#ifdef DOSTORESTATE61
1151SHA1_RECOMPRESS(61)
1152#endif
1153
1154#ifdef DOSTORESTATE62
1155SHA1_RECOMPRESS(62)
1156#endif
1157
1158#ifdef DOSTORESTATE63
1159SHA1_RECOMPRESS(63)
1160#endif
1161
1162#ifdef DOSTORESTATE64
1163SHA1_RECOMPRESS(64)
1164#endif
1165
1166#ifdef DOSTORESTATE65
1167SHA1_RECOMPRESS(65)
1168#endif
1169
1170#ifdef DOSTORESTATE66
1171SHA1_RECOMPRESS(66)
1172#endif
1173
1174#ifdef DOSTORESTATE67
1175SHA1_RECOMPRESS(67)
1176#endif
1177
1178#ifdef DOSTORESTATE68
1179SHA1_RECOMPRESS(68)
1180#endif
1181
1182#ifdef DOSTORESTATE69
1183SHA1_RECOMPRESS(69)
1184#endif
1185
1186#ifdef DOSTORESTATE70
1187SHA1_RECOMPRESS(70)
1188#endif
1189
1190#ifdef DOSTORESTATE71
1191SHA1_RECOMPRESS(71)
1192#endif
1193
1194#ifdef DOSTORESTATE72
1195SHA1_RECOMPRESS(72)
1196#endif
1197
1198#ifdef DOSTORESTATE73
1199SHA1_RECOMPRESS(73)
1200#endif
1201
1202#ifdef DOSTORESTATE74
1203SHA1_RECOMPRESS(74)
1204#endif
1205
1206#ifdef DOSTORESTATE75
1207SHA1_RECOMPRESS(75)
1208#endif
1209
1210#ifdef DOSTORESTATE76
1211SHA1_RECOMPRESS(76)
1212#endif
1213
1214#ifdef DOSTORESTATE77
1215SHA1_RECOMPRESS(77)
1216#endif
1217
1218#ifdef DOSTORESTATE78
1219SHA1_RECOMPRESS(78)
1220#endif
1221
1222#ifdef DOSTORESTATE79
1223SHA1_RECOMPRESS(79)
1224#endif
1225
1226#ifdef _MSC_VER
1227#pragma warning(pop)
1228#endif
1229
1230static 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])
1231{
1232 switch (step)
1233 {
1234#ifdef DOSTORESTATE0
1235 case 0:
1236 sha1recompress_fast_0(ihvin, ihvout, me2, state);
1237 break;
1238#endif
1239#ifdef DOSTORESTATE1
1240 case 1:
1241 sha1recompress_fast_1(ihvin, ihvout, me2, state);
1242 break;
1243#endif
1244#ifdef DOSTORESTATE2
1245 case 2:
1246 sha1recompress_fast_2(ihvin, ihvout, me2, state);
1247 break;
1248#endif
1249#ifdef DOSTORESTATE3
1250 case 3:
1251 sha1recompress_fast_3(ihvin, ihvout, me2, state);
1252 break;
1253#endif
1254#ifdef DOSTORESTATE4
1255 case 4:
1256 sha1recompress_fast_4(ihvin, ihvout, me2, state);
1257 break;
1258#endif
1259#ifdef DOSTORESTATE5
1260 case 5:
1261 sha1recompress_fast_5(ihvin, ihvout, me2, state);
1262 break;
1263#endif
1264#ifdef DOSTORESTATE6
1265 case 6:
1266 sha1recompress_fast_6(ihvin, ihvout, me2, state);
1267 break;
1268#endif
1269#ifdef DOSTORESTATE7
1270 case 7:
1271 sha1recompress_fast_7(ihvin, ihvout, me2, state);
1272 break;
1273#endif
1274#ifdef DOSTORESTATE8
1275 case 8:
1276 sha1recompress_fast_8(ihvin, ihvout, me2, state);
1277 break;
1278#endif
1279#ifdef DOSTORESTATE9
1280 case 9:
1281 sha1recompress_fast_9(ihvin, ihvout, me2, state);
1282 break;
1283#endif
1284#ifdef DOSTORESTATE10
1285 case 10:
1286 sha1recompress_fast_10(ihvin, ihvout, me2, state);
1287 break;
1288#endif
1289#ifdef DOSTORESTATE11
1290 case 11:
1291 sha1recompress_fast_11(ihvin, ihvout, me2, state);
1292 break;
1293#endif
1294#ifdef DOSTORESTATE12
1295 case 12:
1296 sha1recompress_fast_12(ihvin, ihvout, me2, state);
1297 break;
1298#endif
1299#ifdef DOSTORESTATE13
1300 case 13:
1301 sha1recompress_fast_13(ihvin, ihvout, me2, state);
1302 break;
1303#endif
1304#ifdef DOSTORESTATE14
1305 case 14:
1306 sha1recompress_fast_14(ihvin, ihvout, me2, state);
1307 break;
1308#endif
1309#ifdef DOSTORESTATE15
1310 case 15:
1311 sha1recompress_fast_15(ihvin, ihvout, me2, state);
1312 break;
1313#endif
1314#ifdef DOSTORESTATE16
1315 case 16:
1316 sha1recompress_fast_16(ihvin, ihvout, me2, state);
1317 break;
1318#endif
1319#ifdef DOSTORESTATE17
1320 case 17:
1321 sha1recompress_fast_17(ihvin, ihvout, me2, state);
1322 break;
1323#endif
1324#ifdef DOSTORESTATE18
1325 case 18:
1326 sha1recompress_fast_18(ihvin, ihvout, me2, state);
1327 break;
1328#endif
1329#ifdef DOSTORESTATE19
1330 case 19:
1331 sha1recompress_fast_19(ihvin, ihvout, me2, state);
1332 break;
1333#endif
1334#ifdef DOSTORESTATE20
1335 case 20:
1336 sha1recompress_fast_20(ihvin, ihvout, me2, state);
1337 break;
1338#endif
1339#ifdef DOSTORESTATE21
1340 case 21:
1341 sha1recompress_fast_21(ihvin, ihvout, me2, state);
1342 break;
1343#endif
1344#ifdef DOSTORESTATE22
1345 case 22:
1346 sha1recompress_fast_22(ihvin, ihvout, me2, state);
1347 break;
1348#endif
1349#ifdef DOSTORESTATE23
1350 case 23:
1351 sha1recompress_fast_23(ihvin, ihvout, me2, state);
1352 break;
1353#endif
1354#ifdef DOSTORESTATE24
1355 case 24:
1356 sha1recompress_fast_24(ihvin, ihvout, me2, state);
1357 break;
1358#endif
1359#ifdef DOSTORESTATE25
1360 case 25:
1361 sha1recompress_fast_25(ihvin, ihvout, me2, state);
1362 break;
1363#endif
1364#ifdef DOSTORESTATE26
1365 case 26:
1366 sha1recompress_fast_26(ihvin, ihvout, me2, state);
1367 break;
1368#endif
1369#ifdef DOSTORESTATE27
1370 case 27:
1371 sha1recompress_fast_27(ihvin, ihvout, me2, state);
1372 break;
1373#endif
1374#ifdef DOSTORESTATE28
1375 case 28:
1376 sha1recompress_fast_28(ihvin, ihvout, me2, state);
1377 break;
1378#endif
1379#ifdef DOSTORESTATE29
1380 case 29:
1381 sha1recompress_fast_29(ihvin, ihvout, me2, state);
1382 break;
1383#endif
1384#ifdef DOSTORESTATE30
1385 case 30:
1386 sha1recompress_fast_30(ihvin, ihvout, me2, state);
1387 break;
1388#endif
1389#ifdef DOSTORESTATE31
1390 case 31:
1391 sha1recompress_fast_31(ihvin, ihvout, me2, state);
1392 break;
1393#endif
1394#ifdef DOSTORESTATE32
1395 case 32:
1396 sha1recompress_fast_32(ihvin, ihvout, me2, state);
1397 break;
1398#endif
1399#ifdef DOSTORESTATE33
1400 case 33:
1401 sha1recompress_fast_33(ihvin, ihvout, me2, state);
1402 break;
1403#endif
1404#ifdef DOSTORESTATE34
1405 case 34:
1406 sha1recompress_fast_34(ihvin, ihvout, me2, state);
1407 break;
1408#endif
1409#ifdef DOSTORESTATE35
1410 case 35:
1411 sha1recompress_fast_35(ihvin, ihvout, me2, state);
1412 break;
1413#endif
1414#ifdef DOSTORESTATE36
1415 case 36:
1416 sha1recompress_fast_36(ihvin, ihvout, me2, state);
1417 break;
1418#endif
1419#ifdef DOSTORESTATE37
1420 case 37:
1421 sha1recompress_fast_37(ihvin, ihvout, me2, state);
1422 break;
1423#endif
1424#ifdef DOSTORESTATE38
1425 case 38:
1426 sha1recompress_fast_38(ihvin, ihvout, me2, state);
1427 break;
1428#endif
1429#ifdef DOSTORESTATE39
1430 case 39:
1431 sha1recompress_fast_39(ihvin, ihvout, me2, state);
1432 break;
1433#endif
1434#ifdef DOSTORESTATE40
1435 case 40:
1436 sha1recompress_fast_40(ihvin, ihvout, me2, state);
1437 break;
1438#endif
1439#ifdef DOSTORESTATE41
1440 case 41:
1441 sha1recompress_fast_41(ihvin, ihvout, me2, state);
1442 break;
1443#endif
1444#ifdef DOSTORESTATE42
1445 case 42:
1446 sha1recompress_fast_42(ihvin, ihvout, me2, state);
1447 break;
1448#endif
1449#ifdef DOSTORESTATE43
1450 case 43:
1451 sha1recompress_fast_43(ihvin, ihvout, me2, state);
1452 break;
1453#endif
1454#ifdef DOSTORESTATE44
1455 case 44:
1456 sha1recompress_fast_44(ihvin, ihvout, me2, state);
1457 break;
1458#endif
1459#ifdef DOSTORESTATE45
1460 case 45:
1461 sha1recompress_fast_45(ihvin, ihvout, me2, state);
1462 break;
1463#endif
1464#ifdef DOSTORESTATE46
1465 case 46:
1466 sha1recompress_fast_46(ihvin, ihvout, me2, state);
1467 break;
1468#endif
1469#ifdef DOSTORESTATE47
1470 case 47:
1471 sha1recompress_fast_47(ihvin, ihvout, me2, state);
1472 break;
1473#endif
1474#ifdef DOSTORESTATE48
1475 case 48:
1476 sha1recompress_fast_48(ihvin, ihvout, me2, state);
1477 break;
1478#endif
1479#ifdef DOSTORESTATE49
1480 case 49:
1481 sha1recompress_fast_49(ihvin, ihvout, me2, state);
1482 break;
1483#endif
1484#ifdef DOSTORESTATE50
1485 case 50:
1486 sha1recompress_fast_50(ihvin, ihvout, me2, state);
1487 break;
1488#endif
1489#ifdef DOSTORESTATE51
1490 case 51:
1491 sha1recompress_fast_51(ihvin, ihvout, me2, state);
1492 break;
1493#endif
1494#ifdef DOSTORESTATE52
1495 case 52:
1496 sha1recompress_fast_52(ihvin, ihvout, me2, state);
1497 break;
1498#endif
1499#ifdef DOSTORESTATE53
1500 case 53:
1501 sha1recompress_fast_53(ihvin, ihvout, me2, state);
1502 break;
1503#endif
1504#ifdef DOSTORESTATE54
1505 case 54:
1506 sha1recompress_fast_54(ihvin, ihvout, me2, state);
1507 break;
1508#endif
1509#ifdef DOSTORESTATE55
1510 case 55:
1511 sha1recompress_fast_55(ihvin, ihvout, me2, state);
1512 break;
1513#endif
1514#ifdef DOSTORESTATE56
1515 case 56:
1516 sha1recompress_fast_56(ihvin, ihvout, me2, state);
1517 break;
1518#endif
1519#ifdef DOSTORESTATE57
1520 case 57:
1521 sha1recompress_fast_57(ihvin, ihvout, me2, state);
1522 break;
1523#endif
1524#ifdef DOSTORESTATE58
1525 case 58:
1526 sha1recompress_fast_58(ihvin, ihvout, me2, state);
1527 break;
1528#endif
1529#ifdef DOSTORESTATE59
1530 case 59:
1531 sha1recompress_fast_59(ihvin, ihvout, me2, state);
1532 break;
1533#endif
1534#ifdef DOSTORESTATE60
1535 case 60:
1536 sha1recompress_fast_60(ihvin, ihvout, me2, state);
1537 break;
1538#endif
1539#ifdef DOSTORESTATE61
1540 case 61:
1541 sha1recompress_fast_61(ihvin, ihvout, me2, state);
1542 break;
1543#endif
1544#ifdef DOSTORESTATE62
1545 case 62:
1546 sha1recompress_fast_62(ihvin, ihvout, me2, state);
1547 break;
1548#endif
1549#ifdef DOSTORESTATE63
1550 case 63:
1551 sha1recompress_fast_63(ihvin, ihvout, me2, state);
1552 break;
1553#endif
1554#ifdef DOSTORESTATE64
1555 case 64:
1556 sha1recompress_fast_64(ihvin, ihvout, me2, state);
1557 break;
1558#endif
1559#ifdef DOSTORESTATE65
1560 case 65:
1561 sha1recompress_fast_65(ihvin, ihvout, me2, state);
1562 break;
1563#endif
1564#ifdef DOSTORESTATE66
1565 case 66:
1566 sha1recompress_fast_66(ihvin, ihvout, me2, state);
1567 break;
1568#endif
1569#ifdef DOSTORESTATE67
1570 case 67:
1571 sha1recompress_fast_67(ihvin, ihvout, me2, state);
1572 break;
1573#endif
1574#ifdef DOSTORESTATE68
1575 case 68:
1576 sha1recompress_fast_68(ihvin, ihvout, me2, state);
1577 break;
1578#endif
1579#ifdef DOSTORESTATE69
1580 case 69:
1581 sha1recompress_fast_69(ihvin, ihvout, me2, state);
1582 break;
1583#endif
1584#ifdef DOSTORESTATE70
1585 case 70:
1586 sha1recompress_fast_70(ihvin, ihvout, me2, state);
1587 break;
1588#endif
1589#ifdef DOSTORESTATE71
1590 case 71:
1591 sha1recompress_fast_71(ihvin, ihvout, me2, state);
1592 break;
1593#endif
1594#ifdef DOSTORESTATE72
1595 case 72:
1596 sha1recompress_fast_72(ihvin, ihvout, me2, state);
1597 break;
1598#endif
1599#ifdef DOSTORESTATE73
1600 case 73:
1601 sha1recompress_fast_73(ihvin, ihvout, me2, state);
1602 break;
1603#endif
1604#ifdef DOSTORESTATE74
1605 case 74:
1606 sha1recompress_fast_74(ihvin, ihvout, me2, state);
1607 break;
1608#endif
1609#ifdef DOSTORESTATE75
1610 case 75:
1611 sha1recompress_fast_75(ihvin, ihvout, me2, state);
1612 break;
1613#endif
1614#ifdef DOSTORESTATE76
1615 case 76:
1616 sha1recompress_fast_76(ihvin, ihvout, me2, state);
1617 break;
1618#endif
1619#ifdef DOSTORESTATE77
1620 case 77:
1621 sha1recompress_fast_77(ihvin, ihvout, me2, state);
1622 break;
1623#endif
1624#ifdef DOSTORESTATE78
1625 case 78:
1626 sha1recompress_fast_78(ihvin, ihvout, me2, state);
1627 break;
1628#endif
1629#ifdef DOSTORESTATE79
1630 case 79:
1631 sha1recompress_fast_79(ihvin, ihvout, me2, state);
1632 break;
1633#endif
1634 default:
1635 abort();
1636 }
1637
1638}
1639
1640
1641
1642static void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])
1643{
1644 unsigned i, j;
1645 uint32_t ubc_dv_mask[DVMASKSIZE] = { 0xFFFFFFFF };
1646 uint32_t ihvtmp[5];
1647
1648 ctx->ihv1[0] = ctx->ihv[0];
1649 ctx->ihv1[1] = ctx->ihv[1];
1650 ctx->ihv1[2] = ctx->ihv[2];
1651 ctx->ihv1[3] = ctx->ihv[3];
1652 ctx->ihv1[4] = ctx->ihv[4];
1653
1654 sha1_compression_states(ctx->ihv, block, ctx->m1, ctx->states);
1655
1656 if (ctx->detect_coll)
1657 {
1658 if (ctx->ubc_check)
1659 {
1660 ubc_check(ctx->m1, ubc_dv_mask);
1661 }
1662
1663 if (ubc_dv_mask[0] != 0)
1664 {
1665 for (i = 0; sha1_dvs[i].dvType != 0; ++i)
1666 {
1667 if (ubc_dv_mask[0] & ((uint32_t)(1) << sha1_dvs[i].maskb))
1668 {
1669 for (j = 0; j < 80; ++j)
1670 ctx->m2[j] = ctx->m1[j] ^ sha1_dvs[i].dm[j];
1671
1672 sha1_recompression_step(sha1_dvs[i].testt, ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]);
1673
1674 /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */
1675 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])))
1676 || (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]))))
1677 {
1678 ctx->found_collision = 1;
1679
1680 if (ctx->safe_hash)
1681 {
1682 sha1_compression_W(ctx->ihv, ctx->m1);
1683 sha1_compression_W(ctx->ihv, ctx->m1);
1684 }
1685
1686 break;
1687 }
1688 }
1689 }
1690 }
1691 }
1692}
1693
1694void SHA1DCInit(SHA1_CTX* ctx)
1695{
1696 ctx->total = 0;
1697 ctx->ihv[0] = 0x67452301;
1698 ctx->ihv[1] = 0xEFCDAB89;
1699 ctx->ihv[2] = 0x98BADCFE;
1700 ctx->ihv[3] = 0x10325476;
1701 ctx->ihv[4] = 0xC3D2E1F0;
1702 ctx->found_collision = 0;
1703 ctx->safe_hash = SHA1DC_INIT_SAFE_HASH_DEFAULT;
1704 ctx->ubc_check = 1;
1705 ctx->detect_coll = 1;
1706 ctx->reduced_round_coll = 0;
1707 ctx->callback = NULL;
1708}
1709
1710void SHA1DCSetSafeHash(SHA1_CTX* ctx, int safehash)
1711{
1712 if (safehash)
1713 ctx->safe_hash = 1;
1714 else
1715 ctx->safe_hash = 0;
1716}
1717
1718
1719void SHA1DCSetUseUBC(SHA1_CTX* ctx, int ubc_check)
1720{
1721 if (ubc_check)
1722 ctx->ubc_check = 1;
1723 else
1724 ctx->ubc_check = 0;
1725}
1726
1727void SHA1DCSetUseDetectColl(SHA1_CTX* ctx, int detect_coll)
1728{
1729 if (detect_coll)
1730 ctx->detect_coll = 1;
1731 else
1732 ctx->detect_coll = 0;
1733}
1734
1735void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX* ctx, int reduced_round_coll)
1736{
1737 if (reduced_round_coll)
1738 ctx->reduced_round_coll = 1;
1739 else
1740 ctx->reduced_round_coll = 0;
1741}
1742
1743void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback)
1744{
1745 ctx->callback = callback;
1746}
1747
1748void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)
1749{
1750 unsigned left, fill;
1751
1752 if (len == 0)
1753 return;
1754
1755 left = ctx->total & 63;
1756 fill = 64 - left;
1757
1758 if (left && len >= fill)
1759 {
1760 ctx->total += fill;
1761 memcpy(ctx->buffer + left, buf, fill);
1762 sha1_process(ctx, (uint32_t*)(ctx->buffer));
1763 buf += fill;
1764 len -= fill;
1765 left = 0;
1766 }
1767 while (len >= 64)
1768 {
1769 ctx->total += 64;
1770
1771#if defined(SHA1DC_ALLOW_UNALIGNED_ACCESS)
1772 sha1_process(ctx, (uint32_t*)(buf));
1773#else
1774 memcpy(ctx->buffer, buf, 64);
1775 sha1_process(ctx, (uint32_t*)(ctx->buffer));
1776#endif /* defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) */
1777 buf += 64;
1778 len -= 64;
1779 }
1780 if (len > 0)
1781 {
1782 ctx->total += len;
1783 memcpy(ctx->buffer + left, buf, len);
1784 }
1785}
1786
1787static const unsigned char sha1_padding[64] =
1788{
1789 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1790 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1791 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1792 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1793};
1794
1795int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx)
1796{
1797 uint32_t last = ctx->total & 63;
1798 uint32_t padn = (last < 56) ? (56 - last) : (120 - last);
1799 uint64_t total;
1800 SHA1DCUpdate(ctx, (const char*)(sha1_padding), padn);
1801
1802 total = ctx->total - padn;
1803 total <<= 3;
1804 ctx->buffer[56] = (unsigned char)(total >> 56);
1805 ctx->buffer[57] = (unsigned char)(total >> 48);
1806 ctx->buffer[58] = (unsigned char)(total >> 40);
1807 ctx->buffer[59] = (unsigned char)(total >> 32);
1808 ctx->buffer[60] = (unsigned char)(total >> 24);
1809 ctx->buffer[61] = (unsigned char)(total >> 16);
1810 ctx->buffer[62] = (unsigned char)(total >> 8);
1811 ctx->buffer[63] = (unsigned char)(total);
1812 sha1_process(ctx, (uint32_t*)(ctx->buffer));
1813 output[0] = (unsigned char)(ctx->ihv[0] >> 24);
1814 output[1] = (unsigned char)(ctx->ihv[0] >> 16);
1815 output[2] = (unsigned char)(ctx->ihv[0] >> 8);
1816 output[3] = (unsigned char)(ctx->ihv[0]);
1817 output[4] = (unsigned char)(ctx->ihv[1] >> 24);
1818 output[5] = (unsigned char)(ctx->ihv[1] >> 16);
1819 output[6] = (unsigned char)(ctx->ihv[1] >> 8);
1820 output[7] = (unsigned char)(ctx->ihv[1]);
1821 output[8] = (unsigned char)(ctx->ihv[2] >> 24);
1822 output[9] = (unsigned char)(ctx->ihv[2] >> 16);
1823 output[10] = (unsigned char)(ctx->ihv[2] >> 8);
1824 output[11] = (unsigned char)(ctx->ihv[2]);
1825 output[12] = (unsigned char)(ctx->ihv[3] >> 24);
1826 output[13] = (unsigned char)(ctx->ihv[3] >> 16);
1827 output[14] = (unsigned char)(ctx->ihv[3] >> 8);
1828 output[15] = (unsigned char)(ctx->ihv[3]);
1829 output[16] = (unsigned char)(ctx->ihv[4] >> 24);
1830 output[17] = (unsigned char)(ctx->ihv[4] >> 16);
1831 output[18] = (unsigned char)(ctx->ihv[4] >> 8);
1832 output[19] = (unsigned char)(ctx->ihv[4]);
1833 return ctx->found_collision;
1834}
1835
1836#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C
1837#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C
1838#endif