sleeping_kangaroo12 0.0.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +27 -0
  3. data/README.md +48 -53
  4. data/ext/Rakefile +12 -37
  5. data/ext/binding/sleeping_kangaroo12.c +1 -16
  6. data/ext/{xkcp → k12}/Makefile +0 -0
  7. data/ext/k12/Makefile.build +118 -0
  8. data/ext/k12/README.markdown +86 -0
  9. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-ARMv8Asha3.S +623 -0
  10. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-SnP.h +65 -0
  11. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-opt64.c +227 -0
  12. data/ext/{xkcp/lib/low/KeccakP-1600/compact → k12/lib/Inplace32BI}/KeccakP-1600-SnP.h +4 -9
  13. data/ext/{xkcp/lib/low/KeccakP-1600/plain-32bits-inplace → k12/lib/Inplace32BI}/KeccakP-1600-inplace32BI.c +65 -160
  14. data/ext/k12/lib/KangarooTwelve.c +332 -0
  15. data/ext/{xkcp/lib/high/KangarooTwelve → k12/lib}/KangarooTwelve.h +53 -16
  16. data/ext/{xkcp/lib/low/KeccakP-1600/AVX2 → k12/lib/Optimized64}/KeccakP-1600-AVX2.s +122 -558
  17. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512-plainC.c +241 -0
  18. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512.s +551 -0
  19. data/ext/k12/lib/Optimized64/KeccakP-1600-SnP.h +74 -0
  20. data/ext/{xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros → k12/lib/Optimized64/KeccakP-1600-opt64.c} +447 -169
  21. data/ext/k12/lib/Optimized64/KeccakP-1600-runtimeDispatch.c +406 -0
  22. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX2.c +419 -0
  23. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX512.c +458 -0
  24. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-SSSE3.c +438 -0
  25. data/ext/{xkcp/lib/low/KeccakP-1600/plain-64bits → k12/lib/Plain64}/KeccakP-1600-SnP.h +14 -20
  26. data/ext/{xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h → k12/lib/Plain64/KeccakP-1600-plain64.c} +9 -8
  27. data/ext/{xkcp/lib/common → k12/lib}/align.h +3 -2
  28. data/ext/{xkcp/lib/common → k12/lib}/brg_endian.h +0 -0
  29. data/ext/{xkcp → k12}/support/Build/ExpandProducts.xsl +0 -0
  30. data/ext/{xkcp → k12}/support/Build/ToGlobalMakefile.xsl +0 -0
  31. data/ext/{xkcp → k12}/support/Build/ToOneTarget.xsl +0 -0
  32. data/ext/{xkcp → k12}/support/Build/ToTargetConfigFile.xsl +0 -0
  33. data/ext/{xkcp → k12}/support/Build/ToTargetMakefile.xsl +10 -16
  34. data/ext/{xkcp → k12}/support/Build/ToVCXProj.xsl +0 -0
  35. data/lib/sleeping_kangaroo12/binding.rb +2 -1
  36. data/lib/sleeping_kangaroo12/build/loader.rb +1 -0
  37. data/lib/sleeping_kangaroo12/build/platform.rb +1 -0
  38. data/lib/sleeping_kangaroo12/digest.rb +38 -4
  39. data/lib/sleeping_kangaroo12/version.rb +1 -1
  40. metadata +48 -288
  41. data/ext/config/xkcp.build +0 -17
  42. data/ext/xkcp/LICENSE +0 -1
  43. data/ext/xkcp/Makefile.build +0 -200
  44. data/ext/xkcp/README.markdown +0 -296
  45. data/ext/xkcp/lib/HighLevel.build +0 -143
  46. data/ext/xkcp/lib/LowLevel.build +0 -757
  47. data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +0 -301
  48. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +0 -81
  49. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +0 -125
  50. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +0 -48
  51. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +0 -79
  52. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +0 -81
  53. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +0 -73
  54. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +0 -195
  55. data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +0 -111
  56. data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +0 -76
  57. data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +0 -314
  58. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +0 -61
  59. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +0 -67
  60. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +0 -128
  61. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +0 -93
  62. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +0 -599
  63. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +0 -573
  64. data/ext/xkcp/lib/high/Ketje/Ketjev2.c +0 -87
  65. data/ext/xkcp/lib/high/Ketje/Ketjev2.h +0 -88
  66. data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +0 -274
  67. data/ext/xkcp/lib/high/Keyak/Keyakv2.c +0 -132
  68. data/ext/xkcp/lib/high/Keyak/Keyakv2.h +0 -217
  69. data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +0 -81
  70. data/ext/xkcp/lib/high/Keyak/Motorist.inc +0 -953
  71. data/ext/xkcp/lib/high/Kravatte/Kravatte.c +0 -533
  72. data/ext/xkcp/lib/high/Kravatte/Kravatte.h +0 -115
  73. data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +0 -557
  74. data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +0 -247
  75. data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +0 -66
  76. data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +0 -336
  77. data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +0 -26
  78. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +0 -55
  79. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +0 -35
  80. data/ext/xkcp/lib/high/Xoofff/Xoofff.c +0 -634
  81. data/ext/xkcp/lib/high/Xoofff/Xoofff.h +0 -147
  82. data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +0 -483
  83. data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +0 -241
  84. data/ext/xkcp/lib/high/common/Phases.h +0 -25
  85. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +0 -41
  86. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +0 -1666
  87. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +0 -1655
  88. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +0 -1268
  89. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +0 -1264
  90. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +0 -1178
  91. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +0 -1175
  92. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +0 -1338
  93. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +0 -1336
  94. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +0 -1343
  95. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +0 -1339
  96. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +0 -42
  97. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +0 -823
  98. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +0 -831
  99. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +0 -31
  100. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +0 -540
  101. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +0 -42
  102. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +0 -733
  103. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +0 -1121
  104. data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +0 -52
  105. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +0 -623
  106. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +0 -47
  107. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +0 -6
  108. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +0 -6
  109. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +0 -6
  110. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -1031
  111. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +0 -53
  112. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +0 -44
  113. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +0 -476
  114. data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +0 -6
  115. data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +0 -6
  116. data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +0 -305
  117. data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +0 -420
  118. data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +0 -43
  119. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +0 -565
  120. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +0 -7
  121. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +0 -7
  122. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +0 -8
  123. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +0 -6
  124. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +0 -6
  125. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +0 -44
  126. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +0 -23
  127. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +0 -625
  128. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +0 -44
  129. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +0 -440
  130. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +0 -42
  131. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +0 -1196
  132. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +0 -1124
  133. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +0 -1196
  134. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +0 -1392
  135. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +0 -1394
  136. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +0 -42
  137. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +0 -7
  138. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +0 -7
  139. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +0 -7
  140. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +0 -850
  141. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +0 -51
  142. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +0 -957
  143. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +0 -49
  144. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +0 -8
  145. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +0 -8
  146. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +0 -9
  147. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +0 -9
  148. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +0 -45
  149. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +0 -37
  150. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +0 -1321
  151. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +0 -55
  152. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +0 -7
  153. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +0 -7
  154. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +0 -7
  155. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +0 -7
  156. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +0 -7
  157. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +0 -7
  158. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +0 -881
  159. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +0 -51
  160. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +0 -45
  161. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +0 -37
  162. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +0 -45
  163. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +0 -38
  164. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +0 -1615
  165. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +0 -57
  166. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +0 -7
  167. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +0 -7
  168. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +0 -7
  169. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +0 -45
  170. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +0 -37
  171. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +0 -45
  172. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +0 -38
  173. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +0 -45
  174. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +0 -38
  175. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +0 -41
  176. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +0 -442
  177. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +0 -446
  178. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +0 -419
  179. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +0 -427
  180. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +0 -41
  181. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +0 -647
  182. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +0 -39
  183. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +0 -190
  184. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +0 -43
  185. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +0 -412
  186. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +0 -23
  187. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +0 -41
  188. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +0 -454
  189. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +0 -458
  190. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +0 -455
  191. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +0 -458
  192. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +0 -41
  193. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +0 -728
  194. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +0 -43
  195. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +0 -414
  196. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +0 -23
  197. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +0 -42
  198. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +0 -527
  199. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +0 -533
  200. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +0 -528
  201. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +0 -534
  202. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +0 -521
  203. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +0 -527
  204. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +0 -517
  205. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +0 -523
  206. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +0 -550
  207. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +0 -556
  208. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +0 -32
  209. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +0 -432
  210. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +0 -42
  211. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +0 -929
  212. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +0 -40
  213. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +0 -244
  214. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +0 -46
  215. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +0 -184
  216. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +0 -454
  217. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +0 -459
  218. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +0 -83
  219. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +0 -88
  220. data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +0 -7
  221. data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +0 -7
  222. data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +0 -7
  223. data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +0 -7
  224. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +0 -44
  225. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +0 -437
  226. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +0 -23
  227. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +0 -57
  228. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +0 -475
  229. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +0 -480
  230. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +0 -590
  231. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +0 -590
  232. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +0 -126
  233. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +0 -68
  234. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +0 -174
  235. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +0 -80
  236. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +0 -68
  237. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +0 -142
  238. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +0 -55
  239. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +0 -1086
  240. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +0 -1092
  241. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +0 -721
  242. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +0 -726
  243. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +0 -723
  244. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +0 -729
  245. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +0 -1164
  246. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +0 -1165
  247. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +0 -562
  248. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +0 -563
  249. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +0 -563
  250. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +0 -565
  251. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +0 -55
  252. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +0 -476
  253. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +0 -485
  254. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +0 -362
  255. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +0 -367
  256. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +0 -43
  257. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +0 -1341
  258. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +0 -581
  259. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +0 -58
  260. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +0 -332
  261. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +0 -329
  262. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +0 -53
  263. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +0 -355
  264. data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +0 -79
  265. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +0 -56
  266. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +0 -399
  267. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +0 -127
  268. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +0 -43
  269. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +0 -253
  270. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +0 -1044
  271. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +0 -49
  272. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +0 -45
  273. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +0 -37
  274. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +0 -1587
  275. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +0 -48
  276. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +0 -1202
  277. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +0 -48
  278. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +0 -484
  279. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +0 -44
  280. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +0 -45
  281. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +0 -37
  282. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +0 -939
  283. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +0 -49
  284. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +0 -1216
  285. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +0 -48
  286. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +0 -45
  287. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +0 -37
  288. data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +0 -290
  289. data/ext/xkcp/lib/low/common/SnP-Relaned.h +0 -141
  290. data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +0 -133
  291. data/ext/xkcp/support/Kernel-PMU/Makefile +0 -8
  292. data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +0 -129
  293. data/ext/xkcp/support/Kernel-PMU/load-module +0 -1
  294. data/ext/xkcp/util/KeccakSum/KeccakSum.c +0 -394
  295. data/ext/xkcp/util/KeccakSum/base64.c +0 -86
  296. data/ext/xkcp/util/KeccakSum/base64.h +0 -12
@@ -1,52 +0,0 @@
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
@@ -1,623 +0,0 @@
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
- }