sleeping_kangaroo12 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -67
  3. data/ext/Rakefile +12 -37
  4. data/ext/binding/sleeping_kangaroo12.c +1 -16
  5. data/ext/{xkcp → k12}/Makefile +0 -0
  6. data/ext/k12/Makefile.build +118 -0
  7. data/ext/k12/README.markdown +86 -0
  8. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-ARMv8Asha3.S +623 -0
  9. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-SnP.h +65 -0
  10. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-opt64.c +227 -0
  11. data/ext/{xkcp/lib/low/KeccakP-1600/compact → k12/lib/Inplace32BI}/KeccakP-1600-SnP.h +4 -9
  12. data/ext/{xkcp/lib/low/KeccakP-1600/plain-32bits-inplace → k12/lib/Inplace32BI}/KeccakP-1600-inplace32BI.c +65 -160
  13. data/ext/k12/lib/KangarooTwelve.c +332 -0
  14. data/ext/{xkcp/lib/high/KangarooTwelve → k12/lib}/KangarooTwelve.h +53 -16
  15. data/ext/{xkcp/lib/low/KeccakP-1600/AVX2 → k12/lib/Optimized64}/KeccakP-1600-AVX2.s +122 -558
  16. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512-plainC.c +241 -0
  17. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512.s +551 -0
  18. data/ext/k12/lib/Optimized64/KeccakP-1600-SnP.h +74 -0
  19. data/ext/{xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros → k12/lib/Optimized64/KeccakP-1600-opt64.c} +447 -169
  20. data/ext/k12/lib/Optimized64/KeccakP-1600-runtimeDispatch.c +406 -0
  21. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX2.c +419 -0
  22. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX512.c +458 -0
  23. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-SSSE3.c +438 -0
  24. data/ext/{xkcp/lib/low/KeccakP-1600/plain-64bits → k12/lib/Plain64}/KeccakP-1600-SnP.h +14 -20
  25. data/ext/{xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h → k12/lib/Plain64/KeccakP-1600-plain64.c} +9 -8
  26. data/ext/{xkcp/lib/common → k12/lib}/align.h +3 -2
  27. data/ext/{xkcp/lib/common → k12/lib}/brg_endian.h +0 -0
  28. data/ext/{xkcp → k12}/support/Build/ExpandProducts.xsl +0 -0
  29. data/ext/{xkcp → k12}/support/Build/ToGlobalMakefile.xsl +0 -0
  30. data/ext/{xkcp → k12}/support/Build/ToOneTarget.xsl +0 -0
  31. data/ext/{xkcp → k12}/support/Build/ToTargetConfigFile.xsl +0 -0
  32. data/ext/{xkcp → k12}/support/Build/ToTargetMakefile.xsl +10 -16
  33. data/ext/{xkcp → k12}/support/Build/ToVCXProj.xsl +0 -0
  34. data/lib/sleeping_kangaroo12/version.rb +1 -1
  35. metadata +33 -276
  36. data/ext/config/xkcp.build +0 -17
  37. data/ext/xkcp/LICENSE +0 -1
  38. data/ext/xkcp/Makefile.build +0 -200
  39. data/ext/xkcp/README.markdown +0 -296
  40. data/ext/xkcp/lib/HighLevel.build +0 -143
  41. data/ext/xkcp/lib/LowLevel.build +0 -757
  42. data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +0 -301
  43. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +0 -81
  44. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +0 -125
  45. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +0 -48
  46. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +0 -79
  47. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +0 -81
  48. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +0 -73
  49. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +0 -195
  50. data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +0 -111
  51. data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +0 -76
  52. data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +0 -314
  53. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +0 -61
  54. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +0 -67
  55. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +0 -128
  56. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +0 -93
  57. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +0 -599
  58. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +0 -573
  59. data/ext/xkcp/lib/high/Ketje/Ketjev2.c +0 -87
  60. data/ext/xkcp/lib/high/Ketje/Ketjev2.h +0 -88
  61. data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +0 -274
  62. data/ext/xkcp/lib/high/Keyak/Keyakv2.c +0 -132
  63. data/ext/xkcp/lib/high/Keyak/Keyakv2.h +0 -217
  64. data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +0 -81
  65. data/ext/xkcp/lib/high/Keyak/Motorist.inc +0 -953
  66. data/ext/xkcp/lib/high/Kravatte/Kravatte.c +0 -533
  67. data/ext/xkcp/lib/high/Kravatte/Kravatte.h +0 -115
  68. data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +0 -557
  69. data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +0 -247
  70. data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +0 -66
  71. data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +0 -336
  72. data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +0 -26
  73. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +0 -55
  74. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +0 -35
  75. data/ext/xkcp/lib/high/Xoofff/Xoofff.c +0 -634
  76. data/ext/xkcp/lib/high/Xoofff/Xoofff.h +0 -147
  77. data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +0 -483
  78. data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +0 -241
  79. data/ext/xkcp/lib/high/common/Phases.h +0 -25
  80. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +0 -41
  81. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +0 -1666
  82. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +0 -1655
  83. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +0 -1268
  84. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +0 -1264
  85. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +0 -1178
  86. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +0 -1175
  87. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +0 -1338
  88. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +0 -1336
  89. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +0 -1343
  90. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +0 -1339
  91. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +0 -42
  92. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +0 -823
  93. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +0 -831
  94. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +0 -31
  95. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +0 -540
  96. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +0 -42
  97. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +0 -733
  98. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +0 -1121
  99. data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +0 -52
  100. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +0 -623
  101. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +0 -47
  102. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +0 -6
  103. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +0 -6
  104. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +0 -6
  105. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -1031
  106. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +0 -53
  107. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +0 -44
  108. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +0 -476
  109. data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +0 -6
  110. data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +0 -6
  111. data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +0 -305
  112. data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +0 -420
  113. data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +0 -43
  114. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +0 -565
  115. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +0 -7
  116. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +0 -7
  117. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +0 -8
  118. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +0 -6
  119. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +0 -6
  120. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +0 -44
  121. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +0 -23
  122. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +0 -625
  123. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +0 -44
  124. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +0 -440
  125. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +0 -42
  126. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +0 -1196
  127. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +0 -1124
  128. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +0 -1196
  129. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +0 -1392
  130. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +0 -1394
  131. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +0 -42
  132. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +0 -7
  133. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +0 -7
  134. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +0 -7
  135. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +0 -850
  136. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +0 -51
  137. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +0 -957
  138. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +0 -49
  139. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +0 -8
  140. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +0 -8
  141. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +0 -9
  142. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +0 -9
  143. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +0 -45
  144. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +0 -37
  145. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +0 -1321
  146. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +0 -55
  147. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +0 -7
  148. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +0 -7
  149. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +0 -7
  150. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +0 -7
  151. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +0 -7
  152. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +0 -7
  153. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +0 -881
  154. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +0 -51
  155. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +0 -45
  156. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +0 -37
  157. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +0 -45
  158. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +0 -38
  159. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +0 -1615
  160. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +0 -57
  161. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +0 -7
  162. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +0 -7
  163. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +0 -7
  164. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +0 -45
  165. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +0 -37
  166. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +0 -45
  167. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +0 -38
  168. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +0 -45
  169. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +0 -38
  170. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +0 -41
  171. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +0 -442
  172. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +0 -446
  173. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +0 -419
  174. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +0 -427
  175. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +0 -41
  176. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +0 -647
  177. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +0 -39
  178. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +0 -190
  179. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +0 -43
  180. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +0 -412
  181. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +0 -23
  182. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +0 -41
  183. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +0 -454
  184. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +0 -458
  185. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +0 -455
  186. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +0 -458
  187. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +0 -41
  188. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +0 -728
  189. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +0 -43
  190. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +0 -414
  191. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +0 -23
  192. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +0 -42
  193. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +0 -527
  194. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +0 -533
  195. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +0 -528
  196. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +0 -534
  197. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +0 -521
  198. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +0 -527
  199. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +0 -517
  200. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +0 -523
  201. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +0 -550
  202. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +0 -556
  203. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +0 -32
  204. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +0 -432
  205. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +0 -42
  206. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +0 -929
  207. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +0 -40
  208. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +0 -244
  209. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +0 -46
  210. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +0 -184
  211. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +0 -454
  212. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +0 -459
  213. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +0 -83
  214. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +0 -88
  215. data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +0 -7
  216. data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +0 -7
  217. data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +0 -7
  218. data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +0 -7
  219. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +0 -44
  220. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +0 -437
  221. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +0 -23
  222. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +0 -57
  223. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +0 -475
  224. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +0 -480
  225. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +0 -590
  226. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +0 -590
  227. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +0 -126
  228. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +0 -68
  229. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +0 -174
  230. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +0 -80
  231. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +0 -68
  232. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +0 -142
  233. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +0 -55
  234. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +0 -1086
  235. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +0 -1092
  236. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +0 -721
  237. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +0 -726
  238. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +0 -723
  239. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +0 -729
  240. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +0 -1164
  241. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +0 -1165
  242. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +0 -562
  243. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +0 -563
  244. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +0 -563
  245. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +0 -565
  246. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +0 -55
  247. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +0 -476
  248. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +0 -485
  249. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +0 -362
  250. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +0 -367
  251. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +0 -43
  252. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +0 -1341
  253. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +0 -581
  254. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +0 -58
  255. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +0 -332
  256. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +0 -329
  257. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +0 -53
  258. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +0 -355
  259. data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +0 -79
  260. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +0 -56
  261. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +0 -399
  262. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +0 -127
  263. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +0 -43
  264. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +0 -253
  265. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +0 -1044
  266. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +0 -49
  267. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +0 -45
  268. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +0 -37
  269. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +0 -1587
  270. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +0 -48
  271. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +0 -1202
  272. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +0 -48
  273. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +0 -484
  274. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +0 -44
  275. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +0 -45
  276. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +0 -37
  277. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +0 -939
  278. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +0 -49
  279. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +0 -1216
  280. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +0 -48
  281. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +0 -45
  282. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +0 -37
  283. data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +0 -290
  284. data/ext/xkcp/lib/low/common/SnP-Relaned.h +0 -141
  285. data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +0 -133
  286. data/ext/xkcp/support/Kernel-PMU/Makefile +0 -8
  287. data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +0 -129
  288. data/ext/xkcp/support/Kernel-PMU/load-module +0 -1
  289. data/ext/xkcp/util/KeccakSum/KeccakSum.c +0 -394
  290. data/ext/xkcp/util/KeccakSum/base64.c +0 -86
  291. data/ext/xkcp/util/KeccakSum/base64.h +0 -12
@@ -1,5 +1,5 @@
1
1
  /*
2
- The eXtended Keccak Code Package (XKCP)
2
+ K12 based on the eXtended Keccak Code Package (XKCP)
3
3
  https://github.com/XKCP/XKCP
4
4
 
5
5
  The Keccak-p permutations, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
@@ -12,8 +12,241 @@ https://keccak.team/
12
12
  To the extent possible under law, the implementer has waived all copyright
13
13
  and related or neighboring rights to the source code in this file.
14
14
  http://creativecommons.org/publicdomain/zero/1.0/
15
+
16
+ ---
17
+
18
+ Please refer to the XKCP for more details.
15
19
  */
16
20
 
21
+ #include <stdint.h>
22
+ #include <stdlib.h>
23
+ #include <string.h>
24
+ #include "brg_endian.h"
25
+ #include <KeccakP-1600-SnP.h>
26
+
27
+ #define KeccakP1600_opt64_implementation_config "all rounds unrolled"
28
+ #define KeccakP1600_opt64_fullUnrolling
29
+ /* Or */
30
+ /*
31
+ #define KeccakP1600_opt64_implementation_config "6 rounds unrolled"
32
+ #define KeccakP1600_opt64_unrolling 6
33
+ */
34
+ /* Or */
35
+ /*
36
+ #define KeccakP1600_opt64_implementation_config "lane complementing, 6 rounds unrolled"
37
+ #define KeccakP1600_opt64_unrolling 6
38
+ #define KeccakP1600_opt64_useLaneComplementing
39
+ */
40
+ /* Or */
41
+ /*
42
+ #define KeccakP1600_opt64_implementation_config "lane complementing, all rounds unrolled"
43
+ #define KeccakP1600_opt64_fullUnrolling
44
+ #define KeccakP1600_opt64_useLaneComplementing
45
+ */
46
+ /* Or */
47
+ /*
48
+ #define KeccakP1600_opt64_implementation_config "lane complementing, all rounds unrolled, using SHLD for rotations"
49
+ #define KeccakP1600_opt64_fullUnrolling
50
+ #define KeccakP1600_opt64_useLaneComplementing
51
+ #define KeccakP1600_opt64_useSHLD
52
+ */
53
+
54
+ #if defined(KeccakP1600_opt64_useLaneComplementing)
55
+ #define UseBebigokimisa
56
+ #endif
57
+
58
+ #if defined(_MSC_VER)
59
+ #define ROL64(a, offset) _rotl64(a, offset)
60
+ #elif defined(KeccakP1600_opt64_useSHLD)
61
+ #define ROL64(x,N) ({ \
62
+ register uint64_t __out; \
63
+ register uint64_t __in = x; \
64
+ __asm__ ("shld %2,%0,%0" : "=r"(__out) : "0"(__in), "i"(N)); \
65
+ __out; \
66
+ })
67
+ #else
68
+ #define ROL64(a, offset) ((((uint64_t)a) << offset) ^ (((uint64_t)a) >> (64-offset)))
69
+ #endif
70
+
71
+ #ifdef KeccakP1600_opt64_fullUnrolling
72
+ #define FullUnrolling
73
+ #else
74
+ #define Unrolling KeccakP1600_opt64_unrolling
75
+ #endif
76
+
77
+ static const uint64_t KeccakF1600RoundConstants[24] = {
78
+ 0x0000000000000001ULL,
79
+ 0x0000000000008082ULL,
80
+ 0x800000000000808aULL,
81
+ 0x8000000080008000ULL,
82
+ 0x000000000000808bULL,
83
+ 0x0000000080000001ULL,
84
+ 0x8000000080008081ULL,
85
+ 0x8000000000008009ULL,
86
+ 0x000000000000008aULL,
87
+ 0x0000000000000088ULL,
88
+ 0x0000000080008009ULL,
89
+ 0x000000008000000aULL,
90
+ 0x000000008000808bULL,
91
+ 0x800000000000008bULL,
92
+ 0x8000000000008089ULL,
93
+ 0x8000000000008003ULL,
94
+ 0x8000000000008002ULL,
95
+ 0x8000000000000080ULL,
96
+ 0x000000000000800aULL,
97
+ 0x800000008000000aULL,
98
+ 0x8000000080008081ULL,
99
+ 0x8000000000008080ULL,
100
+ 0x0000000080000001ULL,
101
+ 0x8000000080008008ULL };
102
+
103
+ /* ---------------------------------------------------------------- */
104
+
105
+ void KeccakP1600_opt64_Initialize(void *state)
106
+ {
107
+ memset(state, 0, 200);
108
+ #ifdef KeccakP1600_opt64_useLaneComplementing
109
+ ((uint64_t*)state)[ 1] = ~(uint64_t)0;
110
+ ((uint64_t*)state)[ 2] = ~(uint64_t)0;
111
+ ((uint64_t*)state)[ 8] = ~(uint64_t)0;
112
+ ((uint64_t*)state)[12] = ~(uint64_t)0;
113
+ ((uint64_t*)state)[17] = ~(uint64_t)0;
114
+ ((uint64_t*)state)[20] = ~(uint64_t)0;
115
+ #endif
116
+ }
117
+
118
+ /* ---------------------------------------------------------------- */
119
+
120
+ void KeccakP1600_opt64_AddBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
121
+ {
122
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
123
+ uint64_t lane;
124
+ if (length == 0)
125
+ return;
126
+ if (length == 1)
127
+ lane = data[0];
128
+ else {
129
+ lane = 0;
130
+ memcpy(&lane, data, length);
131
+ }
132
+ lane <<= offset*8;
133
+ #else
134
+ uint64_t lane = 0;
135
+ unsigned int i;
136
+ for(i=0; i<length; i++)
137
+ lane |= ((uint64_t)data[i]) << ((i+offset)*8);
138
+ #endif
139
+ ((uint64_t*)state)[lanePosition] ^= lane;
140
+ }
141
+
142
+ /* ---------------------------------------------------------------- */
143
+
144
+ static void KeccakP1600_opt64_AddLanes(void *state, const unsigned char *data, unsigned int laneCount)
145
+ {
146
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
147
+ unsigned int i = 0;
148
+ #ifdef NO_MISALIGNED_ACCESSES
149
+ /* If either pointer is misaligned, fall back to byte-wise xor. */
150
+ if (((((uintptr_t)state) & 7) != 0) || ((((uintptr_t)data) & 7) != 0)) {
151
+ for (i = 0; i < laneCount * 8; i++) {
152
+ ((unsigned char*)state)[i] ^= data[i];
153
+ }
154
+ }
155
+ else
156
+ #endif
157
+ {
158
+ /* Otherwise... */
159
+ for( ; (i+8)<=laneCount; i+=8) {
160
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
161
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
162
+ ((uint64_t*)state)[i+2] ^= ((uint64_t*)data)[i+2];
163
+ ((uint64_t*)state)[i+3] ^= ((uint64_t*)data)[i+3];
164
+ ((uint64_t*)state)[i+4] ^= ((uint64_t*)data)[i+4];
165
+ ((uint64_t*)state)[i+5] ^= ((uint64_t*)data)[i+5];
166
+ ((uint64_t*)state)[i+6] ^= ((uint64_t*)data)[i+6];
167
+ ((uint64_t*)state)[i+7] ^= ((uint64_t*)data)[i+7];
168
+ }
169
+ for( ; (i+4)<=laneCount; i+=4) {
170
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
171
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
172
+ ((uint64_t*)state)[i+2] ^= ((uint64_t*)data)[i+2];
173
+ ((uint64_t*)state)[i+3] ^= ((uint64_t*)data)[i+3];
174
+ }
175
+ for( ; (i+2)<=laneCount; i+=2) {
176
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
177
+ ((uint64_t*)state)[i+1] ^= ((uint64_t*)data)[i+1];
178
+ }
179
+ if (i<laneCount) {
180
+ ((uint64_t*)state)[i+0] ^= ((uint64_t*)data)[i+0];
181
+ }
182
+ }
183
+ #else
184
+ unsigned int i;
185
+ const uint8_t *curData = data;
186
+ for(i=0; i<laneCount; i++, curData+=8) {
187
+ uint64_t lane = (uint64_t)curData[0]
188
+ | ((uint64_t)curData[1] << 8)
189
+ | ((uint64_t)curData[2] << 16)
190
+ | ((uint64_t)curData[3] << 24)
191
+ | ((uint64_t)curData[4] << 32)
192
+ | ((uint64_t)curData[5] << 40)
193
+ | ((uint64_t)curData[6] << 48)
194
+ | ((uint64_t)curData[7] << 56);
195
+ ((uint64_t*)state)[i] ^= lane;
196
+ }
197
+ #endif
198
+ }
199
+
200
+ /* ---------------------------------------------------------------- */
201
+
202
+ void KeccakP1600_opt64_AddByte(void *state, unsigned char byte, unsigned int offset)
203
+ {
204
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
205
+ ((unsigned char*)(state))[offset] ^= byte;
206
+ #else
207
+ uint64_t lane = byte;
208
+ lane <<= (offset%8)*8;
209
+ ((uint64_t*)state)[offset/8] ^= lane;
210
+ #endif
211
+ }
212
+
213
+ /* ---------------------------------------------------------------- */
214
+
215
+ #define SnP_AddBytes(state, data, offset, length, SnP_AddLanes, SnP_AddBytesInLane, SnP_laneLengthInBytes) \
216
+ { \
217
+ if ((offset) == 0) { \
218
+ SnP_AddLanes(state, data, (length)/SnP_laneLengthInBytes); \
219
+ SnP_AddBytesInLane(state, \
220
+ (length)/SnP_laneLengthInBytes, \
221
+ (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
222
+ 0, \
223
+ (length)%SnP_laneLengthInBytes); \
224
+ } \
225
+ else { \
226
+ unsigned int _sizeLeft = (length); \
227
+ unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
228
+ unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
229
+ const unsigned char *_curData = (data); \
230
+ while(_sizeLeft > 0) { \
231
+ unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
232
+ if (_bytesInLane > _sizeLeft) \
233
+ _bytesInLane = _sizeLeft; \
234
+ SnP_AddBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
235
+ _sizeLeft -= _bytesInLane; \
236
+ _lanePosition++; \
237
+ _offsetInLane = 0; \
238
+ _curData += _bytesInLane; \
239
+ } \
240
+ } \
241
+ }
242
+
243
+ void KeccakP1600_opt64_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
244
+ {
245
+ SnP_AddBytes(state, data, offset, length, KeccakP1600_opt64_AddLanes, KeccakP1600_opt64_AddBytesInLane, 8);
246
+ }
247
+
248
+ /* ---------------------------------------------------------------- */
249
+
17
250
  #define declareABCDE \
18
251
  uint64_t Aba, Abe, Abi, Abo, Abu; \
19
252
  uint64_t Aga, Age, Agi, Ago, Agu; \
@@ -539,6 +772,193 @@ http://creativecommons.org/publicdomain/zero/1.0/
539
772
  X##so = Y##so; \
540
773
  X##su = Y##su; \
541
774
 
775
+ #if ((defined(FullUnrolling)) || (Unrolling == 12))
776
+ #define rounds12 \
777
+ prepareTheta \
778
+ thetaRhoPiChiIotaPrepareTheta(12, A, E) \
779
+ thetaRhoPiChiIotaPrepareTheta(13, E, A) \
780
+ thetaRhoPiChiIotaPrepareTheta(14, A, E) \
781
+ thetaRhoPiChiIotaPrepareTheta(15, E, A) \
782
+ thetaRhoPiChiIotaPrepareTheta(16, A, E) \
783
+ thetaRhoPiChiIotaPrepareTheta(17, E, A) \
784
+ thetaRhoPiChiIotaPrepareTheta(18, A, E) \
785
+ thetaRhoPiChiIotaPrepareTheta(19, E, A) \
786
+ thetaRhoPiChiIotaPrepareTheta(20, A, E) \
787
+ thetaRhoPiChiIotaPrepareTheta(21, E, A) \
788
+ thetaRhoPiChiIotaPrepareTheta(22, A, E) \
789
+ thetaRhoPiChiIota(23, E, A) \
790
+
791
+ #elif (Unrolling == 6)
792
+ #define rounds12 \
793
+ prepareTheta \
794
+ for(i=12; i<24; i+=6) { \
795
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
796
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
797
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
798
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
799
+ thetaRhoPiChiIotaPrepareTheta(i+4, A, E) \
800
+ thetaRhoPiChiIotaPrepareTheta(i+5, E, A) \
801
+ } \
802
+
803
+ #elif (Unrolling == 4)
804
+ #define rounds12 \
805
+ prepareTheta \
806
+ for(i=12; i<24; i+=4) { \
807
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
808
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
809
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
810
+ thetaRhoPiChiIotaPrepareTheta(i+3, E, A) \
811
+ } \
812
+
813
+ #elif (Unrolling == 3)
814
+ #define rounds12 \
815
+ prepareTheta \
816
+ for(i=12; i<24; i+=3) { \
817
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
818
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
819
+ thetaRhoPiChiIotaPrepareTheta(i+2, A, E) \
820
+ copyStateVariables(A, E) \
821
+ } \
822
+
823
+ #elif (Unrolling == 2)
824
+ #define rounds12 \
825
+ prepareTheta \
826
+ for(i=12; i<24; i+=2) { \
827
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
828
+ thetaRhoPiChiIotaPrepareTheta(i+1, E, A) \
829
+ } \
830
+
831
+ #elif (Unrolling == 1)
832
+ #define rounds12 \
833
+ prepareTheta \
834
+ for(i=12; i<24; i++) { \
835
+ thetaRhoPiChiIotaPrepareTheta(i , A, E) \
836
+ copyStateVariables(A, E) \
837
+ } \
838
+
839
+ #else
840
+ #error "Unrolling is not correctly specified!"
841
+ #endif
842
+
843
+ void KeccakP1600_opt64_Permute_12rounds(void *state)
844
+ {
845
+ declareABCDE
846
+ #ifndef KeccakP1600_opt64_fullUnrolling
847
+ unsigned int i;
848
+ #endif
849
+ uint64_t *stateAsLanes = (uint64_t*)state;
850
+
851
+ copyFromState(A, stateAsLanes)
852
+ rounds12
853
+ copyToState(stateAsLanes, A)
854
+ }
855
+
856
+ /* ---------------------------------------------------------------- */
857
+
858
+ void KeccakP1600_opt64_ExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length)
859
+ {
860
+ uint64_t lane = ((uint64_t*)state)[lanePosition];
861
+ #ifdef KeccakP1600_opt64_useLaneComplementing
862
+ if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
863
+ lane = ~lane;
864
+ #endif
865
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
866
+ {
867
+ uint64_t lane1[1];
868
+ lane1[0] = lane;
869
+ memcpy(data, (uint8_t*)lane1+offset, length);
870
+ }
871
+ #else
872
+ unsigned int i;
873
+ lane >>= offset*8;
874
+ for(i=0; i<length; i++) {
875
+ data[i] = lane & 0xFF;
876
+ lane >>= 8;
877
+ }
878
+ #endif
879
+ }
880
+
881
+ /* ---------------------------------------------------------------- */
882
+
883
+ #if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
884
+ static void fromWordToBytes(uint8_t *bytes, const uint64_t word)
885
+ {
886
+ unsigned int i;
887
+
888
+ for(i=0; i<(64/8); i++)
889
+ bytes[i] = (word >> (8*i)) & 0xFF;
890
+ }
891
+ #endif
892
+
893
+ void KeccakP1600_opt64_ExtractLanes(const void *state, unsigned char *data, unsigned int laneCount)
894
+ {
895
+ #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
896
+ memcpy(data, state, laneCount*8);
897
+ #else
898
+ unsigned int i;
899
+
900
+ for(i=0; i<laneCount; i++)
901
+ fromWordToBytes(data+(i*8), ((const uint64_t*)state)[i]);
902
+ #endif
903
+ #ifdef KeccakP1600_opt64_useLaneComplementing
904
+ if (laneCount > 1) {
905
+ ((uint64_t*)data)[ 1] = ~((uint64_t*)data)[ 1];
906
+ if (laneCount > 2) {
907
+ ((uint64_t*)data)[ 2] = ~((uint64_t*)data)[ 2];
908
+ if (laneCount > 8) {
909
+ ((uint64_t*)data)[ 8] = ~((uint64_t*)data)[ 8];
910
+ if (laneCount > 12) {
911
+ ((uint64_t*)data)[12] = ~((uint64_t*)data)[12];
912
+ if (laneCount > 17) {
913
+ ((uint64_t*)data)[17] = ~((uint64_t*)data)[17];
914
+ if (laneCount > 20) {
915
+ ((uint64_t*)data)[20] = ~((uint64_t*)data)[20];
916
+ }
917
+ }
918
+ }
919
+ }
920
+ }
921
+ }
922
+ #endif
923
+ }
924
+
925
+ /* ---------------------------------------------------------------- */
926
+
927
+ #define SnP_ExtractBytes(state, data, offset, length, SnP_ExtractLanes, SnP_ExtractBytesInLane, SnP_laneLengthInBytes) \
928
+ { \
929
+ if ((offset) == 0) { \
930
+ SnP_ExtractLanes(state, data, (length)/SnP_laneLengthInBytes); \
931
+ SnP_ExtractBytesInLane(state, \
932
+ (length)/SnP_laneLengthInBytes, \
933
+ (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
934
+ 0, \
935
+ (length)%SnP_laneLengthInBytes); \
936
+ } \
937
+ else { \
938
+ unsigned int _sizeLeft = (length); \
939
+ unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
940
+ unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
941
+ unsigned char *_curData = (data); \
942
+ while(_sizeLeft > 0) { \
943
+ unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLane; \
944
+ if (_bytesInLane > _sizeLeft) \
945
+ _bytesInLane = _sizeLeft; \
946
+ SnP_ExtractBytesInLane(state, _lanePosition, _curData, _offsetInLane, _bytesInLane); \
947
+ _sizeLeft -= _bytesInLane; \
948
+ _lanePosition++; \
949
+ _offsetInLane = 0; \
950
+ _curData += _bytesInLane; \
951
+ } \
952
+ } \
953
+ }
954
+
955
+ void KeccakP1600_opt64_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
956
+ {
957
+ SnP_ExtractBytes(state, data, offset, length, KeccakP1600_opt64_ExtractLanes, KeccakP1600_opt64_ExtractBytesInLane, 8);
958
+ }
959
+
960
+ /* ---------------------------------------------------------------- */
961
+
542
962
  #if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
543
963
  #define HTOLE64(x) (x)
544
964
  #else
@@ -577,172 +997,30 @@ http://creativecommons.org/publicdomain/zero/1.0/
577
997
  X##mu ^= HTOLE64(input[19]); \
578
998
  X##sa ^= HTOLE64(input[20]); \
579
999
  } \
580
- else if (laneCount < 16) { \
581
- if (laneCount < 8) { \
582
- if (laneCount < 4) { \
583
- if (laneCount < 2) { \
584
- if (laneCount < 1) { \
585
- } \
586
- else { \
587
- X##ba ^= HTOLE64(input[ 0]); \
588
- } \
589
- } \
590
- else { \
591
- X##ba ^= HTOLE64(input[ 0]); \
592
- X##be ^= HTOLE64(input[ 1]); \
593
- if (laneCount < 3) { \
594
- } \
595
- else { \
596
- X##bi ^= HTOLE64(input[ 2]); \
597
- } \
598
- } \
599
- } \
600
- else { \
601
- X##ba ^= HTOLE64(input[ 0]); \
602
- X##be ^= HTOLE64(input[ 1]); \
603
- X##bi ^= HTOLE64(input[ 2]); \
604
- X##bo ^= HTOLE64(input[ 3]); \
605
- if (laneCount < 6) { \
606
- if (laneCount < 5) { \
607
- } \
608
- else { \
609
- X##bu ^= HTOLE64(input[ 4]); \
610
- } \
611
- } \
612
- else { \
613
- X##bu ^= HTOLE64(input[ 4]); \
614
- X##ga ^= HTOLE64(input[ 5]); \
615
- if (laneCount < 7) { \
616
- } \
617
- else { \
618
- X##ge ^= HTOLE64(input[ 6]); \
619
- } \
620
- } \
621
- } \
622
- } \
623
- else { \
624
- X##ba ^= HTOLE64(input[ 0]); \
625
- X##be ^= HTOLE64(input[ 1]); \
626
- X##bi ^= HTOLE64(input[ 2]); \
627
- X##bo ^= HTOLE64(input[ 3]); \
628
- X##bu ^= HTOLE64(input[ 4]); \
629
- X##ga ^= HTOLE64(input[ 5]); \
630
- X##ge ^= HTOLE64(input[ 6]); \
631
- X##gi ^= HTOLE64(input[ 7]); \
632
- if (laneCount < 12) { \
633
- if (laneCount < 10) { \
634
- if (laneCount < 9) { \
635
- } \
636
- else { \
637
- X##go ^= HTOLE64(input[ 8]); \
638
- } \
639
- } \
640
- else { \
641
- X##go ^= HTOLE64(input[ 8]); \
642
- X##gu ^= HTOLE64(input[ 9]); \
643
- if (laneCount < 11) { \
644
- } \
645
- else { \
646
- X##ka ^= HTOLE64(input[10]); \
647
- } \
648
- } \
649
- } \
650
- else { \
651
- X##go ^= HTOLE64(input[ 8]); \
652
- X##gu ^= HTOLE64(input[ 9]); \
653
- X##ka ^= HTOLE64(input[10]); \
654
- X##ke ^= HTOLE64(input[11]); \
655
- if (laneCount < 14) { \
656
- if (laneCount < 13) { \
657
- } \
658
- else { \
659
- X##ki ^= HTOLE64(input[12]); \
660
- } \
661
- } \
662
- else { \
663
- X##ki ^= HTOLE64(input[12]); \
664
- X##ko ^= HTOLE64(input[13]); \
665
- if (laneCount < 15) { \
666
- } \
667
- else { \
668
- X##ku ^= HTOLE64(input[14]); \
669
- } \
670
- } \
671
- } \
672
- } \
673
- } \
674
- else { \
675
- X##ba ^= HTOLE64(input[ 0]); \
676
- X##be ^= HTOLE64(input[ 1]); \
677
- X##bi ^= HTOLE64(input[ 2]); \
678
- X##bo ^= HTOLE64(input[ 3]); \
679
- X##bu ^= HTOLE64(input[ 4]); \
680
- X##ga ^= HTOLE64(input[ 5]); \
681
- X##ge ^= HTOLE64(input[ 6]); \
682
- X##gi ^= HTOLE64(input[ 7]); \
683
- X##go ^= HTOLE64(input[ 8]); \
684
- X##gu ^= HTOLE64(input[ 9]); \
685
- X##ka ^= HTOLE64(input[10]); \
686
- X##ke ^= HTOLE64(input[11]); \
687
- X##ki ^= HTOLE64(input[12]); \
688
- X##ko ^= HTOLE64(input[13]); \
689
- X##ku ^= HTOLE64(input[14]); \
690
- X##ma ^= HTOLE64(input[15]); \
691
- if (laneCount < 24) { \
692
- if (laneCount < 20) { \
693
- if (laneCount < 18) { \
694
- if (laneCount < 17) { \
695
- } \
696
- else { \
697
- X##me ^= HTOLE64(input[16]); \
698
- } \
699
- } \
700
- else { \
701
- X##me ^= HTOLE64(input[16]); \
702
- X##mi ^= HTOLE64(input[17]); \
703
- if (laneCount < 19) { \
704
- } \
705
- else { \
706
- X##mo ^= HTOLE64(input[18]); \
707
- } \
708
- } \
709
- } \
710
- else { \
711
- X##me ^= HTOLE64(input[16]); \
712
- X##mi ^= HTOLE64(input[17]); \
713
- X##mo ^= HTOLE64(input[18]); \
714
- X##mu ^= HTOLE64(input[19]); \
715
- if (laneCount < 22) { \
716
- if (laneCount < 21) { \
717
- } \
718
- else { \
719
- X##sa ^= HTOLE64(input[20]); \
720
- } \
721
- } \
722
- else { \
723
- X##sa ^= HTOLE64(input[20]); \
724
- X##se ^= HTOLE64(input[21]); \
725
- if (laneCount < 23) { \
726
- } \
727
- else { \
728
- X##si ^= HTOLE64(input[22]); \
729
- } \
730
- } \
731
- } \
732
- } \
733
- else { \
734
- X##me ^= HTOLE64(input[16]); \
735
- X##mi ^= HTOLE64(input[17]); \
736
- X##mo ^= HTOLE64(input[18]); \
737
- X##mu ^= HTOLE64(input[19]); \
738
- X##sa ^= HTOLE64(input[20]); \
739
- X##se ^= HTOLE64(input[21]); \
740
- X##si ^= HTOLE64(input[22]); \
741
- X##so ^= HTOLE64(input[23]); \
742
- if (laneCount < 25) { \
743
- } \
744
- else { \
745
- X##su ^= HTOLE64(input[24]); \
746
- } \
747
- } \
1000
+
1001
+ #include <assert.h>
1002
+
1003
+ size_t KeccakP1600_opt64_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
1004
+ {
1005
+ size_t originalDataByteLen = dataByteLen;
1006
+ declareABCDE
1007
+ #ifndef KeccakP1600_opt64_fullUnrolling
1008
+ unsigned int i;
1009
+ #endif
1010
+ uint64_t *stateAsLanes = (uint64_t*)state;
1011
+ uint64_t *inDataAsLanes = (uint64_t*)data;
1012
+
1013
+ assert(laneCount == 21);
1014
+
1015
+ #define laneCount 21
1016
+ copyFromState(A, stateAsLanes)
1017
+ while(dataByteLen >= laneCount*8) {
1018
+ addInput(A, inDataAsLanes, laneCount)
1019
+ rounds12
1020
+ inDataAsLanes += laneCount;
1021
+ dataByteLen -= laneCount*8;
748
1022
  }
1023
+ #undef laneCount
1024
+ copyToState(stateAsLanes, A)
1025
+ return originalDataByteLen - dataByteLen;
1026
+ }