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,651 @@
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
+ #define declareABCDE \
15
+ V6464 Abage, Abegi, Abigo, Abogu, Abuga; \
16
+ V6464 Akame, Akemi, Akimo, Akomu, Akuma; \
17
+ V6464 Abae, Abio, Agae, Agio, Akae, Akio, Amae, Amio, Asae, Asio; \
18
+ V64 Aba, Abe, Abi, Abo, Abu; \
19
+ V64 Aga, Age, Agi, Ago, Agu; \
20
+ V64 Aka, Ake, Aki, Ako, Aku; \
21
+ V64 Ama, Ame, Ami, Amo, Amu; \
22
+ V64 Asa, Ase, Asi, Aso, Asu; \
23
+ V128 Bbage, Bbegi, Bbigo, Bbogu, Bbuga; \
24
+ V128 Bkame, Bkemi, Bkimo, Bkomu, Bkuma; \
25
+ V64 Bba, Bbe, Bbi, Bbo, Bbu; \
26
+ V64 Bga, Bge, Bgi, Bgo, Bgu; \
27
+ V64 Bka, Bke, Bki, Bko, Bku; \
28
+ V64 Bma, Bme, Bmi, Bmo, Bmu; \
29
+ V64 Bsa, Bse, Bsi, Bso, Bsu; \
30
+ V128 Cae, Cei, Cio, Cou, Cua, Dei, Dou; \
31
+ V64 Ca, Ce, Ci, Co, Cu; \
32
+ V64 Da, De, Di, Do, Du; \
33
+ V6464 Ebage, Ebegi, Ebigo, Ebogu, Ebuga; \
34
+ V6464 Ekame, Ekemi, Ekimo, Ekomu, Ekuma; \
35
+ V64 Eba, Ebe, Ebi, Ebo, Ebu; \
36
+ V64 Ega, Ege, Egi, Ego, Egu; \
37
+ V64 Eka, Eke, Eki, Eko, Eku; \
38
+ V64 Ema, Eme, Emi, Emo, Emu; \
39
+ V64 Esa, Ese, Esi, Eso, Esu; \
40
+ V128 Zero;
41
+
42
+ #define prepareTheta
43
+
44
+ #define computeD \
45
+ Cua = GET64LOLO(Cu, Cae); \
46
+ Dei = XOR128(Cae, ROL64in128(Cio, 1)); \
47
+ Dou = XOR128(Cio, ROL64in128(Cua, 1)); \
48
+ Da = XOR64(Cu, ROL64in128(COPY64HI2LO(Cae), 1)); \
49
+ De = Dei; \
50
+ Di = COPY64HI2LO(Dei); \
51
+ Do = Dou; \
52
+ Du = COPY64HI2LO(Dou);
53
+
54
+ // --- Theta Rho Pi Chi Iota Prepare-theta
55
+ // --- 64-bit lanes mapped to 64-bit and 128-bit words
56
+ #define thetaRhoPiChiIotaPrepareTheta(i, A, E) \
57
+ computeD \
58
+ \
59
+ A##ba = LOAD64(A##bage.v64[0]); \
60
+ XOReq64(A##ba, Da); \
61
+ Bba = A##ba; \
62
+ XOReq64(A##gu, Du); \
63
+ Bge = ROL64(A##gu, 20); \
64
+ Bbage = GET64LOLO(Bba, Bge); \
65
+ A##ge = LOAD64(A##bage.v64[1]); \
66
+ XOReq64(A##ge, De); \
67
+ Bbe = ROL64(A##ge, 44); \
68
+ A##ka = LOAD64(A##kame.v64[0]); \
69
+ XOReq64(A##ka, Da); \
70
+ Bgi = ROL64(A##ka, 3); \
71
+ Bbegi = GET64LOLO(Bbe, Bgi); \
72
+ XOReq64(A##ki, Di); \
73
+ Bbi = ROL64(A##ki, 43); \
74
+ A##me = LOAD64(A##kame.v64[1]); \
75
+ XOReq64(A##me, De); \
76
+ Bgo = ROL64(A##me, 45); \
77
+ Bbigo = GET64LOLO(Bbi, Bgo); \
78
+ E##bage.v128 = XOR128(Bbage, ANDnu128(Bbegi, Bbigo)); \
79
+ XOReq128(E##bage.v128, CONST64(KeccakF1600RoundConstants[i])); \
80
+ Cae = E##bage.v128; \
81
+ XOReq64(A##mo, Do); \
82
+ Bbo = ROL64(A##mo, 21); \
83
+ XOReq64(A##si, Di); \
84
+ Bgu = ROL64(A##si, 61); \
85
+ Bbogu = GET64LOLO(Bbo, Bgu); \
86
+ E##begi.v128 = XOR128(Bbegi, ANDnu128(Bbigo, Bbogu)); \
87
+ Cei = E##begi.v128; \
88
+ XOReq64(A##su, Du); \
89
+ Bbu = ROL64(A##su, 14); \
90
+ XOReq64(A##bo, Do); \
91
+ Bga = ROL64(A##bo, 28); \
92
+ Bbuga = GET64LOLO(Bbu, Bga); \
93
+ E##bigo.v128 = XOR128(Bbigo, ANDnu128(Bbogu, Bbuga)); \
94
+ E##bi = E##bigo.v128; \
95
+ E##go = GET64HIHI(E##bigo.v128, E##bigo.v128); \
96
+ Cio = E##bigo.v128; \
97
+ E##bogu.v128 = XOR128(Bbogu, ANDnu128(Bbuga, Bbage)); \
98
+ E##bo = E##bogu.v128; \
99
+ E##gu = GET64HIHI(E##bogu.v128, E##bogu.v128); \
100
+ Cou = E##bogu.v128; \
101
+ E##buga.v128 = XOR128(Bbuga, ANDnu128(Bbage, Bbegi)); \
102
+ E##bu = E##buga.v128; \
103
+ E##ga = GET64HIHI(E##buga.v128, E##buga.v128); \
104
+ Cua = E##buga.v128; \
105
+ \
106
+ A##be = LOAD64(A##begi.v64[0]); \
107
+ XOReq64(A##be, De); \
108
+ Bka = ROL64(A##be, 1); \
109
+ XOReq64(A##ga, Da); \
110
+ Bme = ROL64(A##ga, 36); \
111
+ Bkame = GET64LOLO(Bka, Bme); \
112
+ A##gi = LOAD64(A##begi.v64[1]); \
113
+ XOReq64(A##gi, Di); \
114
+ Bke = ROL64(A##gi, 6); \
115
+ A##ke = LOAD64(A##kemi.v64[0]); \
116
+ XOReq64(A##ke, De); \
117
+ Bmi = ROL64(A##ke, 10); \
118
+ Bkemi = GET64LOLO(Bke, Bmi); \
119
+ XOReq64(A##ko, Do); \
120
+ Bki = ROL64(A##ko, 25); \
121
+ A##mi = LOAD64(A##kemi.v64[1]); \
122
+ XOReq64(A##mi, Di); \
123
+ Bmo = ROL64(A##mi, 15); \
124
+ Bkimo = GET64LOLO(Bki, Bmo); \
125
+ E##kame.v128 = XOR128(Bkame, ANDnu128(Bkemi, Bkimo)); \
126
+ XOReq128(Cae, E##kame.v128); \
127
+ Bkomu = GET64LOLO(XOR64(A##mu, Du), XOR64(A##so, Do)); \
128
+ Bkomu = SHUFFLEBYTES128(Bkomu, CONST128(rho8_56)); \
129
+ E##kemi.v128 = XOR128(Bkemi, ANDnu128(Bkimo, Bkomu)); \
130
+ XOReq128(Cei, E##kemi.v128); \
131
+ XOReq64(A##sa, Da); \
132
+ Bku = ROL64(A##sa, 18); \
133
+ XOReq64(A##bu, Du); \
134
+ Bma = ROL64(A##bu, 27); \
135
+ Bkuma = GET64LOLO(Bku, Bma); \
136
+ E##kimo.v128 = XOR128(Bkimo, ANDnu128(Bkomu, Bkuma)); \
137
+ E##ki = E##kimo.v128; \
138
+ E##mo = GET64HIHI(E##kimo.v128, E##kimo.v128); \
139
+ XOReq128(Cio, E##kimo.v128); \
140
+ E##komu.v128 = XOR128(Bkomu, ANDnu128(Bkuma, Bkame)); \
141
+ E##ko = E##komu.v128; \
142
+ E##mu = GET64HIHI(E##komu.v128, E##komu.v128); \
143
+ XOReq128(Cou, E##komu.v128); \
144
+ E##kuma.v128 = XOR128(Bkuma, ANDnu128(Bkame, Bkemi)); \
145
+ E##ku = E##kuma.v128; \
146
+ E##ma = GET64HIHI(E##kuma.v128, E##kuma.v128); \
147
+ XOReq128(Cua, E##kuma.v128); \
148
+ \
149
+ XOReq64(A##bi, Di); \
150
+ Bsa = ROL64(A##bi, 62); \
151
+ XOReq64(A##go, Do); \
152
+ Bse = ROL64(A##go, 55); \
153
+ XOReq64(A##ku, Du); \
154
+ Bsi = ROL64(A##ku, 39); \
155
+ E##sa = XOR64(Bsa, ANDnu64(Bse, Bsi)); \
156
+ Ca = E##sa; \
157
+ XOReq64(A##ma, Da); \
158
+ Bso = ROL64(A##ma, 41); \
159
+ E##se = XOR64(Bse, ANDnu64(Bsi, Bso)); \
160
+ Ce = E##se; \
161
+ XOReq128(Cae, GET64LOLO(Ca, Ce)); \
162
+ XOReq64(A##se, De); \
163
+ Bsu = ROL64(A##se, 2); \
164
+ E##si = XOR64(Bsi, ANDnu64(Bso, Bsu)); \
165
+ Ci = E##si; \
166
+ E##so = XOR64(Bso, ANDnu64(Bsu, Bsa)); \
167
+ Co = E##so; \
168
+ XOReq128(Cio, GET64LOLO(Ci, Co)); \
169
+ E##su = XOR64(Bsu, ANDnu64(Bsa, Bse)); \
170
+ Cu = E##su; \
171
+ \
172
+ Zero = ZERO128(); \
173
+ XOReq128(Cae, GET64HIHI(Cua, Zero)); \
174
+ XOReq128(Cae, GET64LOLO(Zero, Cei)); \
175
+ XOReq128(Cio, GET64HIHI(Cei, Zero)); \
176
+ XOReq128(Cio, GET64LOLO(Zero, Cou)); \
177
+ XOReq128(Cua, GET64HIHI(Cou, Zero)); \
178
+ XOReq64(Cu, Cua); \
179
+
180
+ // --- Theta Rho Pi Chi Iota
181
+ // --- 64-bit lanes mapped to 64-bit and 128-bit words
182
+ #define thetaRhoPiChiIota(i, A, E) thetaRhoPiChiIotaPrepareTheta(i, A, E)
183
+
184
+ const UINT64 KeccakF1600RoundConstants[24] = {
185
+ 0x0000000000000001ULL,
186
+ 0x0000000000008082ULL,
187
+ 0x800000000000808aULL,
188
+ 0x8000000080008000ULL,
189
+ 0x000000000000808bULL,
190
+ 0x0000000080000001ULL,
191
+ 0x8000000080008081ULL,
192
+ 0x8000000000008009ULL,
193
+ 0x000000000000008aULL,
194
+ 0x0000000000000088ULL,
195
+ 0x0000000080008009ULL,
196
+ 0x000000008000000aULL,
197
+ 0x000000008000808bULL,
198
+ 0x800000000000008bULL,
199
+ 0x8000000000008089ULL,
200
+ 0x8000000000008003ULL,
201
+ 0x8000000000008002ULL,
202
+ 0x8000000000000080ULL,
203
+ 0x000000000000800aULL,
204
+ 0x800000008000000aULL,
205
+ 0x8000000080008081ULL,
206
+ 0x8000000000008080ULL,
207
+ 0x0000000080000001ULL,
208
+ 0x8000000080008008ULL };
209
+
210
+ #define copyFromStateAndXor576bits(X, state, input) \
211
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
212
+ X##ba = X##bae.v128; \
213
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
214
+ Cae = X##bae.v128; \
215
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
216
+ X##bi = X##bio.v128; \
217
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
218
+ Cio = X##bio.v128; \
219
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
220
+ Cu = X##bu; \
221
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
222
+ X##ga = X##gae.v128; \
223
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
224
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
225
+ XOReq128(Cae, X##gae.v128); \
226
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
227
+ X##gi = X##gio.v128; \
228
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
229
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
230
+ XOReq128(Cio, X##gio.v128); \
231
+ X##gu = LOAD64(state[ 9]); \
232
+ XOReq64(Cu, X##gu); \
233
+ X##kae.v128 = LOAD128(state[10]); \
234
+ X##ka = X##kae.v128; \
235
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
236
+ XOReq128(Cae, X##kae.v128); \
237
+ X##kio.v128 = LOAD128(state[12]); \
238
+ X##ki = X##kio.v128; \
239
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
240
+ XOReq128(Cio, X##kio.v128); \
241
+ X##ku = LOAD64(state[14]); \
242
+ XOReq64(Cu, X##ku); \
243
+ X##mae.v128 = LOAD128u(state[15]); \
244
+ X##ma = X##mae.v128; \
245
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
246
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
247
+ XOReq128(Cae, X##mae.v128); \
248
+ X##mio.v128 = LOAD128u(state[17]); \
249
+ X##mi = X##mio.v128; \
250
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
251
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
252
+ XOReq128(Cio, X##mio.v128); \
253
+ X##mu = LOAD64(state[19]); \
254
+ XOReq64(Cu, X##mu); \
255
+ X##sae.v128 = LOAD128(state[20]); \
256
+ X##sa = X##sae.v128; \
257
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
258
+ XOReq128(Cae, X##sae.v128); \
259
+ X##sio.v128 = LOAD128(state[22]); \
260
+ X##si = X##sio.v128; \
261
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
262
+ XOReq128(Cio, X##sio.v128); \
263
+ X##su = LOAD64(state[24]); \
264
+ XOReq64(Cu, X##su); \
265
+
266
+ #define copyFromStateAndXor832bits(X, state, input) \
267
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
268
+ X##ba = X##bae.v128; \
269
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
270
+ Cae = X##bae.v128; \
271
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
272
+ X##bi = X##bio.v128; \
273
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
274
+ Cio = X##bio.v128; \
275
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
276
+ Cu = X##bu; \
277
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
278
+ X##ga = X##gae.v128; \
279
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
280
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
281
+ XOReq128(Cae, X##gae.v128); \
282
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
283
+ X##gi = X##gio.v128; \
284
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
285
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
286
+ XOReq128(Cio, X##gio.v128); \
287
+ X##gu = XOR64(LOAD64(state[ 9]), LOAD64(input[ 9])); \
288
+ XOReq64(Cu, X##gu); \
289
+ X##kae.v128 = XOR128(LOAD128(state[10]), LOAD128u(input[10])); \
290
+ X##ka = X##kae.v128; \
291
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
292
+ XOReq128(Cae, X##kae.v128); \
293
+ X##kio.v128 = XOR128(LOAD128(state[12]), LOAD64(input[12])); \
294
+ X##ki = X##kio.v128; \
295
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
296
+ XOReq128(Cio, X##kio.v128); \
297
+ X##ku = LOAD64(state[14]); \
298
+ XOReq64(Cu, X##ku); \
299
+ X##mae.v128 = LOAD128u(state[15]); \
300
+ X##ma = X##mae.v128; \
301
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
302
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
303
+ XOReq128(Cae, X##mae.v128); \
304
+ X##mio.v128 = LOAD128u(state[17]); \
305
+ X##mi = X##mio.v128; \
306
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
307
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
308
+ XOReq128(Cio, X##mio.v128); \
309
+ X##mu = LOAD64(state[19]); \
310
+ XOReq64(Cu, X##mu); \
311
+ X##sae.v128 = LOAD128(state[20]); \
312
+ X##sa = X##sae.v128; \
313
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
314
+ XOReq128(Cae, X##sae.v128); \
315
+ X##sio.v128 = LOAD128(state[22]); \
316
+ X##si = X##sio.v128; \
317
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
318
+ XOReq128(Cio, X##sio.v128); \
319
+ X##su = LOAD64(state[24]); \
320
+ XOReq64(Cu, X##su); \
321
+
322
+ #define copyFromStateAndXor1024bits(X, state, input) \
323
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
324
+ X##ba = X##bae.v128; \
325
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
326
+ Cae = X##bae.v128; \
327
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
328
+ X##bi = X##bio.v128; \
329
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
330
+ Cio = X##bio.v128; \
331
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
332
+ Cu = X##bu; \
333
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
334
+ X##ga = X##gae.v128; \
335
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
336
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
337
+ XOReq128(Cae, X##gae.v128); \
338
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
339
+ X##gi = X##gio.v128; \
340
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
341
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
342
+ XOReq128(Cio, X##gio.v128); \
343
+ X##gu = XOR64(LOAD64(state[ 9]), LOAD64(input[ 9])); \
344
+ XOReq64(Cu, X##gu); \
345
+ X##kae.v128 = XOR128(LOAD128(state[10]), LOAD128u(input[10])); \
346
+ X##ka = X##kae.v128; \
347
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
348
+ XOReq128(Cae, X##kae.v128); \
349
+ X##kio.v128 = XOR128(LOAD128(state[12]), LOAD128u(input[12])); \
350
+ X##ki = X##kio.v128; \
351
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
352
+ XOReq128(Cio, X##kio.v128); \
353
+ X##ku = XOR64(LOAD64(state[14]), LOAD64(input[14])); \
354
+ XOReq64(Cu, X##ku); \
355
+ X##mae.v128 = XOR128(LOAD128u(state[15]), LOAD64(input[15])); \
356
+ X##ma = X##mae.v128; \
357
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
358
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
359
+ XOReq128(Cae, X##mae.v128); \
360
+ X##mio.v128 = LOAD128u(state[17]); \
361
+ X##mi = X##mio.v128; \
362
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
363
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
364
+ XOReq128(Cio, X##mio.v128); \
365
+ X##mu = LOAD64(state[19]); \
366
+ XOReq64(Cu, X##mu); \
367
+ X##sae.v128 = LOAD128(state[20]); \
368
+ X##sa = X##sae.v128; \
369
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
370
+ XOReq128(Cae, X##sae.v128); \
371
+ X##sio.v128 = LOAD128(state[22]); \
372
+ X##si = X##sio.v128; \
373
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
374
+ XOReq128(Cio, X##sio.v128); \
375
+ X##su = LOAD64(state[24]); \
376
+ XOReq64(Cu, X##su); \
377
+
378
+ #define copyFromStateAndXor1088bits(X, state, input) \
379
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
380
+ X##ba = X##bae.v128; \
381
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
382
+ Cae = X##bae.v128; \
383
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
384
+ X##bi = X##bio.v128; \
385
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
386
+ Cio = X##bio.v128; \
387
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
388
+ Cu = X##bu; \
389
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
390
+ X##ga = X##gae.v128; \
391
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
392
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
393
+ XOReq128(Cae, X##gae.v128); \
394
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
395
+ X##gi = X##gio.v128; \
396
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
397
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
398
+ XOReq128(Cio, X##gio.v128); \
399
+ X##gu = XOR64(LOAD64(state[ 9]), LOAD64(input[ 9])); \
400
+ XOReq64(Cu, X##gu); \
401
+ X##kae.v128 = XOR128(LOAD128(state[10]), LOAD128u(input[10])); \
402
+ X##ka = X##kae.v128; \
403
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
404
+ XOReq128(Cae, X##kae.v128); \
405
+ X##kio.v128 = XOR128(LOAD128(state[12]), LOAD128u(input[12])); \
406
+ X##ki = X##kio.v128; \
407
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
408
+ XOReq128(Cio, X##kio.v128); \
409
+ X##ku = XOR64(LOAD64(state[14]), LOAD64(input[14])); \
410
+ XOReq64(Cu, X##ku); \
411
+ X##mae.v128 = XOR128(LOAD128u(state[15]), LOAD128u(input[15])); \
412
+ X##ma = X##mae.v128; \
413
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
414
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
415
+ XOReq128(Cae, X##mae.v128); \
416
+ X##mio.v128 = LOAD128u(state[17]); \
417
+ X##mi = X##mio.v128; \
418
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
419
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
420
+ XOReq128(Cio, X##mio.v128); \
421
+ X##mu = LOAD64(state[19]); \
422
+ XOReq64(Cu, X##mu); \
423
+ X##sae.v128 = LOAD128(state[20]); \
424
+ X##sa = X##sae.v128; \
425
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
426
+ XOReq128(Cae, X##sae.v128); \
427
+ X##sio.v128 = LOAD128(state[22]); \
428
+ X##si = X##sio.v128; \
429
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
430
+ XOReq128(Cio, X##sio.v128); \
431
+ X##su = LOAD64(state[24]); \
432
+ XOReq64(Cu, X##su); \
433
+
434
+ #define copyFromStateAndXor1152bits(X, state, input) \
435
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
436
+ X##ba = X##bae.v128; \
437
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
438
+ Cae = X##bae.v128; \
439
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
440
+ X##bi = X##bio.v128; \
441
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
442
+ Cio = X##bio.v128; \
443
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
444
+ Cu = X##bu; \
445
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
446
+ X##ga = X##gae.v128; \
447
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
448
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
449
+ XOReq128(Cae, X##gae.v128); \
450
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
451
+ X##gi = X##gio.v128; \
452
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
453
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
454
+ XOReq128(Cio, X##gio.v128); \
455
+ X##gu = XOR64(LOAD64(state[ 9]), LOAD64(input[ 9])); \
456
+ XOReq64(Cu, X##gu); \
457
+ X##kae.v128 = XOR128(LOAD128(state[10]), LOAD128u(input[10])); \
458
+ X##ka = X##kae.v128; \
459
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
460
+ XOReq128(Cae, X##kae.v128); \
461
+ X##kio.v128 = XOR128(LOAD128(state[12]), LOAD128u(input[12])); \
462
+ X##ki = X##kio.v128; \
463
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
464
+ XOReq128(Cio, X##kio.v128); \
465
+ X##ku = XOR64(LOAD64(state[14]), LOAD64(input[14])); \
466
+ XOReq64(Cu, X##ku); \
467
+ X##mae.v128 = XOR128(LOAD128u(state[15]), LOAD128u(input[15])); \
468
+ X##ma = X##mae.v128; \
469
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
470
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
471
+ XOReq128(Cae, X##mae.v128); \
472
+ X##mio.v128 = XOR128(LOAD128u(state[17]), LOAD64(input[17])); \
473
+ X##mi = X##mio.v128; \
474
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
475
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
476
+ XOReq128(Cio, X##mio.v128); \
477
+ X##mu = LOAD64(state[19]); \
478
+ XOReq64(Cu, X##mu); \
479
+ X##sae.v128 = LOAD128(state[20]); \
480
+ X##sa = X##sae.v128; \
481
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
482
+ XOReq128(Cae, X##sae.v128); \
483
+ X##sio.v128 = LOAD128(state[22]); \
484
+ X##si = X##sio.v128; \
485
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
486
+ XOReq128(Cio, X##sio.v128); \
487
+ X##su = LOAD64(state[24]); \
488
+ XOReq64(Cu, X##su); \
489
+
490
+ #define copyFromStateAndXor1344bits(X, state, input) \
491
+ X##bae.v128 = XOR128(LOAD128(state[ 0]), LOAD128u(input[ 0])); \
492
+ X##ba = X##bae.v128; \
493
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
494
+ Cae = X##bae.v128; \
495
+ X##bio.v128 = XOR128(LOAD128(state[ 2]), LOAD128u(input[ 2])); \
496
+ X##bi = X##bio.v128; \
497
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
498
+ Cio = X##bio.v128; \
499
+ X##bu = XOR64(LOAD64(state[ 4]), LOAD64(input[ 4])); \
500
+ Cu = X##bu; \
501
+ X##gae.v128 = XOR128(LOAD128u(state[ 5]), LOAD128u(input[ 5])); \
502
+ X##ga = X##gae.v128; \
503
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
504
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
505
+ XOReq128(Cae, X##gae.v128); \
506
+ X##gio.v128 = XOR128(LOAD128u(state[ 7]), LOAD128u(input[ 7])); \
507
+ X##gi = X##gio.v128; \
508
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
509
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
510
+ XOReq128(Cio, X##gio.v128); \
511
+ X##gu = XOR64(LOAD64(state[ 9]), LOAD64(input[ 9])); \
512
+ XOReq64(Cu, X##gu); \
513
+ X##kae.v128 = XOR128(LOAD128(state[10]), LOAD128u(input[10])); \
514
+ X##ka = X##kae.v128; \
515
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
516
+ XOReq128(Cae, X##kae.v128); \
517
+ X##kio.v128 = XOR128(LOAD128(state[12]), LOAD128u(input[12])); \
518
+ X##ki = X##kio.v128; \
519
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
520
+ XOReq128(Cio, X##kio.v128); \
521
+ X##ku = XOR64(LOAD64(state[14]), LOAD64(input[14])); \
522
+ XOReq64(Cu, X##ku); \
523
+ X##mae.v128 = XOR128(LOAD128u(state[15]), LOAD128u(input[15])); \
524
+ X##ma = X##mae.v128; \
525
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
526
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
527
+ XOReq128(Cae, X##mae.v128); \
528
+ X##mio.v128 = XOR128(LOAD128u(state[17]), LOAD128u(input[17])); \
529
+ X##mi = X##mio.v128; \
530
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
531
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
532
+ XOReq128(Cio, X##mio.v128); \
533
+ X##mu = XOR64(LOAD64(state[19]), LOAD64(input[19])); \
534
+ XOReq64(Cu, X##mu); \
535
+ X##sae.v128 = XOR128(LOAD128(state[20]), LOAD64(input[20])); \
536
+ X##sa = X##sae.v128; \
537
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
538
+ XOReq128(Cae, X##sae.v128); \
539
+ X##sio.v128 = LOAD128(state[22]); \
540
+ X##si = X##sio.v128; \
541
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
542
+ XOReq128(Cio, X##sio.v128); \
543
+ X##su = LOAD64(state[24]); \
544
+ XOReq64(Cu, X##su); \
545
+
546
+ #define copyFromState(X, state) \
547
+ X##bae.v128 = LOAD128(state[ 0]); \
548
+ X##ba = X##bae.v128; \
549
+ X##be = GET64HIHI(X##bae.v128, X##bae.v128); \
550
+ Cae = X##bae.v128; \
551
+ X##bio.v128 = LOAD128(state[ 2]); \
552
+ X##bi = X##bio.v128; \
553
+ X##bo = GET64HIHI(X##bio.v128, X##bio.v128); \
554
+ Cio = X##bio.v128; \
555
+ X##bu = LOAD64(state[ 4]); \
556
+ Cu = X##bu; \
557
+ X##gae.v128 = LOAD128u(state[ 5]); \
558
+ X##ga = X##gae.v128; \
559
+ X##ge = GET64HIHI(X##gae.v128, X##gae.v128); \
560
+ X##bage.v128 = GET64LOLO(X##ba, X##ge); \
561
+ XOReq128(Cae, X##gae.v128); \
562
+ X##gio.v128 = LOAD128u(state[ 7]); \
563
+ X##gi = X##gio.v128; \
564
+ X##begi.v128 = GET64LOLO(X##be, X##gi); \
565
+ X##go = GET64HIHI(X##gio.v128, X##gio.v128); \
566
+ XOReq128(Cio, X##gio.v128); \
567
+ X##gu = LOAD64(state[ 9]); \
568
+ XOReq64(Cu, X##gu); \
569
+ X##kae.v128 = LOAD128(state[10]); \
570
+ X##ka = X##kae.v128; \
571
+ X##ke = GET64HIHI(X##kae.v128, X##kae.v128); \
572
+ XOReq128(Cae, X##kae.v128); \
573
+ X##kio.v128 = LOAD128(state[12]); \
574
+ X##ki = X##kio.v128; \
575
+ X##ko = GET64HIHI(X##kio.v128, X##kio.v128); \
576
+ XOReq128(Cio, X##kio.v128); \
577
+ X##ku = LOAD64(state[14]); \
578
+ XOReq64(Cu, X##ku); \
579
+ X##mae.v128 = LOAD128u(state[15]); \
580
+ X##ma = X##mae.v128; \
581
+ X##me = GET64HIHI(X##mae.v128, X##mae.v128); \
582
+ X##kame.v128 = GET64LOLO(X##ka, X##me); \
583
+ XOReq128(Cae, X##mae.v128); \
584
+ X##mio.v128 = LOAD128u(state[17]); \
585
+ X##mi = X##mio.v128; \
586
+ X##kemi.v128 = GET64LOLO(X##ke, X##mi); \
587
+ X##mo = GET64HIHI(X##mio.v128, X##mio.v128); \
588
+ XOReq128(Cio, X##mio.v128); \
589
+ X##mu = LOAD64(state[19]); \
590
+ XOReq64(Cu, X##mu); \
591
+ X##sae.v128 = LOAD128(state[20]); \
592
+ X##sa = X##sae.v128; \
593
+ X##se = GET64HIHI(X##sae.v128, X##sae.v128); \
594
+ XOReq128(Cae, X##sae.v128); \
595
+ X##sio.v128 = LOAD128(state[22]); \
596
+ X##si = X##sio.v128; \
597
+ X##so = GET64HIHI(X##sio.v128, X##sio.v128); \
598
+ XOReq128(Cio, X##sio.v128); \
599
+ X##su = LOAD64(state[24]); \
600
+ XOReq64(Cu, X##su); \
601
+
602
+ #define copyToState(state, X) \
603
+ state[ 0] = A##bage.v64[0]; \
604
+ state[ 1] = A##begi.v64[0]; \
605
+ STORE64(state[ 2], X##bi); \
606
+ STORE64(state[ 3], X##bo); \
607
+ STORE64(state[ 4], X##bu); \
608
+ STORE64(state[ 5], X##ga); \
609
+ state[ 6] = A##bage.v64[1]; \
610
+ state[ 7] = A##begi.v64[1]; \
611
+ STORE64(state[ 8], X##go); \
612
+ STORE64(state[ 9], X##gu); \
613
+ state[10] = X##kame.v64[0]; \
614
+ state[11] = X##kemi.v64[0]; \
615
+ STORE64(state[12], X##ki); \
616
+ STORE64(state[13], X##ko); \
617
+ STORE64(state[14], X##ku); \
618
+ STORE64(state[15], X##ma); \
619
+ state[16] = X##kame.v64[1]; \
620
+ state[17] = X##kemi.v64[1]; \
621
+ STORE64(state[18], X##mo); \
622
+ STORE64(state[19], X##mu); \
623
+ STORE64(state[20], X##sa); \
624
+ STORE64(state[21], X##se); \
625
+ STORE64(state[22], X##si); \
626
+ STORE64(state[23], X##so); \
627
+ STORE64(state[24], X##su); \
628
+
629
+ #define copyStateVariables(X, Y) \
630
+ X##bage = Y##bage; \
631
+ X##begi = Y##begi; \
632
+ X##bi = Y##bi; \
633
+ X##bo = Y##bo; \
634
+ X##bu = Y##bu; \
635
+ X##ga = Y##ga; \
636
+ X##go = Y##go; \
637
+ X##gu = Y##gu; \
638
+ X##kame = Y##kame; \
639
+ X##kemi = Y##kemi; \
640
+ X##ki = Y##ki; \
641
+ X##ko = Y##ko; \
642
+ X##ku = Y##ku; \
643
+ X##ma = Y##ma; \
644
+ X##mo = Y##mo; \
645
+ X##mu = Y##mu; \
646
+ X##sa = Y##sa; \
647
+ X##se = Y##se; \
648
+ X##si = Y##si; \
649
+ X##so = Y##so; \
650
+ X##su = Y##su; \
651
+