PageRenderTime 625ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/sha1dc/sha1.c

https://gitlab.com/storedmirrors/git
C | 1584 lines | 1299 code | 227 blank | 58 comment | 197 complexity | e5779bb321cfae14418d69223c31666c MD5 | raw file
  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. #ifndef SHA1DC_NO_STANDARD_INCLUDES
  8. #include <string.h>
  9. #include <memory.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #ifdef __unix__
  13. #include <sys/types.h> /* make sure macros like _BIG_ENDIAN visible */
  14. #endif
  15. #endif
  16. #ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C
  17. #include SHA1DC_CUSTOM_INCLUDE_SHA1_C
  18. #endif
  19. #ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT
  20. #define SHA1DC_INIT_SAFE_HASH_DEFAULT 1
  21. #endif
  22. #include "sha1.h"
  23. #include "ubc_check.h"
  24. #if (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \
  25. defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \
  26. defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \
  27. defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \
  28. defined(__386) || defined(_M_X64) || defined(_M_AMD64))
  29. #define SHA1DC_ON_INTEL_LIKE_PROCESSOR
  30. #endif
  31. /*
  32. Because Little-Endian architectures are most common,
  33. we only set SHA1DC_BIGENDIAN if one of these conditions is met.
  34. Note that all MSFT platforms are little endian,
  35. so none of these will be defined under the MSC compiler.
  36. If you are compiling on a big endian platform and your compiler does not define one of these,
  37. you will have to add whatever macros your tool chain defines to indicate Big-Endianness.
  38. */
  39. #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
  40. /*
  41. * Should detect Big Endian under GCC since at least 4.6.0 (gcc svn
  42. * rev #165881). See
  43. * https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
  44. *
  45. * This also works under clang since 3.2, it copied the GCC-ism. See
  46. * clang.git's 3b198a97d2 ("Preprocessor: add __BYTE_ORDER__
  47. * predefined macro", 2012-07-27)
  48. */
  49. #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  50. #define SHA1DC_BIGENDIAN
  51. #endif
  52. /* Not under GCC-alike */
  53. #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN)
  54. /*
  55. * Should detect Big Endian under glibc.git since 14245eb70e ("entered
  56. * into RCS", 1992-11-25). Defined in <endian.h> which will have been
  57. * brought in by standard headers. See glibc.git and
  58. * https://sourceforge.net/p/predef/wiki/Endianness/
  59. */
  60. #if __BYTE_ORDER == __BIG_ENDIAN
  61. #define SHA1DC_BIGENDIAN
  62. #endif
  63. /* Not under GCC-alike or glibc */
  64. #elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
  65. /*
  66. * *BSD and newlib (embedded linux, cygwin, etc).
  67. * the defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) part prevents
  68. * this condition from matching with Solaris/sparc.
  69. * (Solaris defines only one endian macro)
  70. */
  71. #if _BYTE_ORDER == _BIG_ENDIAN
  72. #define SHA1DC_BIGENDIAN
  73. #endif
  74. /* Not under GCC-alike or glibc or *BSD or newlib */
  75. #elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
  76. defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \
  77. defined(__sparc))
  78. /*
  79. * Should define Big Endian for a whitelist of known processors. See
  80. * https://sourceforge.net/p/predef/wiki/Endianness/ and
  81. * http://www.oracle.com/technetwork/server-storage/solaris/portingtosolaris-138514.html
  82. */
  83. #define SHA1DC_BIGENDIAN
  84. /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
  85. #elif (defined(_AIX) || defined(__hpux))
  86. /*
  87. * Defines Big Endian on a whitelist of OSs that are known to be Big
  88. * Endian-only. See
  89. * https://lore.kernel.org/git/93056823-2740-d072-1ebd-46b440b33d7e@felt.demon.nl/
  90. */
  91. #define SHA1DC_BIGENDIAN
  92. /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <os whitelist> */
  93. #elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
  94. /*
  95. * As a last resort before we do anything else we're not 100% sure
  96. * about below, we blacklist specific processors here. We could add
  97. * more, see e.g. https://wiki.debian.org/ArchitectureSpecificsMemo
  98. */
  99. #else /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <os whitelist> or <processor blacklist> */
  100. /* We do nothing more here for now */
  101. /*#error "Uncomment this to see if you fall through all the detection"*/
  102. #endif /* Big Endian detection */
  103. #if (defined(SHA1DC_FORCE_LITTLEENDIAN) && defined(SHA1DC_BIGENDIAN))
  104. #undef SHA1DC_BIGENDIAN
  105. #endif
  106. #if (defined(SHA1DC_FORCE_BIGENDIAN) && !defined(SHA1DC_BIGENDIAN))
  107. #define SHA1DC_BIGENDIAN
  108. #endif
  109. /*ENDIANNESS SELECTION*/
  110. #ifndef SHA1DC_FORCE_ALIGNED_ACCESS
  111. #if defined(SHA1DC_FORCE_UNALIGNED_ACCESS) || defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
  112. #define SHA1DC_ALLOW_UNALIGNED_ACCESS
  113. #endif /*UNALIGNED ACCESS DETECTION*/
  114. #endif /*FORCE ALIGNED ACCESS*/
  115. #define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
  116. #define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))
  117. #define sha1_bswap32(x) \
  118. {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);}
  119. #define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
  120. #ifdef SHA1DC_BIGENDIAN
  121. #define sha1_load(m, t, temp) { temp = m[t]; }
  122. #else
  123. #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
  124. #endif
  125. #define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
  126. #define sha1_f1(b,c,d) ((d)^((b)&((c)^(d))))
  127. #define sha1_f2(b,c,d) ((b)^(c)^(d))
  128. #define sha1_f3(b,c,d) (((b)&(c))+((d)&((b)^(c))))
  129. #define sha1_f4(b,c,d) ((b)^(c)^(d))
  130. #define HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, m, t) \
  131. { e += rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; b = rotate_left(b, 30); }
  132. #define HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, m, t) \
  133. { e += rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; b = rotate_left(b, 30); }
  134. #define HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, m, t) \
  135. { e += rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; b = rotate_left(b, 30); }
  136. #define HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, m, t) \
  137. { e += rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; b = rotate_left(b, 30); }
  138. #define HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, m, t) \
  139. { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; }
  140. #define HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, m, t) \
  141. { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; }
  142. #define HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, m, t) \
  143. { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; }
  144. #define HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, m, t) \
  145. { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; }
  146. #define SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, t, temp) \
  147. {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);}
  148. #define SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(a, b, c, d, e, W, t, temp) \
  149. {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); }
  150. #define SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, t, temp) \
  151. {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); }
  152. #define SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, t, temp) \
  153. {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); }
  154. #define SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, t, temp) \
  155. {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); }
  156. #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;
  157. #ifdef BUILDNOCOLLDETECTSHA1COMPRESSION
  158. void sha1_compression(uint32_t ihv[5], const uint32_t m[16])
  159. {
  160. uint32_t W[80];
  161. uint32_t a,b,c,d,e;
  162. unsigned i;
  163. memcpy(W, m, 16 * 4);
  164. for (i = 16; i < 80; ++i)
  165. W[i] = sha1_mix(W, i);
  166. a = ihv[0]; b = ihv[1]; c = ihv[2]; d = ihv[3]; e = ihv[4];
  167. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0);
  168. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1);
  169. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2);
  170. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3);
  171. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4);
  172. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5);
  173. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6);
  174. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7);
  175. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8);
  176. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9);
  177. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10);
  178. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11);
  179. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12);
  180. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13);
  181. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14);
  182. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15);
  183. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16);
  184. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17);
  185. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18);
  186. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19);
  187. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20);
  188. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
  189. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
  190. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23);
  191. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24);
  192. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25);
  193. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26);
  194. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
  195. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
  196. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
  197. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
  198. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
  199. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32);
  200. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
  201. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34);
  202. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
  203. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
  204. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
  205. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
  206. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39);
  207. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40);
  208. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41);
  209. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42);
  210. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43);
  211. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44);
  212. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45);
  213. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46);
  214. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47);
  215. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48);
  216. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49);
  217. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50);
  218. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51);
  219. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52);
  220. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53);
  221. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54);
  222. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55);
  223. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56);
  224. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57);
  225. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58);
  226. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
  227. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60);
  228. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61);
  229. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62);
  230. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63);
  231. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64);
  232. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65);
  233. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66);
  234. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67);
  235. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68);
  236. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69);
  237. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70);
  238. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71);
  239. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72);
  240. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73);
  241. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74);
  242. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75);
  243. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76);
  244. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77);
  245. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
  246. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
  247. ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
  248. }
  249. #endif /*BUILDNOCOLLDETECTSHA1COMPRESSION*/
  250. static void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80])
  251. {
  252. uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4];
  253. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0);
  254. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1);
  255. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2);
  256. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3);
  257. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4);
  258. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5);
  259. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6);
  260. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7);
  261. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8);
  262. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9);
  263. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10);
  264. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11);
  265. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12);
  266. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13);
  267. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14);
  268. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15);
  269. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16);
  270. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17);
  271. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18);
  272. HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19);
  273. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20);
  274. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21);
  275. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22);
  276. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23);
  277. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24);
  278. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25);
  279. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26);
  280. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27);
  281. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28);
  282. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29);
  283. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30);
  284. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31);
  285. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32);
  286. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33);
  287. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34);
  288. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35);
  289. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36);
  290. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37);
  291. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38);
  292. HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39);
  293. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40);
  294. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41);
  295. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42);
  296. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43);
  297. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44);
  298. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45);
  299. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46);
  300. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47);
  301. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48);
  302. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49);
  303. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50);
  304. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51);
  305. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52);
  306. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53);
  307. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54);
  308. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55);
  309. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56);
  310. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57);
  311. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58);
  312. HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59);
  313. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60);
  314. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61);
  315. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62);
  316. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63);
  317. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64);
  318. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65);
  319. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66);
  320. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67);
  321. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68);
  322. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69);
  323. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70);
  324. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71);
  325. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72);
  326. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73);
  327. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74);
  328. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75);
  329. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76);
  330. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77);
  331. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78);
  332. HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79);
  333. ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
  334. }
  335. void sha1_compression_states(uint32_t ihv[5], const uint32_t m[16], uint32_t W[80], uint32_t states[80][5])
  336. {
  337. uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4];
  338. uint32_t temp;
  339. #ifdef DOSTORESTATE00
  340. SHA1_STORE_STATE(0)
  341. #endif
  342. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 0, temp);
  343. #ifdef DOSTORESTATE01
  344. SHA1_STORE_STATE(1)
  345. #endif
  346. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 1, temp);
  347. #ifdef DOSTORESTATE02
  348. SHA1_STORE_STATE(2)
  349. #endif
  350. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 2, temp);
  351. #ifdef DOSTORESTATE03
  352. SHA1_STORE_STATE(3)
  353. #endif
  354. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 3, temp);
  355. #ifdef DOSTORESTATE04
  356. SHA1_STORE_STATE(4)
  357. #endif
  358. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 4, temp);
  359. #ifdef DOSTORESTATE05
  360. SHA1_STORE_STATE(5)
  361. #endif
  362. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 5, temp);
  363. #ifdef DOSTORESTATE06
  364. SHA1_STORE_STATE(6)
  365. #endif
  366. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 6, temp);
  367. #ifdef DOSTORESTATE07
  368. SHA1_STORE_STATE(7)
  369. #endif
  370. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 7, temp);
  371. #ifdef DOSTORESTATE08
  372. SHA1_STORE_STATE(8)
  373. #endif
  374. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 8, temp);
  375. #ifdef DOSTORESTATE09
  376. SHA1_STORE_STATE(9)
  377. #endif
  378. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 9, temp);
  379. #ifdef DOSTORESTATE10
  380. SHA1_STORE_STATE(10)
  381. #endif
  382. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 10, temp);
  383. #ifdef DOSTORESTATE11
  384. SHA1_STORE_STATE(11)
  385. #endif
  386. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 11, temp);
  387. #ifdef DOSTORESTATE12
  388. SHA1_STORE_STATE(12)
  389. #endif
  390. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 12, temp);
  391. #ifdef DOSTORESTATE13
  392. SHA1_STORE_STATE(13)
  393. #endif
  394. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 13, temp);
  395. #ifdef DOSTORESTATE14
  396. SHA1_STORE_STATE(14)
  397. #endif
  398. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 14, temp);
  399. #ifdef DOSTORESTATE15
  400. SHA1_STORE_STATE(15)
  401. #endif
  402. SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 15, temp);
  403. #ifdef DOSTORESTATE16
  404. SHA1_STORE_STATE(16)
  405. #endif
  406. SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(e, a, b, c, d, W, 16, temp);
  407. #ifdef DOSTORESTATE17
  408. SHA1_STORE_STATE(17)
  409. #endif
  410. SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(d, e, a, b, c, W, 17, temp);
  411. #ifdef DOSTORESTATE18
  412. SHA1_STORE_STATE(18)
  413. #endif
  414. SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(c, d, e, a, b, W, 18, temp);
  415. #ifdef DOSTORESTATE19
  416. SHA1_STORE_STATE(19)
  417. #endif
  418. SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(b, c, d, e, a, W, 19, temp);
  419. #ifdef DOSTORESTATE20
  420. SHA1_STORE_STATE(20)
  421. #endif
  422. SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 20, temp);
  423. #ifdef DOSTORESTATE21
  424. SHA1_STORE_STATE(21)
  425. #endif
  426. SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 21, temp);
  427. #ifdef DOSTORESTATE22
  428. SHA1_STORE_STATE(22)
  429. #endif
  430. SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 22, temp);
  431. #ifdef DOSTORESTATE23
  432. SHA1_STORE_STATE(23)
  433. #endif
  434. SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 23, temp);
  435. #ifdef DOSTORESTATE24
  436. SHA1_STORE_STATE(24)
  437. #endif
  438. SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 24, temp);
  439. #ifdef DOSTORESTATE25
  440. SHA1_STORE_STATE(25)
  441. #endif
  442. SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 25, temp);
  443. #ifdef DOSTORESTATE26
  444. SHA1_STORE_STATE(26)
  445. #endif
  446. SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 26, temp);
  447. #ifdef DOSTORESTATE27
  448. SHA1_STORE_STATE(27)
  449. #endif
  450. SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 27, temp);
  451. #ifdef DOSTORESTATE28
  452. SHA1_STORE_STATE(28)
  453. #endif
  454. SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 28, temp);
  455. #ifdef DOSTORESTATE29
  456. SHA1_STORE_STATE(29)
  457. #endif
  458. SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 29, temp);
  459. #ifdef DOSTORESTATE30
  460. SHA1_STORE_STATE(30)
  461. #endif
  462. SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 30, temp);
  463. #ifdef DOSTORESTATE31
  464. SHA1_STORE_STATE(31)
  465. #endif
  466. SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 31, temp);
  467. #ifdef DOSTORESTATE32
  468. SHA1_STORE_STATE(32)
  469. #endif
  470. SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 32, temp);
  471. #ifdef DOSTORESTATE33
  472. SHA1_STORE_STATE(33)
  473. #endif
  474. SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 33, temp);
  475. #ifdef DOSTORESTATE34
  476. SHA1_STORE_STATE(34)
  477. #endif
  478. SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 34, temp);
  479. #ifdef DOSTORESTATE35
  480. SHA1_STORE_STATE(35)
  481. #endif
  482. SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 35, temp);
  483. #ifdef DOSTORESTATE36
  484. SHA1_STORE_STATE(36)
  485. #endif
  486. SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 36, temp);
  487. #ifdef DOSTORESTATE37
  488. SHA1_STORE_STATE(37)
  489. #endif
  490. SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 37, temp);
  491. #ifdef DOSTORESTATE38
  492. SHA1_STORE_STATE(38)
  493. #endif
  494. SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 38, temp);
  495. #ifdef DOSTORESTATE39
  496. SHA1_STORE_STATE(39)
  497. #endif
  498. SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 39, temp);
  499. #ifdef DOSTORESTATE40
  500. SHA1_STORE_STATE(40)
  501. #endif
  502. SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 40, temp);
  503. #ifdef DOSTORESTATE41
  504. SHA1_STORE_STATE(41)
  505. #endif
  506. SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 41, temp);
  507. #ifdef DOSTORESTATE42
  508. SHA1_STORE_STATE(42)
  509. #endif
  510. SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 42, temp);
  511. #ifdef DOSTORESTATE43
  512. SHA1_STORE_STATE(43)
  513. #endif
  514. SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 43, temp);
  515. #ifdef DOSTORESTATE44
  516. SHA1_STORE_STATE(44)
  517. #endif
  518. SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 44, temp);
  519. #ifdef DOSTORESTATE45
  520. SHA1_STORE_STATE(45)
  521. #endif
  522. SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 45, temp);
  523. #ifdef DOSTORESTATE46
  524. SHA1_STORE_STATE(46)
  525. #endif
  526. SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 46, temp);
  527. #ifdef DOSTORESTATE47
  528. SHA1_STORE_STATE(47)
  529. #endif
  530. SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 47, temp);
  531. #ifdef DOSTORESTATE48
  532. SHA1_STORE_STATE(48)
  533. #endif
  534. SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 48, temp);
  535. #ifdef DOSTORESTATE49
  536. SHA1_STORE_STATE(49)
  537. #endif
  538. SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 49, temp);
  539. #ifdef DOSTORESTATE50
  540. SHA1_STORE_STATE(50)
  541. #endif
  542. SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 50, temp);
  543. #ifdef DOSTORESTATE51
  544. SHA1_STORE_STATE(51)
  545. #endif
  546. SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 51, temp);
  547. #ifdef DOSTORESTATE52
  548. SHA1_STORE_STATE(52)
  549. #endif
  550. SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 52, temp);
  551. #ifdef DOSTORESTATE53
  552. SHA1_STORE_STATE(53)
  553. #endif
  554. SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 53, temp);
  555. #ifdef DOSTORESTATE54
  556. SHA1_STORE_STATE(54)
  557. #endif
  558. SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 54, temp);
  559. #ifdef DOSTORESTATE55
  560. SHA1_STORE_STATE(55)
  561. #endif
  562. SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 55, temp);
  563. #ifdef DOSTORESTATE56
  564. SHA1_STORE_STATE(56)
  565. #endif
  566. SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 56, temp);
  567. #ifdef DOSTORESTATE57
  568. SHA1_STORE_STATE(57)
  569. #endif
  570. SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 57, temp);
  571. #ifdef DOSTORESTATE58
  572. SHA1_STORE_STATE(58)
  573. #endif
  574. SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 58, temp);
  575. #ifdef DOSTORESTATE59
  576. SHA1_STORE_STATE(59)
  577. #endif
  578. SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 59, temp);
  579. #ifdef DOSTORESTATE60
  580. SHA1_STORE_STATE(60)
  581. #endif
  582. SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 60, temp);
  583. #ifdef DOSTORESTATE61
  584. SHA1_STORE_STATE(61)
  585. #endif
  586. SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 61, temp);
  587. #ifdef DOSTORESTATE62
  588. SHA1_STORE_STATE(62)
  589. #endif
  590. SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 62, temp);
  591. #ifdef DOSTORESTATE63
  592. SHA1_STORE_STATE(63)
  593. #endif
  594. SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 63, temp);
  595. #ifdef DOSTORESTATE64
  596. SHA1_STORE_STATE(64)
  597. #endif
  598. SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 64, temp);
  599. #ifdef DOSTORESTATE65
  600. SHA1_STORE_STATE(65)
  601. #endif
  602. SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 65, temp);
  603. #ifdef DOSTORESTATE66
  604. SHA1_STORE_STATE(66)
  605. #endif
  606. SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 66, temp);
  607. #ifdef DOSTORESTATE67
  608. SHA1_STORE_STATE(67)
  609. #endif
  610. SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 67, temp);
  611. #ifdef DOSTORESTATE68
  612. SHA1_STORE_STATE(68)
  613. #endif
  614. SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 68, temp);
  615. #ifdef DOSTORESTATE69
  616. SHA1_STORE_STATE(69)
  617. #endif
  618. SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 69, temp);
  619. #ifdef DOSTORESTATE70
  620. SHA1_STORE_STATE(70)
  621. #endif
  622. SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 70, temp);
  623. #ifdef DOSTORESTATE71
  624. SHA1_STORE_STATE(71)
  625. #endif
  626. SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 71, temp);
  627. #ifdef DOSTORESTATE72
  628. SHA1_STORE_STATE(72)
  629. #endif
  630. SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 72, temp);
  631. #ifdef DOSTORESTATE73
  632. SHA1_STORE_STATE(73)
  633. #endif
  634. SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 73, temp);
  635. #ifdef DOSTORESTATE74
  636. SHA1_STORE_STATE(74)
  637. #endif
  638. SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 74, temp);
  639. #ifdef DOSTORESTATE75
  640. SHA1_STORE_STATE(75)
  641. #endif
  642. SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 75, temp);
  643. #ifdef DOSTORESTATE76
  644. SHA1_STORE_STATE(76)
  645. #endif
  646. SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 76, temp);
  647. #ifdef DOSTORESTATE77
  648. SHA1_STORE_STATE(77)
  649. #endif
  650. SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 77, temp);
  651. #ifdef DOSTORESTATE78
  652. SHA1_STORE_STATE(78)
  653. #endif
  654. SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 78, temp);
  655. #ifdef DOSTORESTATE79
  656. SHA1_STORE_STATE(79)
  657. #endif
  658. SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 79, temp);
  659. ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e;
  660. }
  661. #define SHA1_RECOMPRESS(t) \
  662. static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) \
  663. { \
  664. uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; \
  665. if (t > 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 79); \
  666. if (t > 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 78); \
  667. if (t > 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 77); \
  668. if (t > 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 76); \
  669. if (t > 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 75); \
  670. if (t > 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 74); \
  671. if (t > 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 73); \
  672. if (t > 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 72); \
  673. if (t > 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 71); \
  674. if (t > 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 70); \
  675. if (t > 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 69); \
  676. if (t > 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 68); \
  677. if (t > 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 67); \
  678. if (t > 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 66); \
  679. if (t > 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 65); \
  680. if (t > 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 64); \
  681. if (t > 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 63); \
  682. if (t > 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 62); \
  683. if (t > 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 61); \
  684. if (t > 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 60); \
  685. if (t > 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 59); \
  686. if (t > 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 58); \
  687. if (t > 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 57); \
  688. if (t > 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 56); \
  689. if (t > 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 55); \
  690. if (t > 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 54); \
  691. if (t > 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 53); \
  692. if (t > 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 52); \
  693. if (t > 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 51); \
  694. if (t > 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 50); \
  695. if (t > 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 49); \
  696. if (t > 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 48); \
  697. if (t > 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 47); \
  698. if (t > 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 46); \
  699. if (t > 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 45); \
  700. if (t > 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 44); \
  701. if (t > 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 43); \
  702. if (t > 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 42); \
  703. if (t > 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 41); \
  704. if (t > 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 40); \
  705. if (t > 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 39); \
  706. if (t > 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 38); \
  707. if (t > 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 37); \
  708. if (t > 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 36); \
  709. if (t > 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 35); \
  710. if (t > 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 34); \
  711. if (t > 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 33); \
  712. if (t > 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 32); \
  713. if (t > 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 31); \
  714. if (t > 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 30); \
  715. if (t > 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 29); \
  716. if (t > 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 28); \
  717. if (t > 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 27); \
  718. if (t > 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 26); \
  719. if (t > 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 25); \
  720. if (t > 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 24); \
  721. if (t > 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 23); \
  722. if (t > 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 22); \
  723. if (t > 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 21); \
  724. if (t > 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 20); \
  725. if (t > 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 19); \
  726. if (t > 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 18); \
  727. if (t > 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 17); \
  728. if (t > 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 16); \
  729. if (t > 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 15); \
  730. if (t > 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 14); \
  731. if (t > 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 13); \
  732. if (t > 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 12); \
  733. if (t > 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 11); \
  734. if (t > 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 10); \
  735. if (t > 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 9); \
  736. if (t > 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 8); \
  737. if (t > 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 7); \
  738. if (t > 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 6); \
  739. if (t > 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 5); \
  740. if (t > 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 4); \
  741. if (t > 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 3); \
  742. if (t > 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 2); \
  743. if (t > 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 1); \
  744. if (t > 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 0); \
  745. ihvin[0] = a; ihvin[1] = b; ihvin[2] = c; ihvin[3] = d; ihvin[4] = e; \
  746. a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; \
  747. if (t <= 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 0); \
  748. if (t <= 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 1); \
  749. if (t <= 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 2); \
  750. if (t <= 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 3); \
  751. if (t <= 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 4); \
  752. if (t <= 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 5); \
  753. if (t <= 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 6); \
  754. if (t <= 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 7); \
  755. if (t <= 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 8); \
  756. if (t <= 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 9); \
  757. if (t <= 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 10); \
  758. if (t <= 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 11); \
  759. if (t <= 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 12); \
  760. if (t <= 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 13); \
  761. if (t <= 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 14); \
  762. if (t <= 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 15); \
  763. if (t <= 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 16); \
  764. if (t <= 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 17); \
  765. if (t <= 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 18); \
  766. if (t <= 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 19); \
  767. if (t <= 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 20); \
  768. if (t <= 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 21); \
  769. if (t <= 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 22); \
  770. if (t <= 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 23); \
  771. if (t <= 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 24); \
  772. if (t <= 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 25); \
  773. if (t <= 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 26); \
  774. if (t <= 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 27); \
  775. if (t <= 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 28); \
  776. if (t <= 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 29); \
  777. if (t <= 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 30); \
  778. if (t <= 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 31); \
  779. if (t <= 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 32); \
  780. if (t <= 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 33); \
  781. if (t <= 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 34); \
  782. if (t <= 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 35); \
  783. if (t <= 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 36); \
  784. if (t <= 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 37); \
  785. if (t <= 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 38); \
  786. if (t <= 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 39); \
  787. if (t <= 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 40); \
  788. if (t <= 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 41); \
  789. if (t <= 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 42); \
  790. if (t <= 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 43); \
  791. if (t <= 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 44); \
  792. if (t <= 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 45); \
  793. if (t <= 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 46); \
  794. if (t <= 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 47); \
  795. if (t <= 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 48); \
  796. if (t <= 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 49); \
  797. if (t <= 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 50); \
  798. if (t <= 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 51); \
  799. if (t <= 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 52); \
  800. if (t <= 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 53); \
  801. if (t <= 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 54); \
  802. if (t <= 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 55); \
  803. if (t <= 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 56); \
  804. if (t <= 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 57); \
  805. if (t <= 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 58); \
  806. if (t <= 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 59); \
  807. if (t <= 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 60); \
  808. if (t <= 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 61); \
  809. if (t <= 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 62); \
  810. if (t <= 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 63); \
  811. if (t <= 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 64); \
  812. if (t <= 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 65); \
  813. if (t <= 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 66); \
  814. if (t <= 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 67); \
  815. if (t <= 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 68); \
  816. if (t <= 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 69); \
  817. if (t <= 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 70); \
  818. if (t <= 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 71); \
  819. if (t <= 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 72); \
  820. if (t <= 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 73); \
  821. if (t <= 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 74); \
  822. if (t <= 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 75); \
  823. if (t <= 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 76); \
  824. if (t <= 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 77); \
  825. if (t <= 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \
  826. if (t <= 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \
  827. 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; \
  828. }
  829. #ifdef _MSC_VER
  830. #pragma warning(push)
  831. #pragma warning(disable: 4127) /* Compiler complains about the checks in the above macro being constant. */
  832. #endif
  833. #ifdef DOSTORESTATE0
  834. SHA1_RECOMPRESS(0)
  835. #endif
  836. #ifdef DOSTORESTATE1
  837. SHA1_RECOMPRESS(1)
  838. #endif
  839. #ifdef DOSTORESTATE2
  840. SHA1_RECOMPRESS(2)
  841. #endif
  842. #ifdef DOSTORESTATE3
  843. SHA1_RECOMPRESS(3)
  844. #endif
  845. #ifdef DOSTORESTATE4
  846. SHA1_RECOMPRESS(4)
  847. #endif
  848. #ifdef DOSTORESTATE5
  849. SHA1_RECOMPRESS(5)
  850. #endif
  851. #ifdef DOSTORESTATE6
  852. SHA1_RECOMPRESS(6)
  853. #endif
  854. #ifdef DOSTORESTATE7
  855. SHA1_RECOMPRESS(7)
  856. #endif
  857. #ifdef DOSTORESTATE8
  858. SHA1_RECOMPRESS(8)
  859. #endif
  860. #ifdef DOSTORESTATE9
  861. SHA1_RECOMPRESS(9)
  862. #endif
  863. #ifdef DOSTORESTATE10
  864. SHA1_RECOMPRESS(10)
  865. #endif
  866. #ifdef DOSTORESTATE11
  867. SHA1_RECOMPRESS(11)
  868. #endif
  869. #ifdef DOSTORESTATE12
  870. SHA1_RECOMPRESS(12)
  871. #endif
  872. #ifdef DOSTORESTATE13
  873. SHA1_RECOMPRESS(13)
  874. #endif
  875. #ifdef DOSTORESTATE14
  876. SHA1_RECOMPRESS(14)
  877. #endif
  878. #ifdef DOSTORESTATE15
  879. SHA1_RECOMPRESS(15)
  880. #endif
  881. #ifdef DOSTORESTATE16
  882. SHA1_RECOMPRESS(16)
  883. #endif
  884. #ifdef DOSTORESTATE17
  885. SHA1_RECOMPRESS(17)
  886. #endif
  887. #ifdef DOSTORESTATE18
  888. SHA1_RECOMPRESS(18)
  889. #endif
  890. #ifdef DOSTORESTATE19
  891. SHA1_RECOMPRESS(19)
  892. #endif
  893. #ifdef DOSTORESTATE20
  894. SHA1_RECOMPRESS(20)
  895. #endif
  896. #ifdef DOSTORESTATE21
  897. SHA1_RECOMPRESS(21)
  898. #endif
  899. #ifdef DOSTORESTATE22
  900. SHA1_RECOMPRESS(22)
  901. #endif
  902. #ifdef DOSTORESTATE23
  903. SHA1_RECOMPRESS(23)
  904. #endif
  905. #ifdef DOSTORESTATE24
  906. SHA1_RECOMPRESS(24)
  907. #endif
  908. #ifdef DOSTORESTATE25
  909. SHA1_RECOMPRESS(25)
  910. #endif
  911. #ifdef DOSTORESTATE26
  912. SHA1_RECOMPRESS(26)
  913. #endif
  914. #ifdef DOSTORESTATE27
  915. SHA1_RECOMPRESS(27)
  916. #endif
  917. #ifdef DOSTORESTATE28
  918. SHA1_RECOMPRESS(28)
  919. #endif
  920. #ifdef DOSTORESTATE29
  921. SHA1_RECOMPRESS(29)
  922. #endif
  923. #ifdef DOSTORESTATE30
  924. SHA1_RECOMPRESS(30)
  925. #endif
  926. #ifdef DOSTORESTATE31
  927. SHA1_RECOMPRESS(31)
  928. #endif
  929. #ifdef DOSTORESTATE32
  930. SHA1_RECOMPRESS(32)
  931. #endif
  932. #ifdef DOSTORESTATE33
  933. SHA1_RECOMPRESS(33)
  934. #endif
  935. #ifdef DOSTORESTATE34
  936. SHA1_RECOMPRESS(34)
  937. #endif
  938. #ifdef DOSTORESTATE35
  939. SHA1_RECOMPRESS(35)
  940. #endif
  941. #ifdef DOSTORESTATE36
  942. SHA1_RECOMPRESS(36)
  943. #endif
  944. #ifdef DOSTORESTATE37
  945. SHA1_RECOMPRESS(37)
  946. #endif
  947. #ifdef DOSTORESTATE38
  948. SHA1_RECOMPRESS(38)
  949. #endif
  950. #ifdef DOSTORESTATE39
  951. SHA1_RECOMPRESS(39)
  952. #endif
  953. #ifdef DOSTORESTATE40
  954. SHA1_RECOMPRESS(40)
  955. #endif
  956. #ifdef DOSTORESTATE41
  957. SHA1_RECOMPRESS(41)
  958. #endif
  959. #ifdef DOSTORESTATE42
  960. SHA1_RECOMPRESS(42)
  961. #endif
  962. #ifdef DOSTORESTATE43
  963. SHA1_RECOMPRESS(43)
  964. #endif
  965. #ifdef DOSTORESTATE44
  966. SHA1_RECOMPRESS(44)
  967. #endif
  968. #ifdef DOSTORESTATE45
  969. SHA1_RECOMPRESS(45)
  970. #endif
  971. #ifdef DOSTORESTATE46
  972. SHA1_RECOMPRESS(46)
  973. #endif
  974. #ifdef DOSTORESTATE47
  975. SHA1_RECOMPRESS(47)
  976. #endif
  977. #ifdef DOSTORESTATE48
  978. SHA1_RECOMPRESS(48)
  979. #endif
  980. #ifdef DOSTORESTATE49
  981. SHA1_RECOMPRESS(49)
  982. #endif
  983. #ifdef DOSTORESTATE50
  984. SHA1_RECOMPRESS(50)
  985. #endif
  986. #ifdef DOSTORESTATE51
  987. SHA1_RECOMPRESS(51)
  988. #endif
  989. #ifdef DOSTORESTATE52
  990. SHA1_RECOMPRESS(52)
  991. #endif
  992. #ifdef DOSTORESTATE53
  993. SHA1_RECOMPRESS(53)
  994. #endif
  995. #ifdef DOSTORESTATE54
  996. SHA1_RECOMPRESS(54)
  997. #endif
  998. #ifdef DOSTORESTATE55
  999. SHA1_RECOMPRESS(55)
  1000. #endif
  1001. #ifdef DOSTORESTATE56
  1002. SHA1_RECOMPRESS(56)
  1003. #endif
  1004. #ifdef DOSTORESTATE57
  1005. SHA1_RECOMPRESS(57)
  1006. #endif
  1007. #ifdef DOSTORESTATE58
  1008. SHA1_RECOMPRESS(58)
  1009. #endif
  1010. #ifdef DOSTORESTATE59
  1011. SHA1_RECOMPRESS(59)
  1012. #endif
  1013. #ifdef DOSTORESTATE60
  1014. SHA1_RECOMPRESS(60)
  1015. #endif
  1016. #ifdef DOSTORESTATE61
  1017. SHA1_RECOMPRESS(61)
  1018. #endif
  1019. #ifdef DOSTORESTATE62
  1020. SHA1_RECOMPRESS(62)
  1021. #endif
  1022. #ifdef DOSTORESTATE63
  1023. SHA1_RECOMPRESS(63)
  1024. #endif
  1025. #ifdef DOSTORESTATE64
  1026. SHA1_RECOMPRESS(64)
  1027. #endif
  1028. #ifdef DOSTORESTATE65
  1029. SHA1_RECOMPRESS(65)
  1030. #endif
  1031. #ifdef DOSTORESTATE66
  1032. SHA1_RECOMPRESS(66)
  1033. #endif
  1034. #ifdef DOSTORESTATE67
  1035. SHA1_RECOMPRESS(67)
  1036. #endif
  1037. #ifdef DOSTORESTATE68
  1038. SHA1_RECOMPRESS(68)
  1039. #endif
  1040. #ifdef DOSTORESTATE69
  1041. SHA1_RECOMPRESS(69)
  1042. #endif
  1043. #ifdef DOSTORESTATE70
  1044. SHA1_RECOMPRESS(70)
  1045. #endif
  1046. #ifdef DOSTORESTATE71
  1047. SHA1_RECOMPRESS(71)
  1048. #endif
  1049. #ifdef DOSTORESTATE72
  1050. SHA1_RECOMPRESS(72)
  1051. #endif
  1052. #ifdef DOSTORESTATE73
  1053. SHA1_RECOMPRESS(73)
  1054. #endif
  1055. #ifdef DOSTORESTATE74
  1056. SHA1_RECOMPRESS(74)
  1057. #endif
  1058. #ifdef DOSTORESTATE75
  1059. SHA1_RECOMPRESS(75)
  1060. #endif
  1061. #ifdef DOSTORESTATE76
  1062. SHA1_RECOMPRESS(76)
  1063. #endif
  1064. #ifdef DOSTORESTATE77
  1065. SHA1_RECOMPRESS(77)
  1066. #endif
  1067. #ifdef DOSTORESTATE78
  1068. SHA1_RECOMPRESS(78)
  1069. #endif
  1070. #ifdef DOSTORESTATE79
  1071. SHA1_RECOMPRESS(79)
  1072. #endif
  1073. #ifdef _MSC_VER
  1074. #pragma warning(pop)
  1075. #endif
  1076. 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])
  1077. {
  1078. switch (step)
  1079. {
  1080. #ifdef DOSTORESTATE0
  1081. case 0:
  1082. sha1recompress_fast_0(ihvin, ihvout, me2, state);
  1083. break;
  1084. #endif
  1085. #ifdef DOSTORESTATE1
  1086. case 1:
  1087. sha1recompress_fast_1(ihvin, ihvout, me2, state);
  1088. break;
  1089. #endif
  1090. #ifdef DOSTORESTATE2
  1091. case 2:
  1092. sha1recompress_fast_2(ihvin, ihvout, me2, state);
  1093. break;
  1094. #endif
  1095. #ifdef DOSTORESTATE3
  1096. case 3:
  1097. sha1recompress_fast_3(ihvin, ihvout, me2, state);
  1098. break;
  1099. #endif
  1100. #ifdef DOSTORESTATE4
  1101. case 4:
  1102. sha1recompress_fast_4(ihvin, ihvout, me2, state);
  1103. break;
  1104. #endif
  1105. #ifdef DOSTORESTATE5
  1106. case 5:
  1107. sha1recompress_fast_5(ihvin, ihvout, me2, state);
  1108. break;
  1109. #endif
  1110. #ifdef DOSTORESTATE6
  1111. case 6:
  1112. sha1recompress_fast_6(ihvin, ihvout, me2, state);
  1113. break;
  1114. #endif
  1115. #ifdef DOSTORESTATE7
  1116. case 7:
  1117. sha1recompress_fast_7(ihvin, ihvout, me2, state);
  1118. break;
  1119. #endif
  1120. #ifdef DOSTORESTATE8
  1121. case 8:
  1122. sha1recompress_fast_8(ihvin, ihvout, me2, state);
  1123. break;
  1124. #endif
  1125. #ifdef DOSTORESTATE9
  1126. case 9:
  1127. sha1recompress_fast_9(ihvin, ihvout, me2, state);
  1128. break;
  1129. #endif
  1130. #ifdef DOSTORESTATE10
  1131. case 10:
  1132. sha1recompress_fast_10(ihvin, ihvout, me2, state);
  1133. break;
  1134. #endif
  1135. #ifdef DOSTORESTATE11
  1136. case 11:
  1137. sha1recompress_fast_11(ihvin, ihvout, me2, state);
  1138. break;
  1139. #endif
  1140. #ifdef DOSTORESTATE12
  1141. case 12:
  1142. sha1recompress_fast_12(ihvin, ihvout, me2, state);
  1143. break;
  1144. #endif
  1145. #ifdef DOSTORESTATE13
  1146. case 13:
  1147. sha1recompress_fast_13(ihvin, ihvout, me2, state);
  1148. break;
  1149. #endif
  1150. #ifdef DOSTORESTATE14
  1151. case 14:
  1152. sha1recompress_fast_14(ihvin, ihvout, me2, state);
  1153. break;
  1154. #endif
  1155. #ifdef DOSTORESTATE15
  1156. case 15:
  1157. sha1recompress_fast_15(ihvin, ihvout, me2, state);
  1158. break;
  1159. #endif
  1160. #ifdef DOSTORESTATE16
  1161. case 16:
  1162. sha1recompress_fast_16(ihvin, ihvout, me2, state);
  1163. break;
  1164. #endif
  1165. #ifdef DOSTORESTATE17
  1166. case 17:
  1167. sha1recompress_fast_17(ihvin, ihvout, me2, state);
  1168. break;
  1169. #endif
  1170. #ifdef DOSTORESTATE18
  1171. case 18:
  1172. sha1recompress_fast_18(ihvin, ihvout, me2, state);
  1173. break;
  1174. #endif
  1175. #ifdef DOSTORESTATE19
  1176. case 19:
  1177. sha1recompress_fast_19(ihvin, ihvout, me2, state);
  1178. break;
  1179. #endif
  1180. #ifdef DOSTORESTATE20
  1181. case 20:
  1182. sha1recompress_fast_20(ihvin, ihvout, me2, state);
  1183. break;
  1184. #endif
  1185. #ifdef DOSTORESTATE21
  1186. case 21:
  1187. sha1recompress_fast_21(ihvin, ihvout, me2, state);
  1188. break;
  1189. #endif
  1190. #ifdef DOSTORESTATE22
  1191. case 22:
  1192. sha1recompress_fast_22(ihvin, ihvout, me2, state);
  1193. break;
  1194. #endif
  1195. #ifdef DOSTORESTATE23
  1196. case 23:
  1197. sha1recompress_fast_23(ihvin, ihvout, me2, state);
  1198. break;
  1199. #endif
  1200. #ifdef DOSTORESTATE24
  1201. case 24:
  1202. sha1recompress_fast_24(ihvin, ihvout, me2, state);
  1203. break;
  1204. #endif
  1205. #ifdef DOSTORESTATE25
  1206. case 25:
  1207. sha1recompress_fast_25(ihvin, ihvout, me2, state);
  1208. break;
  1209. #endif
  1210. #ifdef DOSTORESTATE26
  1211. case 26:
  1212. sha1recompress_fast_26(ihvin, ihvout, me2, state);
  1213. break;
  1214. #endif
  1215. #ifdef DOSTORESTATE27
  1216. case 27:
  1217. sha1recompress_fast_27(ihvin, ihvout, me2, state);
  1218. break;
  1219. #endif
  1220. #ifdef DOSTORESTATE28
  1221. case 28:
  1222. sha1recompress_fast_28(ihvin, ihvout, me2, state);
  1223. break;
  1224. #endif
  1225. #ifdef DOSTORESTATE29
  1226. case 29:
  1227. sha1recompress_fast_29(ihvin, ihvout, me2, state);
  1228. break;
  1229. #endif
  1230. #ifdef DOSTORESTATE30
  1231. case 30:
  1232. sha1recompress_fast_30(ihvin, ihvout, me2, state);
  1233. break;
  1234. #endif
  1235. #ifdef DOSTORESTATE31
  1236. case 31:
  1237. sha1recompress_fast_31(ihvin, ihvout, me2, state);
  1238. break;
  1239. #endif
  1240. #ifdef DOSTORESTATE32
  1241. case 32:
  1242. sha1recompress_fast_32(ihvin, ihvout, me2, state);
  1243. break;
  1244. #endif
  1245. #ifdef DOSTORESTATE33
  1246. case 33:
  1247. sha1recompress_fast_33(ihvin, ihvout, me2, state);
  1248. break;
  1249. #endif
  1250. #ifdef DOSTORESTATE34
  1251. case 34:
  1252. sha1recompress_fast_34(ihvin, ihvout, me2, state);
  1253. break;
  1254. #endif
  1255. #ifdef DOSTORESTATE35
  1256. case 35:
  1257. sha1recompress_fast_35(ihvin, ihvout, me2, state);
  1258. break;
  1259. #endif
  1260. #ifdef DOSTORESTATE36
  1261. case 36:
  1262. sha1recompress_fast_36(ihvin, ihvout, me2, state);
  1263. break;
  1264. #endif
  1265. #ifdef DOSTORESTATE37
  1266. case 37:
  1267. sha1recompress_fast_37(ihvin, ihvout, me2, state);
  1268. break;
  1269. #endif
  1270. #ifdef DOSTORESTATE38
  1271. case 38:
  1272. sha1recompress_fast_38(ihvin, ihvout, me2, state);
  1273. break;
  1274. #endif
  1275. #ifdef DOSTORESTATE39
  1276. case 39:
  1277. sha1recompress_fast_39(ihvin, ihvout, me2, state);
  1278. break;
  1279. #endif
  1280. #ifdef DOSTORESTATE40
  1281. case 40:
  1282. sha1recompress_fast_40(ihvin, ihvout, me2, state);
  1283. break;
  1284. #endif
  1285. #ifdef DOSTORESTATE41
  1286. case 41:
  1287. sha1recompress_fast_41(ihvin, ihvout, me2, state);
  1288. break;
  1289. #endif
  1290. #ifdef DOSTORESTATE42
  1291. case 42:
  1292. sha1recompress_fast_42(ihvin, ihvout, me2, state);
  1293. break;
  1294. #endif
  1295. #ifdef DOSTORESTATE43
  1296. case 43:
  1297. sha1recompress_fast_43(ihvin, ihvout, me2, state);
  1298. break;
  1299. #endif
  1300. #ifdef DOSTORESTATE44
  1301. case 44:
  1302. sha1recompress_fast_44(ihvin, ihvout, me2, state);
  1303. break;
  1304. #endif
  1305. #ifdef DOSTORESTATE45
  1306. case 45:
  1307. sha1recompress_fast_45(ihvin, ihvout, me2, state);
  1308. break;
  1309. #endif
  1310. #ifdef DOSTORESTATE46
  1311. case 46:
  1312. sha1recompress_fast_46(ihvin, ihvout, me2, state);
  1313. break;
  1314. #endif
  1315. #ifdef DOSTORESTATE47
  1316. case 47:
  1317. sha1recompress_fast_47(ihvin, ihvout, me2, state);
  1318. break;
  1319. #endif
  1320. #ifdef DOSTORESTATE48
  1321. case 48:
  1322. sha1recompress_fast_48(ihvin, ihvout, me2, state);
  1323. break;
  1324. #endif
  1325. #ifdef DOSTORESTATE49
  1326. case 49:
  1327. sha1recompress_fast_49(ihvin, ihvout, me2, state);
  1328. break;
  1329. #endif
  1330. #ifdef DOSTORESTATE50
  1331. case 50:
  1332. sha1recompress_fast_50(ihvin, ihvout, me2, state);
  1333. break;
  1334. #endif
  1335. #ifdef DOSTORESTATE51
  1336. case 51:
  1337. sha1recompress_fast_51(ihvin, ihvout, me2, state);
  1338. break;
  1339. #endif
  1340. #ifdef DOSTORESTATE52
  1341. case 52:
  1342. sha1recompress_fast_52(ihvin, ihvout, me2, state);
  1343. break;
  1344. #endif
  1345. #ifdef DOSTORESTATE53
  1346. case 53:
  1347. sha1recompress_fast_53(ihvin, ihvout, me2, state);
  1348. break;
  1349. #endif
  1350. #ifdef DOSTORESTATE54
  1351. case 54:
  1352. sha1recompress_fast_54(ihvin, ihvout, me2, state);
  1353. break;
  1354. #endif
  1355. #ifdef DOSTORESTATE55
  1356. case 55:
  1357. sha1recompress_fast_55(ihvin, ihvout, me2, st