rugged 0.26.0b5 → 0.26.0

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