sleeping_kangaroo12 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +127 -0
  3. data/ext/Rakefile +73 -0
  4. data/ext/binding/sleeping_kangaroo12.c +39 -0
  5. data/ext/config/xkcp.build +17 -0
  6. data/ext/xkcp/LICENSE +1 -0
  7. data/ext/xkcp/Makefile +15 -0
  8. data/ext/xkcp/Makefile.build +200 -0
  9. data/ext/xkcp/README.markdown +296 -0
  10. data/ext/xkcp/lib/HighLevel.build +143 -0
  11. data/ext/xkcp/lib/LowLevel.build +757 -0
  12. data/ext/xkcp/lib/common/align.h +33 -0
  13. data/ext/xkcp/lib/common/brg_endian.h +143 -0
  14. data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +301 -0
  15. data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.h +97 -0
  16. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +81 -0
  17. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +125 -0
  18. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +48 -0
  19. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +79 -0
  20. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +81 -0
  21. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +73 -0
  22. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +195 -0
  23. data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +111 -0
  24. data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +76 -0
  25. data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +314 -0
  26. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +61 -0
  27. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +67 -0
  28. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +128 -0
  29. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +93 -0
  30. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +599 -0
  31. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +573 -0
  32. data/ext/xkcp/lib/high/Ketje/Ketjev2.c +87 -0
  33. data/ext/xkcp/lib/high/Ketje/Ketjev2.h +88 -0
  34. data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +274 -0
  35. data/ext/xkcp/lib/high/Keyak/Keyakv2.c +132 -0
  36. data/ext/xkcp/lib/high/Keyak/Keyakv2.h +217 -0
  37. data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +81 -0
  38. data/ext/xkcp/lib/high/Keyak/Motorist.inc +953 -0
  39. data/ext/xkcp/lib/high/Kravatte/Kravatte.c +533 -0
  40. data/ext/xkcp/lib/high/Kravatte/Kravatte.h +115 -0
  41. data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +557 -0
  42. data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +247 -0
  43. data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +66 -0
  44. data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +336 -0
  45. data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +26 -0
  46. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +55 -0
  47. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +35 -0
  48. data/ext/xkcp/lib/high/Xoofff/Xoofff.c +634 -0
  49. data/ext/xkcp/lib/high/Xoofff/Xoofff.h +147 -0
  50. data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +483 -0
  51. data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +241 -0
  52. data/ext/xkcp/lib/high/common/Phases.h +25 -0
  53. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +41 -0
  54. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +1666 -0
  55. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +1655 -0
  56. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +1268 -0
  57. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +1264 -0
  58. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +1178 -0
  59. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +1175 -0
  60. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +1338 -0
  61. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +1336 -0
  62. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +1343 -0
  63. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +1339 -0
  64. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +42 -0
  65. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +823 -0
  66. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +831 -0
  67. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +31 -0
  68. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +540 -0
  69. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +42 -0
  70. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +733 -0
  71. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +1121 -0
  72. data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s +1100 -0
  73. data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +52 -0
  74. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +623 -0
  75. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +47 -0
  76. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +6 -0
  77. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +6 -0
  78. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +6 -0
  79. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +1031 -0
  80. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +53 -0
  81. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +44 -0
  82. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +476 -0
  83. data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +6 -0
  84. data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +6 -0
  85. data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +748 -0
  86. data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +305 -0
  87. data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-SnP.h +40 -0
  88. data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +420 -0
  89. data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +43 -0
  90. data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-inplace32BI.c +1163 -0
  91. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-SnP.h +54 -0
  92. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +565 -0
  93. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +7 -0
  94. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +7 -0
  95. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +8 -0
  96. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +6 -0
  97. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +6 -0
  98. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +44 -0
  99. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +23 -0
  100. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +625 -0
  101. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +44 -0
  102. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +440 -0
  103. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h +23 -0
  104. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +42 -0
  105. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +1196 -0
  106. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +1124 -0
  107. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +1196 -0
  108. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +1392 -0
  109. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +1394 -0
  110. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +42 -0
  111. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +7 -0
  112. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +7 -0
  113. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +7 -0
  114. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +850 -0
  115. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +51 -0
  116. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +957 -0
  117. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +49 -0
  118. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +8 -0
  119. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +8 -0
  120. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +9 -0
  121. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +9 -0
  122. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +45 -0
  123. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +37 -0
  124. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +1321 -0
  125. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +55 -0
  126. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +7 -0
  127. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +7 -0
  128. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +7 -0
  129. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +7 -0
  130. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +7 -0
  131. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +7 -0
  132. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +881 -0
  133. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +51 -0
  134. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +45 -0
  135. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +37 -0
  136. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +45 -0
  137. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +38 -0
  138. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +1615 -0
  139. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +57 -0
  140. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +7 -0
  141. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +7 -0
  142. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +7 -0
  143. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +45 -0
  144. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +37 -0
  145. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +45 -0
  146. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +38 -0
  147. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +45 -0
  148. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +38 -0
  149. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +41 -0
  150. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +442 -0
  151. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +446 -0
  152. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +419 -0
  153. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +427 -0
  154. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +41 -0
  155. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +647 -0
  156. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +39 -0
  157. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +190 -0
  158. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +43 -0
  159. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +412 -0
  160. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +23 -0
  161. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +41 -0
  162. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +454 -0
  163. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +458 -0
  164. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +455 -0
  165. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +458 -0
  166. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +41 -0
  167. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +728 -0
  168. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +43 -0
  169. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +414 -0
  170. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +23 -0
  171. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +42 -0
  172. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +527 -0
  173. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +533 -0
  174. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +528 -0
  175. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +534 -0
  176. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +521 -0
  177. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +527 -0
  178. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +517 -0
  179. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +523 -0
  180. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +550 -0
  181. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +556 -0
  182. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +32 -0
  183. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +432 -0
  184. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +42 -0
  185. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +929 -0
  186. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +40 -0
  187. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +244 -0
  188. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +46 -0
  189. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +184 -0
  190. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +454 -0
  191. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +459 -0
  192. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +83 -0
  193. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +88 -0
  194. data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +7 -0
  195. data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +7 -0
  196. data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +7 -0
  197. data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +7 -0
  198. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +44 -0
  199. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +437 -0
  200. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +23 -0
  201. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +57 -0
  202. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +475 -0
  203. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +480 -0
  204. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +590 -0
  205. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +590 -0
  206. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +126 -0
  207. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +68 -0
  208. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +174 -0
  209. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +80 -0
  210. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +68 -0
  211. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +142 -0
  212. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +55 -0
  213. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +1086 -0
  214. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +1092 -0
  215. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +721 -0
  216. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +726 -0
  217. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +723 -0
  218. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +729 -0
  219. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +1164 -0
  220. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +1165 -0
  221. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +562 -0
  222. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +563 -0
  223. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +563 -0
  224. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +565 -0
  225. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +55 -0
  226. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +476 -0
  227. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +485 -0
  228. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +362 -0
  229. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +367 -0
  230. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +43 -0
  231. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +1341 -0
  232. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +581 -0
  233. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +58 -0
  234. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +332 -0
  235. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +329 -0
  236. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +53 -0
  237. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +355 -0
  238. data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +79 -0
  239. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +56 -0
  240. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +399 -0
  241. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +127 -0
  242. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +43 -0
  243. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +253 -0
  244. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +1044 -0
  245. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +49 -0
  246. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +45 -0
  247. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +37 -0
  248. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +1587 -0
  249. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +48 -0
  250. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +1202 -0
  251. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +48 -0
  252. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +484 -0
  253. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +44 -0
  254. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +45 -0
  255. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +37 -0
  256. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +939 -0
  257. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +49 -0
  258. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +1216 -0
  259. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +48 -0
  260. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +45 -0
  261. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +37 -0
  262. data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +290 -0
  263. data/ext/xkcp/lib/low/common/SnP-Relaned.h +141 -0
  264. data/ext/xkcp/support/Build/ExpandProducts.xsl +79 -0
  265. data/ext/xkcp/support/Build/ToGlobalMakefile.xsl +206 -0
  266. data/ext/xkcp/support/Build/ToOneTarget.xsl +89 -0
  267. data/ext/xkcp/support/Build/ToTargetConfigFile.xsl +37 -0
  268. data/ext/xkcp/support/Build/ToTargetMakefile.xsl +298 -0
  269. data/ext/xkcp/support/Build/ToVCXProj.xsl +198 -0
  270. data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +133 -0
  271. data/ext/xkcp/support/Kernel-PMU/Makefile +8 -0
  272. data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +129 -0
  273. data/ext/xkcp/support/Kernel-PMU/load-module +1 -0
  274. data/ext/xkcp/util/KeccakSum/KeccakSum.c +394 -0
  275. data/ext/xkcp/util/KeccakSum/base64.c +86 -0
  276. data/ext/xkcp/util/KeccakSum/base64.h +12 -0
  277. data/lib/sleeping_kangaroo12/binding.rb +15 -0
  278. data/lib/sleeping_kangaroo12/build/loader.rb +40 -0
  279. data/lib/sleeping_kangaroo12/build/platform.rb +37 -0
  280. data/lib/sleeping_kangaroo12/build.rb +4 -0
  281. data/lib/sleeping_kangaroo12/digest.rb +103 -0
  282. data/lib/sleeping_kangaroo12/version.rb +5 -0
  283. data/lib/sleeping_kangaroo12.rb +7 -0
  284. metadata +372 -0
@@ -0,0 +1,52 @@
1
+ /*
2
+ The eXtended Keccak Code Package (XKCP)
3
+ https://github.com/XKCP/XKCP
4
+
5
+ The Keccak-p permutations, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
+
7
+ Implementation by Ronny Van Keer, hereby denoted as "the implementer".
8
+
9
+ For more information, feedback or questions, please refer to the Keccak Team website:
10
+ https://keccak.team/
11
+
12
+ To the extent possible under law, the implementer has waived all copyright
13
+ and related or neighboring rights to the source code in this file.
14
+ http://creativecommons.org/publicdomain/zero/1.0/
15
+
16
+ ---
17
+
18
+ Please refer to SnP-documentation.h for more details.
19
+ */
20
+
21
+ #ifndef _KeccakP_1600_SnP_h_
22
+ #define _KeccakP_1600_SnP_h_
23
+
24
+ #include <stddef.h>
25
+
26
+ #ifdef __MINGW32__
27
+ #define FORCE_SYSV __attribute__((sysv_abi))
28
+ #else
29
+ #define FORCE_SYSV
30
+ #endif
31
+
32
+ #define KeccakP1600_implementation "AVX2 optimized implementation"
33
+ #define KeccakP1600_stateSizeInBytes 200
34
+ #define KeccakP1600_stateAlignment 8
35
+ #define KeccakF1600_FastLoop_supported
36
+ #define KeccakP1600_12rounds_FastLoop_supported
37
+
38
+ #define KeccakP1600_StaticInitialize()
39
+ FORCE_SYSV void KeccakP1600_Initialize(void *state);
40
+ FORCE_SYSV void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
41
+ FORCE_SYSV void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
42
+ FORCE_SYSV void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
43
+ FORCE_SYSV void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
44
+ FORCE_SYSV void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
45
+ FORCE_SYSV void KeccakP1600_Permute_12rounds(void *state);
46
+ FORCE_SYSV void KeccakP1600_Permute_24rounds(void *state);
47
+ FORCE_SYSV void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
48
+ FORCE_SYSV void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
49
+ FORCE_SYSV size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen);
50
+ FORCE_SYSV size_t KeccakP1600_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen);
51
+
52
+ #endif
@@ -0,0 +1,623 @@
1
+ /*
2
+ The eXtended Keccak Code Package (XKCP)
3
+ https://github.com/XKCP/XKCP
4
+
5
+ The Keccak-p permutations, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
+
7
+ Implementation by Ronny Van Keer, hereby denoted as "the implementer".
8
+
9
+ For more information, feedback or questions, please refer to the Keccak Team website:
10
+ https://keccak.team/
11
+
12
+ To the extent possible under law, the implementer has waived all copyright
13
+ and related or neighboring rights to the source code in this file.
14
+ http://creativecommons.org/publicdomain/zero/1.0/
15
+
16
+ ---
17
+
18
+ This file implements Keccak-p[1600] in a SnP-compatible way.
19
+ Please refer to SnP-documentation.h for more details.
20
+
21
+ This implementation comes with KeccakP-1600-SnP.h in the same folder.
22
+ Please refer to LowLevel.build for the exact list of other files it must be combined with.
23
+
24
+ ---
25
+
26
+ We would like to thank Vladimir Sedach, we have used parts of his Keccak AVX-512 C++ code.
27
+ */
28
+
29
+ #include <stdio.h>
30
+ #include <stdlib.h>
31
+ #include <string.h>
32
+ #include <stdint.h>
33
+ #include <smmintrin.h>
34
+ #include <wmmintrin.h>
35
+ #include <immintrin.h>
36
+ #include <emmintrin.h>
37
+ #include "align.h"
38
+ #include "brg_endian.h"
39
+ #include "KeccakP-1600-AVX512-config.h"
40
+
41
+ #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
42
+ #error Expecting a little-endian platform
43
+ #endif
44
+
45
+ #ifdef KeccakP1600_fullUnrolling
46
+ #define FullUnrolling
47
+ #else
48
+ #define Unrolling KeccakP1600_unrolling
49
+ #endif
50
+
51
+ /* Comment the define hereunder when compiling for a CPU with AVX-512 SIMD */
52
+ /*
53
+ * Warning: This code has only been tested on Haswell (AVX2) with SIMULATE_AVX512 defined,
54
+ * errors will occur if we did a bad interpretation of the AVX-512 intrinsics'
55
+ * API or functionality.
56
+ */
57
+ /* #define SIMULATE_AVX512 */
58
+
59
+ #if defined(SIMULATE_AVX512)
60
+
61
+ typedef struct
62
+ {
63
+ uint64_t x[8];
64
+ } __m512i;
65
+
66
+ static __m512i _mm512_xor_si512( __m512i a, __m512i b)
67
+ {
68
+ __m512i r;
69
+ unsigned int i;
70
+
71
+ for ( i = 0; i < 8; ++i )
72
+ r.x[i] = a.x[i] ^ b.x[i];
73
+ return(r);
74
+ }
75
+
76
+ static __m512i _mm512_ternarylogic_epi64(__m512i a, __m512i b, __m512i c, int imm)
77
+ {
78
+
79
+ if (imm == 0x96)
80
+ return ( _mm512_xor_si512( _mm512_xor_si512( a, b ), c ) );
81
+ if (imm == 0xD2) {
82
+ __m512i t;
83
+ unsigned int i;
84
+
85
+ for ( i = 0; i < 8; ++i )
86
+ t.x[i] = ~b.x[i] & c.x[i];
87
+ return ( _mm512_xor_si512( a, t ) );
88
+ }
89
+ printf( "_mm512_ternarylogic_epi64( a, b, c, %02X) not implemented!\n", imm );
90
+ exit(1);
91
+
92
+ }
93
+
94
+ static __m512i _mm512_rol_epi64(__m512i a, int offset)
95
+ {
96
+ __m512i r;
97
+ unsigned int i;
98
+
99
+ for ( i = 0; i < 8; ++i )
100
+ r.x[i] = (a.x[i] << offset) | (a.x[i] >> (64-offset));
101
+ return(r);
102
+ }
103
+
104
+ static __m512i _mm512_rolv_epi64(__m512i a, __m512i offset)
105
+ {
106
+ __m512i r;
107
+ unsigned int i;
108
+
109
+ for ( i = 0; i < 8; ++i )
110
+ r.x[i] = (a.x[i] << offset.x[i]) | (a.x[i] >> (64-offset.x[i]));
111
+ return(r);
112
+ }
113
+
114
+ static __m512i _mm512_setr_epi64(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f, uint64_t g, uint64_t h)
115
+ {
116
+ __m512i r;
117
+
118
+ r.x[0] = a;
119
+ r.x[1] = b;
120
+ r.x[2] = c;
121
+ r.x[3] = d;
122
+ r.x[4] = e;
123
+ r.x[5] = f;
124
+ r.x[6] = g;
125
+ r.x[7] = h;
126
+ return(r);
127
+ }
128
+
129
+ static __m512i _mm512_permutexvar_epi64(__m512i idx, __m512i v)
130
+ {
131
+ __m512i r;
132
+ unsigned int i;
133
+
134
+ for ( i = 0; i < 8; ++i )
135
+ r.x[i] = v.x[idx.x[i]];
136
+ return(r);
137
+ }
138
+
139
+ static __m512i _mm512_permutex2var_epi64(__m512i a, __m512i idx, __m512i b)
140
+ {
141
+ __m512i r;
142
+ unsigned int i;
143
+ unsigned int index;
144
+
145
+ for ( i = 0; i < 8; ++i ) {
146
+ index = idx.x[i] & 7;
147
+ r.x[i] = (idx.x[i] & 8) ? b.x[index] : a.x[index];
148
+ }
149
+ return(r);
150
+ }
151
+
152
+ static __m512i _mm512_unpacklo_epi64(__m512i a, __m512i b)
153
+ {
154
+ __m512i r;
155
+ unsigned int i;
156
+
157
+ for ( i = 0; i < 8; i += 2 ) {
158
+ r.x[i] = a.x[i];
159
+ r.x[i+1] = b.x[i];
160
+ }
161
+ return(r);
162
+ }
163
+
164
+ static __m512i _mm512_unpackhi_epi64(__m512i a, __m512i b)
165
+ {
166
+ __m512i r;
167
+ unsigned int i;
168
+
169
+ for ( i = 0; i < 8; i += 2 ) {
170
+ r.x[i] = a.x[i+1];
171
+ r.x[i+1] = b.x[i+1];
172
+ }
173
+ return(r);
174
+ }
175
+
176
+ static __m512i _mm512_mask_blend_epi64(unsigned char mask, __m512i a, __m512i b)
177
+ {
178
+ __m512i r;
179
+ unsigned int i;
180
+
181
+ for ( i = 0; i < 8; ++i, mask >>= 1 )
182
+ r.x[i] = (mask & 1) ? b.x[i] : a.x[i];
183
+ return(r);
184
+ }
185
+
186
+ static __m512i _mm512_maskz_loadu_epi64( unsigned char mask, const void * a)
187
+ {
188
+ __m512i r;
189
+ unsigned int i;
190
+ const uint64_t *p = a;
191
+
192
+ for ( i = 0; i < 8; ++i, mask >>= 1 )
193
+ r.x[i] = (mask & 1) ? p[i] : 0;
194
+ return(r);
195
+ }
196
+
197
+ static void _mm512_mask_storeu_epi64( void * a, unsigned char mask, __m512i v)
198
+ {
199
+ unsigned int i;
200
+ uint64_t *p = a;
201
+
202
+ for ( i = 0; i < 8; ++i, mask >>= 1 )
203
+ if ( mask & 1 )
204
+ p[i] = v.x[i];
205
+ }
206
+
207
+
208
+ #endif
209
+
210
+ typedef __m512i V512;
211
+
212
+ #define XOR(a,b) _mm512_xor_si512(a,b)
213
+ #define XOR3(a,b,c) _mm512_ternarylogic_epi64(a,b,c,0x96)
214
+ #define XOR5(a,b,c,d,e) XOR3(XOR3(a,b,c),d,e)
215
+ #define ROL(a,offset) _mm512_rol_epi64(a,offset)
216
+ #define Chi(a,b,c) _mm512_ternarylogic_epi64(a,b,c,0xD2)
217
+
218
+ #define LOAD_Lanes(m,a) _mm512_maskz_loadu_epi64(m,a)
219
+ #define LOAD_Lane(a) LOAD_Lanes(0x01,a)
220
+ #define LOAD_Plane(a) LOAD_Lanes(0x1F,a)
221
+ #define LOAD_8Lanes(a) LOAD_Lanes(0xFF,a)
222
+ #define STORE_Lanes(a,m,v) _mm512_mask_storeu_epi64(a,m,v)
223
+ #define STORE_Lane(a,v) STORE_Lanes(a,0x01,v)
224
+ #define STORE_Plane(a,v) STORE_Lanes(a,0x1F,v)
225
+ #define STORE_8Lanes(a,v) STORE_Lanes(a,0xFF,v)
226
+
227
+ /* ---------------------------------------------------------------- */
228
+
229
+ void KeccakP1600_Initialize(void *state)
230
+ {
231
+ memset(state, 0, 1600/8);
232
+ }
233
+
234
+ /* ---------------------------------------------------------------- */
235
+
236
+ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
237
+ {
238
+ uint8_t *stateAsBytes;
239
+ uint64_t *stateAsLanes;
240
+
241
+ for( stateAsBytes = (uint8_t*)state; ((offset % 8) != 0) && (length != 0); ++offset, --length)
242
+ stateAsBytes[offset] ^= *(data++);
243
+ for (stateAsLanes = (uint64_t*)(stateAsBytes + offset); length >= 8*8; stateAsLanes += 8, data += 8*8, length -= 8*8)
244
+ STORE_8Lanes( stateAsLanes, XOR(LOAD_8Lanes(stateAsLanes), LOAD_8Lanes((const uint64_t*)data)));
245
+ for (/* empty */; length >= 8; ++stateAsLanes, data += 8, length -= 8)
246
+ STORE_Lane( stateAsLanes, XOR(LOAD_Lane(stateAsLanes), LOAD_Lane((const uint64_t*)data)));
247
+ for ( stateAsBytes = (uint8_t*)stateAsLanes; length != 0; --length)
248
+ *(stateAsBytes++) ^= *(data++);
249
+ }
250
+
251
+ /* ---------------------------------------------------------------- */
252
+
253
+ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
254
+ {
255
+ memcpy((unsigned char*)state+offset, data, length);
256
+ }
257
+
258
+ /* ---------------------------------------------------------------- */
259
+
260
+ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
261
+ {
262
+ memset(state, 0, byteCount);
263
+ }
264
+
265
+ /* ---------------------------------------------------------------- */
266
+
267
+ void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
268
+ {
269
+ memcpy(data, (unsigned char*)state+offset, length);
270
+ }
271
+
272
+ /* ---------------------------------------------------------------- */
273
+
274
+ void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
275
+ {
276
+ uint8_t *stateAsBytes;
277
+ uint64_t *stateAsLanes;
278
+
279
+ for( stateAsBytes = (uint8_t*)state; ((offset % 8) != 0) && (length != 0); ++offset, --length)
280
+ *(output++) = stateAsBytes[offset] ^ *(input++);
281
+ for (stateAsLanes = (uint64_t*)(stateAsBytes + offset); length >= 8*8; stateAsLanes += 8, input += 8*8, output += 8*8, length -= 8*8)
282
+ STORE_8Lanes( (uint64_t*)output, XOR(LOAD_8Lanes(stateAsLanes), LOAD_8Lanes((const uint64_t*)input)));
283
+ for (/* empty */; length >= 8; ++stateAsLanes, input += 8, output += 8, length -= 8)
284
+ STORE_Lane( (uint64_t*)output, XOR(LOAD_Lane(stateAsLanes), LOAD_Lane((const uint64_t*)input)));
285
+ for ( stateAsBytes = (uint8_t*)stateAsLanes; length != 0; --length)
286
+ *(output++) = *(stateAsBytes++) ^ *(input++);
287
+ }
288
+
289
+ const uint64_t KeccakP1600RoundConstants[24] = {
290
+ 0x0000000000000001ULL,
291
+ 0x0000000000008082ULL,
292
+ 0x800000000000808aULL,
293
+ 0x8000000080008000ULL,
294
+ 0x000000000000808bULL,
295
+ 0x0000000080000001ULL,
296
+ 0x8000000080008081ULL,
297
+ 0x8000000000008009ULL,
298
+ 0x000000000000008aULL,
299
+ 0x0000000000000088ULL,
300
+ 0x0000000080008009ULL,
301
+ 0x000000008000000aULL,
302
+ 0x000000008000808bULL,
303
+ 0x800000000000008bULL,
304
+ 0x8000000000008089ULL,
305
+ 0x8000000000008003ULL,
306
+ 0x8000000000008002ULL,
307
+ 0x8000000000000080ULL,
308
+ 0x000000000000800aULL,
309
+ 0x800000008000000aULL,
310
+ 0x8000000080008081ULL,
311
+ 0x8000000000008080ULL,
312
+ 0x0000000080000001ULL,
313
+ 0x8000000080008008ULL };
314
+
315
+ #define KeccakP_DeclareVars \
316
+ V512 b0, b1, b2, b3, b4; \
317
+ V512 Baeiou, Gaeiou, Kaeiou, Maeiou, Saeiou; \
318
+ V512 moveThetaPrev = _mm512_setr_epi64(4, 0, 1, 2, 3, 5, 6, 7); \
319
+ V512 moveThetaNext = _mm512_setr_epi64(1, 2, 3, 4, 0, 5, 6, 7); \
320
+ V512 rhoB = _mm512_setr_epi64( 0, 1, 62, 28, 27, 0, 0, 0); \
321
+ V512 rhoG = _mm512_setr_epi64(36, 44, 6, 55, 20, 0, 0, 0); \
322
+ V512 rhoK = _mm512_setr_epi64( 3, 10, 43, 25, 39, 0, 0, 0); \
323
+ V512 rhoM = _mm512_setr_epi64(41, 45, 15, 21, 8, 0, 0, 0); \
324
+ V512 rhoS = _mm512_setr_epi64(18, 2, 61, 56, 14, 0, 0, 0); \
325
+ V512 pi1B = _mm512_setr_epi64(0, 3, 1, 4, 2, 5, 6, 7); \
326
+ V512 pi1G = _mm512_setr_epi64(1, 4, 2, 0, 3, 5, 6, 7); \
327
+ V512 pi1K = _mm512_setr_epi64(2, 0, 3, 1, 4, 5, 6, 7); \
328
+ V512 pi1M = _mm512_setr_epi64(3, 1, 4, 2, 0, 5, 6, 7); \
329
+ V512 pi1S = _mm512_setr_epi64(4, 2, 0, 3, 1, 5, 6, 7); \
330
+ V512 pi2S1 = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 0+8, 2+8); \
331
+ V512 pi2S2 = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 1+8, 3+8); \
332
+ V512 pi2BG = _mm512_setr_epi64(0, 1, 0+8, 1+8, 6, 5, 6, 7); \
333
+ V512 pi2KM = _mm512_setr_epi64(2, 3, 2+8, 3+8, 7, 5, 6, 7); \
334
+ V512 pi2S3 = _mm512_setr_epi64(4, 5, 4+8, 5+8, 4, 5, 6, 7);
335
+
336
+ #define copyFromState(pState) \
337
+ Baeiou = LOAD_Plane(pState+ 0); \
338
+ Gaeiou = LOAD_Plane(pState+ 5); \
339
+ Kaeiou = LOAD_Plane(pState+10); \
340
+ Maeiou = LOAD_Plane(pState+15); \
341
+ Saeiou = LOAD_Plane(pState+20);
342
+
343
+ #define copyToState(pState) \
344
+ STORE_Plane(pState+ 0, Baeiou); \
345
+ STORE_Plane(pState+ 5, Gaeiou); \
346
+ STORE_Plane(pState+10, Kaeiou); \
347
+ STORE_Plane(pState+15, Maeiou); \
348
+ STORE_Plane(pState+20, Saeiou);
349
+
350
+ #define KeccakP_Round(i) \
351
+ /* Theta */ \
352
+ b0 = XOR5( Baeiou, Gaeiou, Kaeiou, Maeiou, Saeiou ); \
353
+ b1 = _mm512_permutexvar_epi64(moveThetaPrev, b0); \
354
+ b0 = _mm512_permutexvar_epi64(moveThetaNext, b0); \
355
+ b0 = _mm512_rol_epi64(b0, 1); \
356
+ Baeiou = XOR3( Baeiou, b0, b1 ); \
357
+ Gaeiou = XOR3( Gaeiou, b0, b1 ); \
358
+ Kaeiou = XOR3( Kaeiou, b0, b1 ); \
359
+ Maeiou = XOR3( Maeiou, b0, b1 ); \
360
+ Saeiou = XOR3( Saeiou, b0, b1 ); \
361
+ /* Rho */ \
362
+ Baeiou = _mm512_rolv_epi64(Baeiou, rhoB); \
363
+ Gaeiou = _mm512_rolv_epi64(Gaeiou, rhoG); \
364
+ Kaeiou = _mm512_rolv_epi64(Kaeiou, rhoK); \
365
+ Maeiou = _mm512_rolv_epi64(Maeiou, rhoM); \
366
+ Saeiou = _mm512_rolv_epi64(Saeiou, rhoS); \
367
+ /* Pi 1 */ \
368
+ b0 = _mm512_permutexvar_epi64(pi1B, Baeiou); \
369
+ b1 = _mm512_permutexvar_epi64(pi1G, Gaeiou); \
370
+ b2 = _mm512_permutexvar_epi64(pi1K, Kaeiou); \
371
+ b3 = _mm512_permutexvar_epi64(pi1M, Maeiou); \
372
+ b4 = _mm512_permutexvar_epi64(pi1S, Saeiou); \
373
+ /* Chi */ \
374
+ Baeiou = Chi(b0, b1, b2); \
375
+ Gaeiou = Chi(b1, b2, b3); \
376
+ Kaeiou = Chi(b2, b3, b4); \
377
+ Maeiou = Chi(b3, b4, b0); \
378
+ Saeiou = Chi(b4, b0, b1); \
379
+ /* Iota */ \
380
+ Baeiou = XOR(Baeiou, LOAD_Lane(KeccakP1600RoundConstants+i)); \
381
+ /* Pi 2 */ \
382
+ b0 = _mm512_unpacklo_epi64(Baeiou, Gaeiou); \
383
+ b1 = _mm512_unpacklo_epi64(Kaeiou, Maeiou); \
384
+ b0 = _mm512_permutex2var_epi64(b0, pi2S1, Saeiou); \
385
+ b2 = _mm512_unpackhi_epi64(Baeiou, Gaeiou); \
386
+ b3 = _mm512_unpackhi_epi64(Kaeiou, Maeiou); \
387
+ b2 = _mm512_permutex2var_epi64(b2, pi2S2, Saeiou); \
388
+ Baeiou = _mm512_permutex2var_epi64(b0, pi2BG, b1); \
389
+ Gaeiou = _mm512_permutex2var_epi64(b2, pi2BG, b3); \
390
+ Kaeiou = _mm512_permutex2var_epi64(b0, pi2KM, b1); \
391
+ Maeiou = _mm512_permutex2var_epi64(b2, pi2KM, b3); \
392
+ b0 = _mm512_permutex2var_epi64(b0, pi2S3, b1); \
393
+ Saeiou = _mm512_mask_blend_epi64(0x10, b0, Saeiou)
394
+
395
+ #ifdef FullUnrolling
396
+
397
+ #define rounds12 \
398
+ KeccakP_Round( 12 ); \
399
+ KeccakP_Round( 13 ); \
400
+ KeccakP_Round( 14 ); \
401
+ KeccakP_Round( 15 ); \
402
+ KeccakP_Round( 16 ); \
403
+ KeccakP_Round( 17 ); \
404
+ KeccakP_Round( 18 ); \
405
+ KeccakP_Round( 19 ); \
406
+ KeccakP_Round( 20 ); \
407
+ KeccakP_Round( 21 ); \
408
+ KeccakP_Round( 22 ); \
409
+ KeccakP_Round( 23 )
410
+
411
+ #define rounds24 \
412
+ KeccakP_Round( 0 ); \
413
+ KeccakP_Round( 1 ); \
414
+ KeccakP_Round( 2 ); \
415
+ KeccakP_Round( 3 ); \
416
+ KeccakP_Round( 4 ); \
417
+ KeccakP_Round( 5 ); \
418
+ KeccakP_Round( 6 ); \
419
+ KeccakP_Round( 7 ); \
420
+ KeccakP_Round( 8 ); \
421
+ KeccakP_Round( 9 ); \
422
+ KeccakP_Round( 10 ); \
423
+ KeccakP_Round( 11 ); \
424
+ KeccakP_Round( 12 ); \
425
+ KeccakP_Round( 13 ); \
426
+ KeccakP_Round( 14 ); \
427
+ KeccakP_Round( 15 ); \
428
+ KeccakP_Round( 16 ); \
429
+ KeccakP_Round( 17 ); \
430
+ KeccakP_Round( 18 ); \
431
+ KeccakP_Round( 19 ); \
432
+ KeccakP_Round( 20 ); \
433
+ KeccakP_Round( 21 ); \
434
+ KeccakP_Round( 22 ); \
435
+ KeccakP_Round( 23 )
436
+
437
+ #elif (Unrolling == 6)
438
+
439
+ #define rounds12 \
440
+ i = 12; \
441
+ do { \
442
+ KeccakP_Round( i+ 0 ); \
443
+ KeccakP_Round( i+ 1 ); \
444
+ KeccakP_Round( i+ 2 ); \
445
+ KeccakP_Round( i+ 3 ); \
446
+ KeccakP_Round( i+ 4 ); \
447
+ KeccakP_Round( i+ 5 ); \
448
+ } while( (i += 6) < 24 )
449
+
450
+ #define rounds24 \
451
+ i = 0; \
452
+ do { \
453
+ KeccakP_Round( i+ 0 ); \
454
+ KeccakP_Round( i+ 1 ); \
455
+ KeccakP_Round( i+ 2 ); \
456
+ KeccakP_Round( i+ 3 ); \
457
+ KeccakP_Round( i+ 4 ); \
458
+ KeccakP_Round( i+ 5 ); \
459
+ } while( (i += 6) < 24 )
460
+
461
+ #elif (Unrolling == 12)
462
+
463
+ #define rounds12 \
464
+ KeccakP_Round( 12 ); \
465
+ KeccakP_Round( 13 ); \
466
+ KeccakP_Round( 14 ); \
467
+ KeccakP_Round( 15 ); \
468
+ KeccakP_Round( 16 ); \
469
+ KeccakP_Round( 17 ); \
470
+ KeccakP_Round( 18 ); \
471
+ KeccakP_Round( 19 ); \
472
+ KeccakP_Round( 20 ); \
473
+ KeccakP_Round( 21 ); \
474
+ KeccakP_Round( 22 ); \
475
+ KeccakP_Round( 23 )
476
+
477
+ #define rounds24 \
478
+ i = 0; \
479
+ do { \
480
+ KeccakP_Round( i+ 0 ); \
481
+ KeccakP_Round( i+ 1 ); \
482
+ KeccakP_Round( i+ 2 ); \
483
+ KeccakP_Round( i+ 3 ); \
484
+ KeccakP_Round( i+ 4 ); \
485
+ KeccakP_Round( i+ 5 ); \
486
+ KeccakP_Round( i+ 6 ); \
487
+ KeccakP_Round( i+ 7 ); \
488
+ KeccakP_Round( i+ 8 ); \
489
+ KeccakP_Round( i+ 9 ); \
490
+ KeccakP_Round( i+10 ); \
491
+ KeccakP_Round( i+11 ); \
492
+ } while( (i += 12) < 24 )
493
+
494
+ #else
495
+ #error "Unrolling is not correctly specified!"
496
+ #endif
497
+
498
+ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds)
499
+ {
500
+ KeccakP_DeclareVars
501
+ unsigned int i;
502
+ uint64_t *stateAsLanes = (uint64_t*)state;
503
+
504
+ copyFromState(stateAsLanes);
505
+ if ((nrounds & 1) != 0) {
506
+ KeccakP_Round( 24-nrounds );
507
+ --nrounds;
508
+ }
509
+ if ((nrounds & 2) != 0) {
510
+ KeccakP_Round( 24+0-nrounds );
511
+ KeccakP_Round( 24+1-nrounds );
512
+ nrounds -= 2;
513
+ }
514
+ for (i = 24-nrounds; i < 24; i+= 4) {
515
+ KeccakP_Round( i );
516
+ KeccakP_Round( i+1 );
517
+ KeccakP_Round( i+2 );
518
+ KeccakP_Round( i+3 );
519
+ }
520
+ copyToState(stateAsLanes);
521
+ }
522
+
523
+ /* ---------------------------------------------------------------- */
524
+
525
+ void KeccakP1600_Permute_12rounds(void *state)
526
+ {
527
+ KeccakP_DeclareVars
528
+ #ifndef KeccakP1600_fullUnrolling
529
+ unsigned int i;
530
+ #endif
531
+ uint64_t *stateAsLanes = (uint64_t*)state;
532
+
533
+ copyFromState(stateAsLanes);
534
+ rounds12;
535
+ copyToState(stateAsLanes);
536
+ }
537
+
538
+ /* ---------------------------------------------------------------- */
539
+
540
+ void KeccakP1600_Permute_24rounds(void *state)
541
+ {
542
+ KeccakP_DeclareVars
543
+ #ifndef KeccakP1600_fullUnrolling
544
+ unsigned int i;
545
+ #endif
546
+ uint64_t *stateAsLanes = (uint64_t*)state;
547
+
548
+ copyFromState(stateAsLanes);
549
+ rounds24;
550
+ copyToState(stateAsLanes);
551
+ }
552
+
553
+ size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
554
+ {
555
+ size_t originalDataByteLen = dataByteLen;
556
+
557
+ if (laneCount == 21) {
558
+ KeccakP_DeclareVars;
559
+ #ifndef KeccakP1600_fullUnrolling
560
+ unsigned int i;
561
+ #endif
562
+ uint64_t *stateAsLanes = (uint64_t*)state;
563
+ uint64_t *inDataAsLanes = (uint64_t*)data;
564
+
565
+ copyFromState(stateAsLanes);
566
+ while(dataByteLen >= 21*8) {
567
+ Baeiou = XOR(Baeiou, LOAD_Plane(inDataAsLanes+ 0));
568
+ Gaeiou = XOR(Gaeiou, LOAD_Plane(inDataAsLanes+ 5));
569
+ Kaeiou = XOR(Kaeiou, LOAD_Plane(inDataAsLanes+10));
570
+ Maeiou = XOR(Maeiou, LOAD_Plane(inDataAsLanes+15));
571
+ Saeiou = XOR(Saeiou, LOAD_Lane(inDataAsLanes+20));
572
+ rounds24;
573
+ inDataAsLanes += 21;
574
+ dataByteLen -= 21*8;
575
+ }
576
+ copyToState(stateAsLanes);
577
+ }
578
+ else {
579
+ while(dataByteLen >= laneCount*8) {
580
+ KeccakP1600_AddBytes(state, data, 0, laneCount*8);
581
+ KeccakP1600_Permute_24rounds(state);
582
+ data += laneCount*8;
583
+ dataByteLen -= laneCount*8;
584
+ }
585
+ }
586
+ return originalDataByteLen - dataByteLen;
587
+ }
588
+
589
+ size_t KeccakP1600_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
590
+ {
591
+ size_t originalDataByteLen = dataByteLen;
592
+
593
+ if (laneCount == 21) {
594
+ KeccakP_DeclareVars;
595
+ #if !defined(KeccakP1600_fullUnrolling) && (KeccakP1600_unrolling < 12)
596
+ unsigned int i;
597
+ #endif
598
+ uint64_t *stateAsLanes = (uint64_t*)state;
599
+ uint64_t *inDataAsLanes = (uint64_t*)data;
600
+
601
+ copyFromState(stateAsLanes);
602
+ while(dataByteLen >= 21*8) {
603
+ Baeiou = XOR(Baeiou, LOAD_Plane(inDataAsLanes+ 0));
604
+ Gaeiou = XOR(Gaeiou, LOAD_Plane(inDataAsLanes+ 5));
605
+ Kaeiou = XOR(Kaeiou, LOAD_Plane(inDataAsLanes+10));
606
+ Maeiou = XOR(Maeiou, LOAD_Plane(inDataAsLanes+15));
607
+ Saeiou = XOR(Saeiou, LOAD_Lane(inDataAsLanes+20));
608
+ rounds12;
609
+ inDataAsLanes += 21;
610
+ dataByteLen -= 21*8;
611
+ }
612
+ copyToState(stateAsLanes);
613
+ }
614
+ else {
615
+ while(dataByteLen >= laneCount*8) {
616
+ KeccakP1600_AddBytes(state, data, 0, laneCount*8);
617
+ KeccakP1600_Permute_12rounds(state);
618
+ data += laneCount*8;
619
+ dataByteLen -= laneCount*8;
620
+ }
621
+ }
622
+ return originalDataByteLen - dataByteLen;
623
+ }