sleeping_kangaroo12 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,54 @@
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 Gilles Van Assche and 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 "brg_endian.h"
25
+ #include "KeccakP-1600-opt64-config.h"
26
+
27
+ #define KeccakP1600_implementation "generic 64-bit optimized implementation (" KeccakP1600_implementation_config ")"
28
+ #define KeccakP1600_stateSizeInBytes 200
29
+ #define KeccakP1600_stateAlignment 8
30
+ #define KeccakF1600_FastLoop_supported
31
+ #define KeccakP1600_12rounds_FastLoop_supported
32
+
33
+ #include <stddef.h>
34
+
35
+ #define KeccakP1600_StaticInitialize()
36
+ void KeccakP1600_Initialize(void *state);
37
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
38
+ #define KeccakP1600_AddByte(state, byte, offset) \
39
+ ((unsigned char*)(state))[(offset)] ^= (byte)
40
+ #else
41
+ void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
42
+ #endif
43
+ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
44
+ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
45
+ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
46
+ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
47
+ void KeccakP1600_Permute_12rounds(void *state);
48
+ void KeccakP1600_Permute_24rounds(void *state);
49
+ void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
50
+ void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
51
+ size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen);
52
+ size_t KeccakP1600_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen);
53
+
54
+ #endif
@@ -0,0 +1,565 @@
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 Gilles Van Assche and 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
+ #include <stdint.h>
26
+ #include <string.h>
27
+ #include <stdlib.h>
28
+ #include "brg_endian.h"
29
+ #include "KeccakP-1600-opt64-config.h"
30
+
31
+ #if defined(KeccakP1600_useLaneComplementing)
32
+ #define UseBebigokimisa
33
+ #endif
34
+
35
+ #if defined(_MSC_VER)
36
+ #define ROL64(a, offset) _rotl64(a, offset)
37
+ #elif defined(KeccakP1600_useSHLD)
38
+ #define ROL64(x,N) ({ \
39
+ register uint64_t __out; \
40
+ register uint64_t __in = x; \
41
+ __asm__ ("shld %2,%0,%0" : "=r"(__out) : "0"(__in), "i"(N)); \
42
+ __out; \
43
+ })
44
+ #else
45
+ #define ROL64(a, offset) ((((uint64_t)a) << offset) ^ (((uint64_t)a) >> (64-offset)))
46
+ #endif
47
+
48
+ #include "KeccakP-1600-64.macros"
49
+ #ifdef KeccakP1600_fullUnrolling
50
+ #define FullUnrolling
51
+ #else
52
+ #define Unrolling KeccakP1600_unrolling
53
+ #endif
54
+ #include "KeccakP-1600-unrolling.macros"
55
+ #include "SnP-Relaned.h"
56
+
57
+ static const uint64_t KeccakF1600RoundConstants[24] = {
58
+ 0x0000000000000001ULL,
59
+ 0x0000000000008082ULL,
60
+ 0x800000000000808aULL,
61
+ 0x8000000080008000ULL,
62
+ 0x000000000000808bULL,
63
+ 0x0000000080000001ULL,
64
+ 0x8000000080008081ULL,
65
+ 0x8000000000008009ULL,
66
+ 0x000000000000008aULL,
67
+ 0x0000000000000088ULL,
68
+ 0x0000000080008009ULL,
69
+ 0x000000008000000aULL,
70
+ 0x000000008000808bULL,
71
+ 0x800000000000008bULL,
72
+ 0x8000000000008089ULL,
73
+ 0x8000000000008003ULL,
74
+ 0x8000000000008002ULL,
75
+ 0x8000000000000080ULL,
76
+ 0x000000000000800aULL,
77
+ 0x800000008000000aULL,
78
+ 0x8000000080008081ULL,
79
+ 0x8000000000008080ULL,
80
+ 0x0000000080000001ULL,
81
+ 0x8000000080008008ULL };
82
+
83
+ /* ---------------------------------------------------------------- */
84
+
85
+ void KeccakP1600_Initialize(void *state)
86
+ {
87
+ memset(state, 0, 200);
88
+ #ifdef KeccakP1600_useLaneComplementing
89
+ ((uint64_t*)state)[ 1] = ~(uint64_t)0;
90
+ ((uint64_t*)state)[ 2] = ~(uint64_t)0;
91
+ ((uint64_t*)state)[ 8] = ~(uint64_t)0;
92
+ ((uint64_t*)state)[12] = ~(uint64_t)0;
93
+ ((uint64_t*)state)[17] = ~(uint64_t)0;
94
+ ((uint64_t*)state)[20] = ~(uint64_t)0;
95
+ #endif
96
+ }
97
+
98
+ /* ---------------------------------------------------------------- */
99
+
100
+ void KeccakP1600_AddBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
101
+ {
102
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
103
+ uint64_t lane;
104
+ if (length == 0)
105
+ return;
106
+ if (length == 1)
107
+ lane = data[0];
108
+ else {
109
+ lane = 0;
110
+ memcpy(&lane, data, length);
111
+ }
112
+ lane <<= offset*8;
113
+ #else
114
+ uint64_t lane = 0;
115
+ unsigned int i;
116
+ for(i=0; i<length; i++)
117
+ lane |= ((uint64_t)data[i]) << ((i+offset)*8);
118
+ #endif
119
+ ((uint64_t*)state)[lanePosition] ^= lane;
120
+ }
121
+
122
+ /* ---------------------------------------------------------------- */
123
+
124
+ void KeccakP1600_AddLanes(void *state, const unsigned char *data, unsigned int laneCount)
125
+ {
126
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
127
+ unsigned int i = 0;
128
+ #ifdef NO_MISALIGNED_ACCESSES
129
+ /* If either pointer is misaligned, fall back to byte-wise xor. */
130
+ if (((((uintptr_t)state) & 7) != 0) || ((((uintptr_t)data) & 7) != 0)) {
131
+ for (i = 0; i < laneCount * 8; i++) {
132
+ ((unsigned char*)state)[i] ^= data[i];
133
+ }
134
+ }
135
+ else
136
+ #endif
137
+ {
138
+ /* Otherwise... */
139
+ for( ; (i+8)<=laneCount; i+=8) {
140
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
141
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
142
+ ((uint64_t*)state)[i+2] ^= ((uint64_t*)data)[i+2];
143
+ ((uint64_t*)state)[i+3] ^= ((uint64_t*)data)[i+3];
144
+ ((uint64_t*)state)[i+4] ^= ((uint64_t*)data)[i+4];
145
+ ((uint64_t*)state)[i+5] ^= ((uint64_t*)data)[i+5];
146
+ ((uint64_t*)state)[i+6] ^= ((uint64_t*)data)[i+6];
147
+ ((uint64_t*)state)[i+7] ^= ((uint64_t*)data)[i+7];
148
+ }
149
+ for( ; (i+4)<=laneCount; i+=4) {
150
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
151
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
152
+ ((uint64_t*)state)[i+2] ^= ((uint64_t*)data)[i+2];
153
+ ((uint64_t*)state)[i+3] ^= ((uint64_t*)data)[i+3];
154
+ }
155
+ for( ; (i+2)<=laneCount; i+=2) {
156
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
157
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
158
+ }
159
+ if (i<laneCount) {
160
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
161
+ }
162
+ }
163
+ #else
164
+ unsigned int i;
165
+ const uint8_t *curData = data;
166
+ for(i=0; i<laneCount; i++, curData+=8) {
167
+ uint64_t lane = (uint64_t)curData[0]
168
+ | ((uint64_t)curData[1] << 8)
169
+ | ((uint64_t)curData[2] << 16)
170
+ | ((uint64_t)curData[3] << 24)
171
+ | ((uint64_t)curData[4] << 32)
172
+ | ((uint64_t)curData[5] << 40)
173
+ | ((uint64_t)curData[6] << 48)
174
+ | ((uint64_t)curData[7] << 56);
175
+ ((uint64_t*)state)[i] ^= lane;
176
+ }
177
+ #endif
178
+ }
179
+
180
+ /* ---------------------------------------------------------------- */
181
+
182
+ #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
183
+ void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset)
184
+ {
185
+ uint64_t lane = byte;
186
+ lane <<= (offset%8)*8;
187
+ ((uint64_t*)state)[offset/8] ^= lane;
188
+ }
189
+ #endif
190
+
191
+ /* ---------------------------------------------------------------- */
192
+
193
+ void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
194
+ {
195
+ SnP_AddBytes(state, data, offset, length, KeccakP1600_AddLanes, KeccakP1600_AddBytesInLane, 8);
196
+ }
197
+
198
+ /* ---------------------------------------------------------------- */
199
+
200
+ void KeccakP1600_OverwriteBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
201
+ {
202
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
203
+ #ifdef KeccakP1600_useLaneComplementing
204
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20)) {
205
+ unsigned int i;
206
+ for(i=0; i<length; i++)
207
+ ((unsigned char*)state)[lanePosition*8+offset+i] = ~data[i];
208
+ }
209
+ else
210
+ #endif
211
+ {
212
+ memcpy((unsigned char*)state+lanePosition*8+offset, data, length);
213
+ }
214
+ #else
215
+ uint64_t lane = ((uint64_t*)state)[lanePosition];
216
+ unsigned int i;
217
+ for(i=0; i<length; i++) {
218
+ lane &= ~((uint64_t)0xFF << ((offset+i)*8));
219
+ #ifdef KeccakP1600_useLaneComplementing
220
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
221
+ lane |= (uint64_t)(data[i] ^ 0xFF) << ((offset+i)*8);
222
+ else
223
+ #endif
224
+ lane |= (uint64_t)data[i] << ((offset+i)*8);
225
+ }
226
+ ((uint64_t*)state)[lanePosition] = lane;
227
+ #endif
228
+ }
229
+
230
+ /* ---------------------------------------------------------------- */
231
+
232
+ void KeccakP1600_OverwriteLanes(void *state, const unsigned char *data, unsigned int laneCount)
233
+ {
234
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
235
+ #ifdef KeccakP1600_useLaneComplementing
236
+ unsigned int lanePosition;
237
+
238
+ for(lanePosition=0; lanePosition<laneCount; lanePosition++)
239
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
240
+ ((uint64_t*)state)[lanePosition] = ~((const uint64_t*)data)[lanePosition];
241
+ else
242
+ ((uint64_t*)state)[lanePosition] = ((const uint64_t*)data)[lanePosition];
243
+ #else
244
+ memcpy(state, data, laneCount*8);
245
+ #endif
246
+ #else
247
+ unsigned int lanePosition;
248
+ const uint8_t *curData = data;
249
+ for(lanePosition=0; lanePosition<laneCount; lanePosition++, curData+=8) {
250
+ uint64_t lane = (uint64_t)curData[0]
251
+ | ((uint64_t)curData[1] << 8)
252
+ | ((uint64_t)curData[2] << 16)
253
+ | ((uint64_t)curData[3] << 24)
254
+ | ((uint64_t)curData[4] << 32)
255
+ | ((uint64_t)curData[5] << 40)
256
+ | ((uint64_t)curData[6] << 48)
257
+ | ((uint64_t)curData[7] << 56);
258
+ #ifdef KeccakP1600_useLaneComplementing
259
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
260
+ ((uint64_t*)state)[lanePosition] = ~lane;
261
+ else
262
+ #endif
263
+ ((uint64_t*)state)[lanePosition] = lane;
264
+ }
265
+ #endif
266
+ }
267
+
268
+ /* ---------------------------------------------------------------- */
269
+
270
+ void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
271
+ {
272
+ SnP_OverwriteBytes(state, data, offset, length, KeccakP1600_OverwriteLanes, KeccakP1600_OverwriteBytesInLane, 8);
273
+ }
274
+
275
+ /* ---------------------------------------------------------------- */
276
+
277
+ void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
278
+ {
279
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
280
+ #ifdef KeccakP1600_useLaneComplementing
281
+ unsigned int lanePosition;
282
+
283
+ for(lanePosition=0; lanePosition<byteCount/8; lanePosition++)
284
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
285
+ ((uint64_t*)state)[lanePosition] = ~0;
286
+ else
287
+ ((uint64_t*)state)[lanePosition] = 0;
288
+ if (byteCount%8 != 0) {
289
+ lanePosition = byteCount/8;
290
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
291
+ memset((unsigned char*)state+lanePosition*8, 0xFF, byteCount%8);
292
+ else
293
+ memset((unsigned char*)state+lanePosition*8, 0, byteCount%8);
294
+ }
295
+ #else
296
+ memset(state, 0, byteCount);
297
+ #endif
298
+ #else
299
+ unsigned int i, j;
300
+ for(i=0; i<byteCount; i+=8) {
301
+ unsigned int lanePosition = i/8;
302
+ if (i+8 <= byteCount) {
303
+ #ifdef KeccakP1600_useLaneComplementing
304
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
305
+ ((uint64_t*)state)[lanePosition] = ~(uint64_t)0;
306
+ else
307
+ #endif
308
+ ((uint64_t*)state)[lanePosition] = 0;
309
+ }
310
+ else {
311
+ uint64_t lane = ((uint64_t*)state)[lanePosition];
312
+ for(j=0; j<byteCount%8; j++) {
313
+ #ifdef KeccakP1600_useLaneComplementing
314
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
315
+ lane |= (uint64_t)0xFF << (j*8);
316
+ else
317
+ #endif
318
+ lane &= ~((uint64_t)0xFF << (j*8));
319
+ }
320
+ ((uint64_t*)state)[lanePosition] = lane;
321
+ }
322
+ }
323
+ #endif
324
+ }
325
+
326
+ /* ---------------------------------------------------------------- */
327
+
328
+ void KeccakP1600_Permute_Nrounds(void *state, unsigned int nr)
329
+ {
330
+ declareABCDE
331
+ unsigned int i;
332
+ uint64_t *stateAsLanes = (uint64_t*)state;
333
+
334
+ copyFromState(A, stateAsLanes)
335
+ roundsN(nr)
336
+ copyToState(stateAsLanes, A)
337
+
338
+ }
339
+
340
+ /* ---------------------------------------------------------------- */
341
+
342
+ void KeccakP1600_Permute_24rounds(void *state)
343
+ {
344
+ declareABCDE
345
+ #ifndef KeccakP1600_fullUnrolling
346
+ unsigned int i;
347
+ #endif
348
+ uint64_t *stateAsLanes = (uint64_t*)state;
349
+
350
+ copyFromState(A, stateAsLanes)
351
+ rounds24
352
+ copyToState(stateAsLanes, A)
353
+ }
354
+
355
+ /* ---------------------------------------------------------------- */
356
+
357
+ void KeccakP1600_Permute_12rounds(void *state)
358
+ {
359
+ declareABCDE
360
+ #ifndef KeccakP1600_fullUnrolling
361
+ unsigned int i;
362
+ #endif
363
+ uint64_t *stateAsLanes = (uint64_t*)state;
364
+
365
+ copyFromState(A, stateAsLanes)
366
+ rounds12
367
+ copyToState(stateAsLanes, A)
368
+ }
369
+
370
+ /* ---------------------------------------------------------------- */
371
+
372
+ void KeccakP1600_ExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length)
373
+ {
374
+ uint64_t lane = ((uint64_t*)state)[lanePosition];
375
+ #ifdef KeccakP1600_useLaneComplementing
376
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
377
+ lane = ~lane;
378
+ #endif
379
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
380
+ {
381
+ uint64_t lane1[1];
382
+ lane1[0] = lane;
383
+ memcpy(data, (uint8_t*)lane1+offset, length);
384
+ }
385
+ #else
386
+ unsigned int i;
387
+ lane >>= offset*8;
388
+ for(i=0; i<length; i++) {
389
+ data[i] = lane & 0xFF;
390
+ lane >>= 8;
391
+ }
392
+ #endif
393
+ }
394
+
395
+ /* ---------------------------------------------------------------- */
396
+
397
+ #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
398
+ static void fromWordToBytes(uint8_t *bytes, const uint64_t word)
399
+ {
400
+ unsigned int i;
401
+
402
+ for(i=0; i<(64/8); i++)
403
+ bytes[i] = (word >> (8*i)) & 0xFF;
404
+ }
405
+ #endif
406
+
407
+ void KeccakP1600_ExtractLanes(const void *state, unsigned char *data, unsigned int laneCount)
408
+ {
409
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
410
+ memcpy(data, state, laneCount*8);
411
+ #else
412
+ unsigned int i;
413
+
414
+ for(i=0; i<laneCount; i++)
415
+ fromWordToBytes(data+(i*8), ((const uint64_t*)state)[i]);
416
+ #endif
417
+ #ifdef KeccakP1600_useLaneComplementing
418
+ if (laneCount > 1) {
419
+ ((uint64_t*)data)[ 1] = ~((uint64_t*)data)[ 1];
420
+ if (laneCount > 2) {
421
+ ((uint64_t*)data)[ 2] = ~((uint64_t*)data)[ 2];
422
+ if (laneCount > 8) {
423
+ ((uint64_t*)data)[ 8] = ~((uint64_t*)data)[ 8];
424
+ if (laneCount > 12) {
425
+ ((uint64_t*)data)[12] = ~((uint64_t*)data)[12];
426
+ if (laneCount > 17) {
427
+ ((uint64_t*)data)[17] = ~((uint64_t*)data)[17];
428
+ if (laneCount > 20) {
429
+ ((uint64_t*)data)[20] = ~((uint64_t*)data)[20];
430
+ }
431
+ }
432
+ }
433
+ }
434
+ }
435
+ }
436
+ #endif
437
+ }
438
+
439
+ /* ---------------------------------------------------------------- */
440
+
441
+ void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
442
+ {
443
+ SnP_ExtractBytes(state, data, offset, length, KeccakP1600_ExtractLanes, KeccakP1600_ExtractBytesInLane, 8);
444
+ }
445
+
446
+ /* ---------------------------------------------------------------- */
447
+
448
+ void KeccakP1600_ExtractAndAddBytesInLane(const void *state, unsigned int lanePosition, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
449
+ {
450
+ uint64_t lane = ((uint64_t*)state)[lanePosition];
451
+ #ifdef KeccakP1600_useLaneComplementing
452
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
453
+ lane = ~lane;
454
+ #endif
455
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
456
+ {
457
+ unsigned int i;
458
+ uint64_t lane1[1];
459
+ lane1[0] = lane;
460
+ for(i=0; i<length; i++)
461
+ output[i] = input[i] ^ ((uint8_t*)lane1)[offset+i];
462
+ }
463
+ #else
464
+ unsigned int i;
465
+ lane >>= offset*8;
466
+ for(i=0; i<length; i++) {
467
+ output[i] = input[i] ^ (lane & 0xFF);
468
+ lane >>= 8;
469
+ }
470
+ #endif
471
+ }
472
+
473
+ /* ---------------------------------------------------------------- */
474
+
475
+ void KeccakP1600_ExtractAndAddLanes(const void *state, const unsigned char *input, unsigned char *output, unsigned int laneCount)
476
+ {
477
+ unsigned int i;
478
+ #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
479
+ unsigned char temp[8];
480
+ unsigned int j;
481
+ #endif
482
+
483
+ for(i=0; i<laneCount; i++) {
484
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
485
+ ((uint64_t*)output)[i] = ((uint64_t*)input)[i] ^ ((const uint64_t*)state)[i];
486
+ #else
487
+ fromWordToBytes(temp, ((const uint64_t*)state)[i]);
488
+ for(j=0; j<8; j++)
489
+ output[i*8+j] = input[i*8+j] ^ temp[j];
490
+ #endif
491
+ }
492
+ #ifdef KeccakP1600_useLaneComplementing
493
+ if (laneCount > 1) {
494
+ ((uint64_t*)output)[ 1] = ~((uint64_t*)output)[ 1];
495
+ if (laneCount > 2) {
496
+ ((uint64_t*)output)[ 2] = ~((uint64_t*)output)[ 2];
497
+ if (laneCount > 8) {
498
+ ((uint64_t*)output)[ 8] = ~((uint64_t*)output)[ 8];
499
+ if (laneCount > 12) {
500
+ ((uint64_t*)output)[12] = ~((uint64_t*)output)[12];
501
+ if (laneCount > 17) {
502
+ ((uint64_t*)output)[17] = ~((uint64_t*)output)[17];
503
+ if (laneCount > 20) {
504
+ ((uint64_t*)output)[20] = ~((uint64_t*)output)[20];
505
+ }
506
+ }
507
+ }
508
+ }
509
+ }
510
+ }
511
+ #endif
512
+ }
513
+
514
+ /* ---------------------------------------------------------------- */
515
+
516
+ void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
517
+ {
518
+ SnP_ExtractAndAddBytes(state, input, output, offset, length, KeccakP1600_ExtractAndAddLanes, KeccakP1600_ExtractAndAddBytesInLane, 8);
519
+ }
520
+
521
+ /* ---------------------------------------------------------------- */
522
+
523
+ size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
524
+ {
525
+ size_t originalDataByteLen = dataByteLen;
526
+ declareABCDE
527
+ #ifndef KeccakP1600_fullUnrolling
528
+ unsigned int i;
529
+ #endif
530
+ uint64_t *stateAsLanes = (uint64_t*)state;
531
+ uint64_t *inDataAsLanes = (uint64_t*)data;
532
+
533
+ copyFromState(A, stateAsLanes)
534
+ while(dataByteLen >= laneCount*8) {
535
+ addInput(A, inDataAsLanes, laneCount)
536
+ rounds24
537
+ inDataAsLanes += laneCount;
538
+ dataByteLen -= laneCount*8;
539
+ }
540
+ copyToState(stateAsLanes, A)
541
+ return originalDataByteLen - dataByteLen;
542
+ }
543
+
544
+ /* ---------------------------------------------------------------- */
545
+
546
+ size_t KeccakP1600_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
547
+ {
548
+ size_t originalDataByteLen = dataByteLen;
549
+ declareABCDE
550
+ #ifndef KeccakP1600_fullUnrolling
551
+ unsigned int i;
552
+ #endif
553
+ uint64_t *stateAsLanes = (uint64_t*)state;
554
+ uint64_t *inDataAsLanes = (uint64_t*)data;
555
+
556
+ copyFromState(A, stateAsLanes)
557
+ while(dataByteLen >= laneCount*8) {
558
+ addInput(A, inDataAsLanes, laneCount)
559
+ rounds12
560
+ inDataAsLanes += laneCount;
561
+ dataByteLen -= laneCount*8;
562
+ }
563
+ copyToState(stateAsLanes, A)
564
+ return originalDataByteLen - dataByteLen;
565
+ }
@@ -0,0 +1,7 @@
1
+ /*
2
+ This file defines some parameters of the implementation in the parent directory.
3
+ */
4
+
5
+ #define KeccakP1600_implementation_config "lane complementing, 6 rounds unrolled"
6
+ #define KeccakP1600_unrolling 6
7
+ #define KeccakP1600_useLaneComplementing
@@ -0,0 +1,7 @@
1
+ /*
2
+ This file defines some parameters of the implementation in the parent directory.
3
+ */
4
+
5
+ #define KeccakP1600_implementation_config "lane complementing, all rounds unrolled"
6
+ #define KeccakP1600_fullUnrolling
7
+ #define KeccakP1600_useLaneComplementing
@@ -0,0 +1,8 @@
1
+ /*
2
+ This file defines some parameters of the implementation in the parent directory.
3
+ */
4
+
5
+ #define KeccakP1600_implementation_config "lane complementing, all rounds unrolled, using SHLD for rotations"
6
+ #define KeccakP1600_fullUnrolling
7
+ #define KeccakP1600_useLaneComplementing
8
+ #define KeccakP1600_useSHLD
@@ -0,0 +1,6 @@
1
+ /*
2
+ This file defines some parameters of the implementation in the parent directory.
3
+ */
4
+
5
+ #define KeccakP1600_implementation_config "6 rounds unrolled"
6
+ #define KeccakP1600_unrolling 6
@@ -0,0 +1,6 @@
1
+ /*
2
+ This file defines some parameters of the implementation in the parent directory.
3
+ */
4
+
5
+ #define KeccakP1600_implementation_config "all rounds unrolled"
6
+ #define KeccakP1600_fullUnrolling