sha3-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +7 -0
  6. data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact.vcproj +207 -0
  7. data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact8.vcproj +207 -0
  8. data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace.vcproj +203 -0
  9. data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace32BI.vcproj +201 -0
  10. data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized32.vcproj +267 -0
  11. data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized64.vcproj +267 -0
  12. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference.vcproj +243 -0
  13. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference32BI.vcproj +243 -0
  14. data/ext/sha3/KeccakReferenceAndOptimized/KeccakReferenceAndOptimized.sln +62 -0
  15. data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple.vcproj +203 -0
  16. data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple32BI.vcproj +201 -0
  17. data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.h +27 -0
  18. data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.s +285 -0
  19. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-settings.h +2 -0
  20. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-test.c +142 -0
  21. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.h +15 -0
  22. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.s +119 -0
  23. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.c +184 -0
  24. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.h +25 -0
  25. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-settings.h +3 -0
  26. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-test.c +317 -0
  27. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.c +341 -0
  28. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.h +50 -0
  29. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-settings.h +2 -0
  30. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-test.c +192 -0
  31. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.c +375 -0
  32. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.h +47 -0
  33. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +406 -0
  34. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-minimal-test.c +231 -0
  35. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-settings.h +3 -0
  36. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-test.c +221 -0
  37. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace.c +445 -0
  38. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv6M.s +844 -0
  39. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7A.s +687 -0
  40. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7M.s +687 -0
  41. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI.c +849 -0
  42. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-settings.h +3 -0
  43. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-test.c +221 -0
  44. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple.c +403 -0
  45. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple32BI.c +673 -0
  46. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.c +68 -0
  47. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.h +59 -0
  48. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-rvk.macros +555 -0
  49. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s1.macros +1187 -0
  50. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s2.macros +1187 -0
  51. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32.macros +26 -0
  52. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-64.macros +728 -0
  53. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-arm.c +123 -0
  54. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armcc.s +653 -0
  55. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armgcc.s +686 -0
  56. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8.c +163 -0
  57. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-compact.s +647 -0
  58. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-fast.s +934 -0
  59. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-inplace-armgcc-ARMv7A-NEON.s +446 -0
  60. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-int-set.h +6 -0
  61. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-interface.h +46 -0
  62. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32-settings.h +4 -0
  63. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32.c +524 -0
  64. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64-settings.h +7 -0
  65. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64.c +504 -0
  66. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.c +300 -0
  67. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.h +20 -0
  68. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.o +0 -0
  69. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference32BI.c +371 -0
  70. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd128.macros +651 -0
  71. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd64.macros +517 -0
  72. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-unrolling.macros +124 -0
  73. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-asm.c +62 -0
  74. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-gas.s +766 -0
  75. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-shld-gas.s +766 -0
  76. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-xop.macros +573 -0
  77. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.c +81 -0
  78. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.h +70 -0
  79. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.o +0 -0
  80. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.c +266 -0
  81. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.h +76 -0
  82. data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.o +0 -0
  83. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc1024-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +296 -0
  84. data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc512-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +429 -0
  85. data/ext/sha3/KeccakReferenceAndOptimized/Sources/brg_endian.h +142 -0
  86. data/ext/sha3/KeccakReferenceAndOptimized/Sources/crypto_hash.h +0 -0
  87. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.c +117 -0
  88. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.h +29 -0
  89. data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.o +0 -0
  90. data/ext/sha3/KeccakReferenceAndOptimized/Sources/genKAT.c +692 -0
  91. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainARM.c +88 -0
  92. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainOptimized.c +23 -0
  93. data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainReference.c +381 -0
  94. data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.c +436 -0
  95. data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.h +13 -0
  96. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation-config.h +2 -0
  97. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.c +572 -0
  98. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.h +38 -0
  99. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/KeccakF-1600-unrolling.macros +124 -0
  100. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.c +81 -0
  101. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.h +18 -0
  102. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.c +81 -0
  103. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.h +18 -0
  104. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/crypto_hash.h +0 -0
  105. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/mainOptimized.c +112 -0
  106. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.c +225 -0
  107. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.h +20 -0
  108. data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/makefile +68 -0
  109. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakCompact +0 -0
  110. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized32 +0 -0
  111. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized64 +0 -0
  112. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference +0 -0
  113. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference32BI +0 -0
  114. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple +0 -0
  115. data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple32BI +0 -0
  116. data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact-test.o +0 -0
  117. data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact.o +0 -0
  118. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakDuplex.o +0 -0
  119. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakF-1600-opt32.o +0 -0
  120. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakNISTInterface.o +0 -0
  121. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakSponge.o +0 -0
  122. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/genKAT.o +0 -0
  123. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/mainOptimized.o +0 -0
  124. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/timing.o +0 -0
  125. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakDuplex.o +0 -0
  126. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakF-1600-opt64.o +0 -0
  127. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakNISTInterface.o +0 -0
  128. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakSponge.o +0 -0
  129. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/genKAT.o +0 -0
  130. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/mainOptimized.o +0 -0
  131. data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/timing.o +0 -0
  132. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakDuplex.o +0 -0
  133. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakF-1600-reference.o +0 -0
  134. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakNISTInterface.o +0 -0
  135. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakSponge.o +0 -0
  136. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/displayIntermediateValues.o +0 -0
  137. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/genKAT.o +0 -0
  138. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/mainReference.o +0 -0
  139. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakDuplex.o +0 -0
  140. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakF-1600-reference32BI.o +0 -0
  141. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakNISTInterface.o +0 -0
  142. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakSponge.o +0 -0
  143. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/displayIntermediateValues.o +0 -0
  144. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/genKAT.o +0 -0
  145. data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/mainReference.o +0 -0
  146. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple-test.o +0 -0
  147. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple.o +0 -0
  148. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple-test.o +0 -0
  149. data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple32BI.o +0 -0
  150. data/ext/sha3/KeccakReferenceAndOptimized/compile64.bat +1 -0
  151. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccak +1 -0
  152. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc1024 +1 -0
  153. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256 +1 -0
  154. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256treed2 +1 -0
  155. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc448 +1 -0
  156. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512 +1 -0
  157. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512treed2 +1 -0
  158. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc768 +1 -0
  159. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccak.c +11 -0
  160. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc1024.c +11 -0
  161. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc256.c +11 -0
  162. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc448.c +11 -0
  163. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc512.c +11 -0
  164. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc768.c +11 -0
  165. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccak.h +1 -0
  166. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc1024.h +1 -0
  167. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc256.h +1 -0
  168. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc448.h +1 -0
  169. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc512.h +1 -0
  170. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc768.h +1 -0
  171. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/populate.py +506 -0
  172. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccak.h +2 -0
  173. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc1024.h +2 -0
  174. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc256.h +2 -0
  175. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc448.h +2 -0
  176. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc512.h +2 -0
  177. data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc768.h +2 -0
  178. data/ext/sha3/KeccakReferenceAndOptimized/makefile +327 -0
  179. data/ext/sha3/Makefile +240 -0
  180. data/ext/sha3/depend +28 -0
  181. data/ext/sha3/extconf.rb +21 -0
  182. data/ext/sha3/sha3.c +95 -0
  183. data/lib/sha3-ruby.rb +27 -0
  184. data/lib/sha3-ruby/version.rb +5 -0
  185. data/sha3-ruby.gemspec +21 -0
  186. metadata +233 -0
@@ -0,0 +1,572 @@
1
+ /*
2
+ The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3
+ Michaël Peeters and Gilles Van Assche. For more information, feedback or
4
+ questions, please refer to our website: http://keccak.noekeon.org/
5
+
6
+ Implementation by the designers,
7
+ hereby denoted as "the implementer".
8
+
9
+ To the extent possible under law, the implementer has waived all copyright
10
+ and related or neighboring rights to the source code in this file.
11
+ http://creativecommons.org/publicdomain/zero/1.0/
12
+ */
13
+
14
+ #include <stdio.h>
15
+ #include <stdlib.h>
16
+ #include <string.h>
17
+ #include <x86intrin.h>
18
+ #include "DoublePermutation.h"
19
+
20
+ #include "DoublePermutation-config.h"
21
+ #define UseSSE
22
+ #define UseOnlySIMD64
23
+
24
+ typedef unsigned char UINT8;
25
+ typedef unsigned long long int UINT64;
26
+
27
+ #if defined(UseSSE)
28
+ #define ANDnu128(a, b) _mm_andnot_si128(a, b)
29
+ #define CONST128(a) _mm_load_si128((const V128 *)&(a))
30
+ #define LOAD128(a) _mm_load_si128((const V128 *)&(a))
31
+ #define LOAD128u(a) _mm_loadu_si128((const V128 *)&(a))
32
+ #if defined(UseXOP)
33
+ #define ROL64in128(a, o) _mm_roti_epi64(a, o)
34
+ #define ROL64in128_8(a) ROL64in128(a, 8)
35
+ #define ROL64in128_56(a) ROL64in128(a, 56)
36
+ #else
37
+ #define ROL64in128(a, o) _mm_or_si128(_mm_slli_epi64(a, o), _mm_srli_epi64(a, 64-(o)))
38
+ #define ROL64in128_8(a) _mm_shuffle_epi8(a, CONST128(rho8))
39
+ #define ROL64in128_56(a) _mm_shuffle_epi8(a, CONST128(rho56))
40
+ const UINT64 rho8[2] = {0x0605040302010007, 0x0E0D0C0B0A09080F};
41
+ const UINT64 rho56[2] = {0x0007060504030201, 0x080F0E0D0C0B0A09};
42
+ #endif
43
+ #define STORE128(a, b) _mm_store_si128((V128 *)&(a), b)
44
+ #define XOR128(a, b) _mm_xor_si128(a, b)
45
+ #define XOReq128(a, b) a = _mm_xor_si128(a, b)
46
+ #define ZERO128() _mm_setzero_si128()
47
+ #endif
48
+
49
+ #define declareABCDE \
50
+ V128 Aba, Abe, Abi, Abo, Abu; \
51
+ V128 Aga, Age, Agi, Ago, Agu; \
52
+ V128 Aka, Ake, Aki, Ako, Aku; \
53
+ V128 Ama, Ame, Ami, Amo, Amu; \
54
+ V128 Asa, Ase, Asi, Aso, Asu; \
55
+ V128 Bba, Bbe, Bbi, Bbo, Bbu; \
56
+ V128 Bga, Bge, Bgi, Bgo, Bgu; \
57
+ V128 Bka, Bke, Bki, Bko, Bku; \
58
+ V128 Bma, Bme, Bmi, Bmo, Bmu; \
59
+ V128 Bsa, Bse, Bsi, Bso, Bsu; \
60
+ V128 Ca, Ce, Ci, Co, Cu; \
61
+ V128 Da, De, Di, Do, Du; \
62
+ V128 Eba, Ebe, Ebi, Ebo, Ebu; \
63
+ V128 Ega, Ege, Egi, Ego, Egu; \
64
+ V128 Eka, Eke, Eki, Eko, Eku; \
65
+ V128 Ema, Eme, Emi, Emo, Emu; \
66
+ V128 Esa, Ese, Esi, Eso, Esu; \
67
+
68
+ #define prepareTheta \
69
+ Ca = XOR128(Aba, XOR128(Aga, XOR128(Aka, XOR128(Ama, Asa)))); \
70
+ Ce = XOR128(Abe, XOR128(Age, XOR128(Ake, XOR128(Ame, Ase)))); \
71
+ Ci = XOR128(Abi, XOR128(Agi, XOR128(Aki, XOR128(Ami, Asi)))); \
72
+ Co = XOR128(Abo, XOR128(Ago, XOR128(Ako, XOR128(Amo, Aso)))); \
73
+ Cu = XOR128(Abu, XOR128(Agu, XOR128(Aku, XOR128(Amu, Asu)))); \
74
+
75
+ // --- Theta Rho Pi Chi Iota Prepare-theta
76
+ // --- 64-bit lanes mapped to 64-bit words
77
+ #define thetaRhoPiChiIotaPrepareTheta(i, A, E) \
78
+ Da = XOR128(Cu, ROL64in128(Ce, 1)); \
79
+ De = XOR128(Ca, ROL64in128(Ci, 1)); \
80
+ Di = XOR128(Ce, ROL64in128(Co, 1)); \
81
+ Do = XOR128(Ci, ROL64in128(Cu, 1)); \
82
+ Du = XOR128(Co, ROL64in128(Ca, 1)); \
83
+ \
84
+ XOReq128(A##ba, Da); \
85
+ Bba = A##ba; \
86
+ XOReq128(A##ge, De); \
87
+ Bbe = ROL64in128(A##ge, 44); \
88
+ XOReq128(A##ki, Di); \
89
+ Bbi = ROL64in128(A##ki, 43); \
90
+ E##ba = XOR128(Bba, ANDnu128(Bbe, Bbi)); \
91
+ XOReq128(E##ba, CONST128(KeccakF1600DoubleRoundConstants[(i)*2])); \
92
+ Ca = E##ba; \
93
+ XOReq128(A##mo, Do); \
94
+ Bbo = ROL64in128(A##mo, 21); \
95
+ E##be = XOR128(Bbe, ANDnu128(Bbi, Bbo)); \
96
+ Ce = E##be; \
97
+ XOReq128(A##su, Du); \
98
+ Bbu = ROL64in128(A##su, 14); \
99
+ E##bi = XOR128(Bbi, ANDnu128(Bbo, Bbu)); \
100
+ Ci = E##bi; \
101
+ E##bo = XOR128(Bbo, ANDnu128(Bbu, Bba)); \
102
+ Co = E##bo; \
103
+ E##bu = XOR128(Bbu, ANDnu128(Bba, Bbe)); \
104
+ Cu = E##bu; \
105
+ \
106
+ XOReq128(A##bo, Do); \
107
+ Bga = ROL64in128(A##bo, 28); \
108
+ XOReq128(A##gu, Du); \
109
+ Bge = ROL64in128(A##gu, 20); \
110
+ XOReq128(A##ka, Da); \
111
+ Bgi = ROL64in128(A##ka, 3); \
112
+ E##ga = XOR128(Bga, ANDnu128(Bge, Bgi)); \
113
+ XOReq128(Ca, E##ga); \
114
+ XOReq128(A##me, De); \
115
+ Bgo = ROL64in128(A##me, 45); \
116
+ E##ge = XOR128(Bge, ANDnu128(Bgi, Bgo)); \
117
+ XOReq128(Ce, E##ge); \
118
+ XOReq128(A##si, Di); \
119
+ Bgu = ROL64in128(A##si, 61); \
120
+ E##gi = XOR128(Bgi, ANDnu128(Bgo, Bgu)); \
121
+ XOReq128(Ci, E##gi); \
122
+ E##go = XOR128(Bgo, ANDnu128(Bgu, Bga)); \
123
+ XOReq128(Co, E##go); \
124
+ E##gu = XOR128(Bgu, ANDnu128(Bga, Bge)); \
125
+ XOReq128(Cu, E##gu); \
126
+ \
127
+ XOReq128(A##be, De); \
128
+ Bka = ROL64in128(A##be, 1); \
129
+ XOReq128(A##gi, Di); \
130
+ Bke = ROL64in128(A##gi, 6); \
131
+ XOReq128(A##ko, Do); \
132
+ Bki = ROL64in128(A##ko, 25); \
133
+ E##ka = XOR128(Bka, ANDnu128(Bke, Bki)); \
134
+ XOReq128(Ca, E##ka); \
135
+ XOReq128(A##mu, Du); \
136
+ Bko = ROL64in128_8(A##mu); \
137
+ E##ke = XOR128(Bke, ANDnu128(Bki, Bko)); \
138
+ XOReq128(Ce, E##ke); \
139
+ XOReq128(A##sa, Da); \
140
+ Bku = ROL64in128(A##sa, 18); \
141
+ E##ki = XOR128(Bki, ANDnu128(Bko, Bku)); \
142
+ XOReq128(Ci, E##ki); \
143
+ E##ko = XOR128(Bko, ANDnu128(Bku, Bka)); \
144
+ XOReq128(Co, E##ko); \
145
+ E##ku = XOR128(Bku, ANDnu128(Bka, Bke)); \
146
+ XOReq128(Cu, E##ku); \
147
+ \
148
+ XOReq128(A##bu, Du); \
149
+ Bma = ROL64in128(A##bu, 27); \
150
+ XOReq128(A##ga, Da); \
151
+ Bme = ROL64in128(A##ga, 36); \
152
+ XOReq128(A##ke, De); \
153
+ Bmi = ROL64in128(A##ke, 10); \
154
+ E##ma = XOR128(Bma, ANDnu128(Bme, Bmi)); \
155
+ XOReq128(Ca, E##ma); \
156
+ XOReq128(A##mi, Di); \
157
+ Bmo = ROL64in128(A##mi, 15); \
158
+ E##me = XOR128(Bme, ANDnu128(Bmi, Bmo)); \
159
+ XOReq128(Ce, E##me); \
160
+ XOReq128(A##so, Do); \
161
+ Bmu = ROL64in128_56(A##so); \
162
+ E##mi = XOR128(Bmi, ANDnu128(Bmo, Bmu)); \
163
+ XOReq128(Ci, E##mi); \
164
+ E##mo = XOR128(Bmo, ANDnu128(Bmu, Bma)); \
165
+ XOReq128(Co, E##mo); \
166
+ E##mu = XOR128(Bmu, ANDnu128(Bma, Bme)); \
167
+ XOReq128(Cu, E##mu); \
168
+ \
169
+ XOReq128(A##bi, Di); \
170
+ Bsa = ROL64in128(A##bi, 62); \
171
+ XOReq128(A##go, Do); \
172
+ Bse = ROL64in128(A##go, 55); \
173
+ XOReq128(A##ku, Du); \
174
+ Bsi = ROL64in128(A##ku, 39); \
175
+ E##sa = XOR128(Bsa, ANDnu128(Bse, Bsi)); \
176
+ XOReq128(Ca, E##sa); \
177
+ XOReq128(A##ma, Da); \
178
+ Bso = ROL64in128(A##ma, 41); \
179
+ E##se = XOR128(Bse, ANDnu128(Bsi, Bso)); \
180
+ XOReq128(Ce, E##se); \
181
+ XOReq128(A##se, De); \
182
+ Bsu = ROL64in128(A##se, 2); \
183
+ E##si = XOR128(Bsi, ANDnu128(Bso, Bsu)); \
184
+ XOReq128(Ci, E##si); \
185
+ E##so = XOR128(Bso, ANDnu128(Bsu, Bsa)); \
186
+ XOReq128(Co, E##so); \
187
+ E##su = XOR128(Bsu, ANDnu128(Bsa, Bse)); \
188
+ XOReq128(Cu, E##su); \
189
+ \
190
+
191
+ // --- Theta Rho Pi Chi Iota
192
+ // --- 64-bit lanes mapped to 64-bit words
193
+ #define thetaRhoPiChiIota(i, A, E) \
194
+ Da = XOR128(Cu, ROL64in128(Ce, 1)); \
195
+ De = XOR128(Ca, ROL64in128(Ci, 1)); \
196
+ Di = XOR128(Ce, ROL64in128(Co, 1)); \
197
+ Do = XOR128(Ci, ROL64in128(Cu, 1)); \
198
+ Du = XOR128(Co, ROL64in128(Ca, 1)); \
199
+ \
200
+ XOReq128(A##ba, Da); \
201
+ Bba = A##ba; \
202
+ XOReq128(A##ge, De); \
203
+ Bbe = ROL64in128(A##ge, 44); \
204
+ XOReq128(A##ki, Di); \
205
+ Bbi = ROL64in128(A##ki, 43); \
206
+ E##ba = XOR128(Bba, ANDnu128(Bbe, Bbi)); \
207
+ XOReq128(E##ba, CONST128(KeccakF1600DoubleRoundConstants[(i)*2])); \
208
+ XOReq128(A##mo, Do); \
209
+ Bbo = ROL64in128(A##mo, 21); \
210
+ E##be = XOR128(Bbe, ANDnu128(Bbi, Bbo)); \
211
+ XOReq128(A##su, Du); \
212
+ Bbu = ROL64in128(A##su, 14); \
213
+ E##bi = XOR128(Bbi, ANDnu128(Bbo, Bbu)); \
214
+ E##bo = XOR128(Bbo, ANDnu128(Bbu, Bba)); \
215
+ E##bu = XOR128(Bbu, ANDnu128(Bba, Bbe)); \
216
+ \
217
+ XOReq128(A##bo, Do); \
218
+ Bga = ROL64in128(A##bo, 28); \
219
+ XOReq128(A##gu, Du); \
220
+ Bge = ROL64in128(A##gu, 20); \
221
+ XOReq128(A##ka, Da); \
222
+ Bgi = ROL64in128(A##ka, 3); \
223
+ E##ga = XOR128(Bga, ANDnu128(Bge, Bgi)); \
224
+ XOReq128(A##me, De); \
225
+ Bgo = ROL64in128(A##me, 45); \
226
+ E##ge = XOR128(Bge, ANDnu128(Bgi, Bgo)); \
227
+ XOReq128(A##si, Di); \
228
+ Bgu = ROL64in128(A##si, 61); \
229
+ E##gi = XOR128(Bgi, ANDnu128(Bgo, Bgu)); \
230
+ E##go = XOR128(Bgo, ANDnu128(Bgu, Bga)); \
231
+ E##gu = XOR128(Bgu, ANDnu128(Bga, Bge)); \
232
+ \
233
+ XOReq128(A##be, De); \
234
+ Bka = ROL64in128(A##be, 1); \
235
+ XOReq128(A##gi, Di); \
236
+ Bke = ROL64in128(A##gi, 6); \
237
+ XOReq128(A##ko, Do); \
238
+ Bki = ROL64in128(A##ko, 25); \
239
+ E##ka = XOR128(Bka, ANDnu128(Bke, Bki)); \
240
+ XOReq128(A##mu, Du); \
241
+ Bko = ROL64in128_8(A##mu); \
242
+ E##ke = XOR128(Bke, ANDnu128(Bki, Bko)); \
243
+ XOReq128(A##sa, Da); \
244
+ Bku = ROL64in128(A##sa, 18); \
245
+ E##ki = XOR128(Bki, ANDnu128(Bko, Bku)); \
246
+ E##ko = XOR128(Bko, ANDnu128(Bku, Bka)); \
247
+ E##ku = XOR128(Bku, ANDnu128(Bka, Bke)); \
248
+ \
249
+ XOReq128(A##bu, Du); \
250
+ Bma = ROL64in128(A##bu, 27); \
251
+ XOReq128(A##ga, Da); \
252
+ Bme = ROL64in128(A##ga, 36); \
253
+ XOReq128(A##ke, De); \
254
+ Bmi = ROL64in128(A##ke, 10); \
255
+ E##ma = XOR128(Bma, ANDnu128(Bme, Bmi)); \
256
+ XOReq128(A##mi, Di); \
257
+ Bmo = ROL64in128(A##mi, 15); \
258
+ E##me = XOR128(Bme, ANDnu128(Bmi, Bmo)); \
259
+ XOReq128(A##so, Do); \
260
+ Bmu = ROL64in128_56(A##so); \
261
+ E##mi = XOR128(Bmi, ANDnu128(Bmo, Bmu)); \
262
+ E##mo = XOR128(Bmo, ANDnu128(Bmu, Bma)); \
263
+ E##mu = XOR128(Bmu, ANDnu128(Bma, Bme)); \
264
+ \
265
+ XOReq128(A##bi, Di); \
266
+ Bsa = ROL64in128(A##bi, 62); \
267
+ XOReq128(A##go, Do); \
268
+ Bse = ROL64in128(A##go, 55); \
269
+ XOReq128(A##ku, Du); \
270
+ Bsi = ROL64in128(A##ku, 39); \
271
+ E##sa = XOR128(Bsa, ANDnu128(Bse, Bsi)); \
272
+ XOReq128(A##ma, Da); \
273
+ Bso = ROL64in128(A##ma, 41); \
274
+ E##se = XOR128(Bse, ANDnu128(Bsi, Bso)); \
275
+ XOReq128(A##se, De); \
276
+ Bsu = ROL64in128(A##se, 2); \
277
+ E##si = XOR128(Bsi, ANDnu128(Bso, Bsu)); \
278
+ E##so = XOR128(Bso, ANDnu128(Bsu, Bsa)); \
279
+ E##su = XOR128(Bsu, ANDnu128(Bsa, Bse)); \
280
+ \
281
+
282
+ ALIGN const UINT64 KeccakF1600DoubleRoundConstants[48] = {
283
+ 0x0000000000000001ULL, 0x0000000000000001ULL,
284
+ 0x0000000000008082ULL, 0x0000000000008082ULL,
285
+ 0x800000000000808aULL, 0x800000000000808aULL,
286
+ 0x8000000080008000ULL, 0x8000000080008000ULL,
287
+ 0x000000000000808bULL, 0x000000000000808bULL,
288
+ 0x0000000080000001ULL, 0x0000000080000001ULL,
289
+ 0x8000000080008081ULL, 0x8000000080008081ULL,
290
+ 0x8000000000008009ULL, 0x8000000000008009ULL,
291
+ 0x000000000000008aULL, 0x000000000000008aULL,
292
+ 0x0000000000000088ULL, 0x0000000000000088ULL,
293
+ 0x0000000080008009ULL, 0x0000000080008009ULL,
294
+ 0x000000008000000aULL, 0x000000008000000aULL,
295
+ 0x000000008000808bULL, 0x000000008000808bULL,
296
+ 0x800000000000008bULL, 0x800000000000008bULL,
297
+ 0x8000000000008089ULL, 0x8000000000008089ULL,
298
+ 0x8000000000008003ULL, 0x8000000000008003ULL,
299
+ 0x8000000000008002ULL, 0x8000000000008002ULL,
300
+ 0x8000000000000080ULL, 0x8000000000000080ULL,
301
+ 0x000000000000800aULL, 0x000000000000800aULL,
302
+ 0x800000008000000aULL, 0x800000008000000aULL,
303
+ 0x8000000080008081ULL, 0x8000000080008081ULL,
304
+ 0x8000000000008080ULL, 0x8000000000008080ULL,
305
+ 0x0000000080000001ULL, 0x0000000080000001ULL,
306
+ 0x8000000080008008ULL, 0x8000000080008008ULL };
307
+
308
+ #define copyFromStateAndXor1344bits(X, state, input) \
309
+ X##ba = XOR128(LOAD128(state[ 0]), LOAD128(input[ 0])); \
310
+ X##be = XOR128(LOAD128(state[ 1]), LOAD128(input[ 1])); \
311
+ X##bi = XOR128(LOAD128(state[ 2]), LOAD128(input[ 2])); \
312
+ X##bo = XOR128(LOAD128(state[ 3]), LOAD128(input[ 3])); \
313
+ X##bu = XOR128(LOAD128(state[ 4]), LOAD128(input[ 4])); \
314
+ X##ga = XOR128(LOAD128(state[ 5]), LOAD128(input[ 5])); \
315
+ X##ge = XOR128(LOAD128(state[ 6]), LOAD128(input[ 6])); \
316
+ X##gi = XOR128(LOAD128(state[ 7]), LOAD128(input[ 7])); \
317
+ X##go = XOR128(LOAD128(state[ 8]), LOAD128(input[ 8])); \
318
+ X##gu = XOR128(LOAD128(state[ 9]), LOAD128(input[ 9])); \
319
+ X##ka = XOR128(LOAD128(state[10]), LOAD128(input[10])); \
320
+ X##ke = XOR128(LOAD128(state[11]), LOAD128(input[11])); \
321
+ X##ki = XOR128(LOAD128(state[12]), LOAD128(input[12])); \
322
+ X##ko = XOR128(LOAD128(state[13]), LOAD128(input[13])); \
323
+ X##ku = XOR128(LOAD128(state[14]), LOAD128(input[14])); \
324
+ X##ma = XOR128(LOAD128(state[15]), LOAD128(input[15])); \
325
+ X##me = XOR128(LOAD128(state[16]), LOAD128(input[16])); \
326
+ X##mi = XOR128(LOAD128(state[17]), LOAD128(input[17])); \
327
+ X##mo = XOR128(LOAD128(state[18]), LOAD128(input[18])); \
328
+ X##mu = XOR128(LOAD128(state[19]), LOAD128(input[19])); \
329
+ X##sa = XOR128(LOAD128(state[20]), LOAD128(input[20])); \
330
+ X##se = LOAD128(state[21]); \
331
+ X##si = LOAD128(state[22]); \
332
+ X##so = LOAD128(state[23]); \
333
+ X##su = LOAD128(state[24]); \
334
+
335
+ #define copyFromStateAndXor1088bits(X, state, input) \
336
+ X##ba = XOR128(LOAD128(state[ 0]), LOAD128(input[ 0])); \
337
+ X##be = XOR128(LOAD128(state[ 1]), LOAD128(input[ 1])); \
338
+ X##bi = XOR128(LOAD128(state[ 2]), LOAD128(input[ 2])); \
339
+ X##bo = XOR128(LOAD128(state[ 3]), LOAD128(input[ 3])); \
340
+ X##bu = XOR128(LOAD128(state[ 4]), LOAD128(input[ 4])); \
341
+ X##ga = XOR128(LOAD128(state[ 5]), LOAD128(input[ 5])); \
342
+ X##ge = XOR128(LOAD128(state[ 6]), LOAD128(input[ 6])); \
343
+ X##gi = XOR128(LOAD128(state[ 7]), LOAD128(input[ 7])); \
344
+ X##go = XOR128(LOAD128(state[ 8]), LOAD128(input[ 8])); \
345
+ X##gu = XOR128(LOAD128(state[ 9]), LOAD128(input[ 9])); \
346
+ X##ka = XOR128(LOAD128(state[10]), LOAD128(input[10])); \
347
+ X##ke = XOR128(LOAD128(state[11]), LOAD128(input[11])); \
348
+ X##ki = XOR128(LOAD128(state[12]), LOAD128(input[12])); \
349
+ X##ko = XOR128(LOAD128(state[13]), LOAD128(input[13])); \
350
+ X##ku = XOR128(LOAD128(state[14]), LOAD128(input[14])); \
351
+ X##ma = XOR128(LOAD128(state[15]), LOAD128(input[15])); \
352
+ X##me = XOR128(LOAD128(state[16]), LOAD128(input[16])); \
353
+ X##mi = LOAD128(state[17]); \
354
+ X##mo = LOAD128(state[18]); \
355
+ X##mu = LOAD128(state[19]); \
356
+ X##sa = LOAD128(state[20]); \
357
+ X##se = LOAD128(state[21]); \
358
+ X##si = LOAD128(state[22]); \
359
+ X##so = LOAD128(state[23]); \
360
+ X##su = LOAD128(state[24]); \
361
+
362
+ #define copyFromStateAndXor1024bits(X, state, input) \
363
+ X##ba = XOR128(LOAD128(state[ 0]), LOAD128(input[ 0])); \
364
+ X##be = XOR128(LOAD128(state[ 1]), LOAD128(input[ 1])); \
365
+ X##bi = XOR128(LOAD128(state[ 2]), LOAD128(input[ 2])); \
366
+ X##bo = XOR128(LOAD128(state[ 3]), LOAD128(input[ 3])); \
367
+ X##bu = XOR128(LOAD128(state[ 4]), LOAD128(input[ 4])); \
368
+ X##ga = XOR128(LOAD128(state[ 5]), LOAD128(input[ 5])); \
369
+ X##ge = XOR128(LOAD128(state[ 6]), LOAD128(input[ 6])); \
370
+ X##gi = XOR128(LOAD128(state[ 7]), LOAD128(input[ 7])); \
371
+ X##go = XOR128(LOAD128(state[ 8]), LOAD128(input[ 8])); \
372
+ X##gu = XOR128(LOAD128(state[ 9]), LOAD128(input[ 9])); \
373
+ X##ka = XOR128(LOAD128(state[10]), LOAD128(input[10])); \
374
+ X##ke = XOR128(LOAD128(state[11]), LOAD128(input[11])); \
375
+ X##ki = XOR128(LOAD128(state[12]), LOAD128(input[12])); \
376
+ X##ko = XOR128(LOAD128(state[13]), LOAD128(input[13])); \
377
+ X##ku = XOR128(LOAD128(state[14]), LOAD128(input[14])); \
378
+ X##ma = XOR128(LOAD128(state[15]), LOAD128(input[15])); \
379
+ X##me = LOAD128(state[16]); \
380
+ X##mi = LOAD128(state[17]); \
381
+ X##mo = LOAD128(state[18]); \
382
+ X##mu = LOAD128(state[19]); \
383
+ X##sa = LOAD128(state[20]); \
384
+ X##se = LOAD128(state[21]); \
385
+ X##si = LOAD128(state[22]); \
386
+ X##so = LOAD128(state[23]); \
387
+ X##su = LOAD128(state[24]); \
388
+
389
+ #define copyFromStateAndXor512bits(X, state, input) \
390
+ X##ba = XOR128(LOAD128(state[ 0]), LOAD128(input[ 0])); \
391
+ X##be = XOR128(LOAD128(state[ 1]), LOAD128(input[ 1])); \
392
+ X##bi = XOR128(LOAD128(state[ 2]), LOAD128(input[ 2])); \
393
+ X##bo = XOR128(LOAD128(state[ 3]), LOAD128(input[ 3])); \
394
+ X##bu = XOR128(LOAD128(state[ 4]), LOAD128(input[ 4])); \
395
+ X##ga = XOR128(LOAD128(state[ 5]), LOAD128(input[ 5])); \
396
+ X##ge = XOR128(LOAD128(state[ 6]), LOAD128(input[ 6])); \
397
+ X##gi = XOR128(LOAD128(state[ 7]), LOAD128(input[ 7])); \
398
+ X##go = LOAD128(state[ 8]); \
399
+ X##gu = LOAD128(state[ 9]); \
400
+ X##ka = LOAD128(state[10]); \
401
+ X##ke = LOAD128(state[11]); \
402
+ X##ki = LOAD128(state[12]); \
403
+ X##ko = LOAD128(state[13]); \
404
+ X##ku = LOAD128(state[14]); \
405
+ X##ma = LOAD128(state[15]); \
406
+ X##me = LOAD128(state[16]); \
407
+ X##mi = LOAD128(state[17]); \
408
+ X##mo = LOAD128(state[18]); \
409
+ X##mu = LOAD128(state[19]); \
410
+ X##sa = LOAD128(state[20]); \
411
+ X##se = LOAD128(state[21]); \
412
+ X##si = LOAD128(state[22]); \
413
+ X##so = LOAD128(state[23]); \
414
+ X##su = LOAD128(state[24]); \
415
+
416
+ #define copyFromState(X, state) \
417
+ X##ba = LOAD128(state[ 0]); \
418
+ X##be = LOAD128(state[ 1]); \
419
+ X##bi = LOAD128(state[ 2]); \
420
+ X##bo = LOAD128(state[ 3]); \
421
+ X##bu = LOAD128(state[ 4]); \
422
+ X##ga = LOAD128(state[ 5]); \
423
+ X##ge = LOAD128(state[ 6]); \
424
+ X##gi = LOAD128(state[ 7]); \
425
+ X##go = LOAD128(state[ 8]); \
426
+ X##gu = LOAD128(state[ 9]); \
427
+ X##ka = LOAD128(state[10]); \
428
+ X##ke = LOAD128(state[11]); \
429
+ X##ki = LOAD128(state[12]); \
430
+ X##ko = LOAD128(state[13]); \
431
+ X##ku = LOAD128(state[14]); \
432
+ X##ma = LOAD128(state[15]); \
433
+ X##me = LOAD128(state[16]); \
434
+ X##mi = LOAD128(state[17]); \
435
+ X##mo = LOAD128(state[18]); \
436
+ X##mu = LOAD128(state[19]); \
437
+ X##sa = LOAD128(state[20]); \
438
+ X##se = LOAD128(state[21]); \
439
+ X##si = LOAD128(state[22]); \
440
+ X##so = LOAD128(state[23]); \
441
+ X##su = LOAD128(state[24]); \
442
+
443
+ #define copyToState(state, X) \
444
+ STORE128(state[ 0], X##ba); \
445
+ STORE128(state[ 1], X##be); \
446
+ STORE128(state[ 2], X##bi); \
447
+ STORE128(state[ 3], X##bo); \
448
+ STORE128(state[ 4], X##bu); \
449
+ STORE128(state[ 5], X##ga); \
450
+ STORE128(state[ 6], X##ge); \
451
+ STORE128(state[ 7], X##gi); \
452
+ STORE128(state[ 8], X##go); \
453
+ STORE128(state[ 9], X##gu); \
454
+ STORE128(state[10], X##ka); \
455
+ STORE128(state[11], X##ke); \
456
+ STORE128(state[12], X##ki); \
457
+ STORE128(state[13], X##ko); \
458
+ STORE128(state[14], X##ku); \
459
+ STORE128(state[15], X##ma); \
460
+ STORE128(state[16], X##me); \
461
+ STORE128(state[17], X##mi); \
462
+ STORE128(state[18], X##mo); \
463
+ STORE128(state[19], X##mu); \
464
+ STORE128(state[20], X##sa); \
465
+ STORE128(state[21], X##se); \
466
+ STORE128(state[22], X##si); \
467
+ STORE128(state[23], X##so); \
468
+ STORE128(state[24], X##su); \
469
+
470
+ #define copyStateVariables(X, Y) \
471
+ X##ba = Y##ba; \
472
+ X##be = Y##be; \
473
+ X##bi = Y##bi; \
474
+ X##bo = Y##bo; \
475
+ X##bu = Y##bu; \
476
+ X##ga = Y##ga; \
477
+ X##ge = Y##ge; \
478
+ X##gi = Y##gi; \
479
+ X##go = Y##go; \
480
+ X##gu = Y##gu; \
481
+ X##ka = Y##ka; \
482
+ X##ke = Y##ke; \
483
+ X##ki = Y##ki; \
484
+ X##ko = Y##ko; \
485
+ X##ku = Y##ku; \
486
+ X##ma = Y##ma; \
487
+ X##me = Y##me; \
488
+ X##mi = Y##mi; \
489
+ X##mo = Y##mo; \
490
+ X##mu = Y##mu; \
491
+ X##sa = Y##sa; \
492
+ X##se = Y##se; \
493
+ X##si = Y##si; \
494
+ X##so = Y##so; \
495
+ X##su = Y##su; \
496
+
497
+ #include "KeccakF-1600-unrolling.macros"
498
+
499
+ void KeccakDoublePermutationOnWords(V128 *state)
500
+ {
501
+ declareABCDE
502
+ #if (Unrolling != 24)
503
+ unsigned int i;
504
+ #endif
505
+
506
+ copyFromState(A, state)
507
+ rounds
508
+ #if defined(UseMMX)
509
+ _mm_empty();
510
+ #endif
511
+ }
512
+
513
+ void KeccakDoublePermutationOnWordsAfterXoring2x512bits(V128 *state, const V128 *input)
514
+ {
515
+ declareABCDE
516
+ #if (Unrolling != 24)
517
+ unsigned int i;
518
+ #endif
519
+
520
+ copyFromStateAndXor512bits(A, state, input)
521
+ rounds
522
+ #if defined(UseMMX)
523
+ _mm_empty();
524
+ #endif
525
+ }
526
+
527
+ void KeccakDoublePermutationOnWordsAfterXoring2x1024bits(V128 *state, const V128 *input)
528
+ {
529
+ declareABCDE
530
+ #if (Unrolling != 24)
531
+ unsigned int i;
532
+ #endif
533
+
534
+ copyFromStateAndXor1024bits(A, state, input)
535
+ rounds
536
+ #if defined(UseMMX)
537
+ _mm_empty();
538
+ #endif
539
+ }
540
+
541
+ void KeccakDoublePermutationOnWordsAfterXoring2x1088bits(V128 *state, const V128 *input)
542
+ {
543
+ declareABCDE
544
+ #if (Unrolling != 24)
545
+ unsigned int i;
546
+ #endif
547
+
548
+ copyFromStateAndXor1088bits(A, state, input)
549
+ rounds
550
+ #if defined(UseMMX)
551
+ _mm_empty();
552
+ #endif
553
+ }
554
+
555
+ void KeccakDoublePermutationOnWordsAfterXoring2x1344bits(V128 *state, const V128 *input)
556
+ {
557
+ declareABCDE
558
+ #if (Unrolling != 24)
559
+ unsigned int i;
560
+ #endif
561
+
562
+ copyFromStateAndXor1344bits(A, state, input)
563
+ rounds
564
+ #if defined(UseMMX)
565
+ _mm_empty();
566
+ #endif
567
+ }
568
+
569
+ void KeccakInitializeDoubleState(V128 *state)
570
+ {
571
+ memset(state, 0, KeccakPermutationSizeInBytes*2);
572
+ }