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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78f06d260dbd9fb1a3519e169c2ad485458c052059ab01052f6e69b1ecc9a145
4
- data.tar.gz: 386fdd73caa218e6dc8176c20cabf69e771cc2390026bd7863055a67cfeaa622
3
+ metadata.gz: 6b89369bac3beb3d85045ea6f94f2c0d995d4e72e04a1887f83818b308e4bae7
4
+ data.tar.gz: 464479f5b0d85d7d6c5453e208fc287b5637f1fcc99769101aeee75e9dd2ec58
5
5
  SHA512:
6
- metadata.gz: 4fd121f2cf9c76cf4132e7f4599a379164773ee66ca576c98f0d0a8e4688b92e06013f64a013fca2d0ae9f3fed795932f23e53a806aa17f631c97579eefa3c49
7
- data.tar.gz: 2dc91a661191d1c398904e7633b168437cff077673bed942e5c20065c9c7f6e69d79b4ae6ab8cb3d08967689d4700ead12e5a9d29f89b260f6ab00b29f3740f5
6
+ metadata.gz: 7514b62f2f38a373d055f71dd6acce85ab37554403bc3fb294e2b516e768133120134469d29d81b69be36f6804dd002439ce49e9208bf6831d7e99d359bee21a
7
+ data.tar.gz: 4a5dea0068e28db9180e65c3469863f9c6ada04948866999efe788c1ef941d7eebfdb6d1a18a816175b6dbd85d653d8f83bdd6613514c70e3c907245ee75911e
data/README.md CHANGED
@@ -25,29 +25,22 @@ gem is sleeping. :-D
25
25
 
26
26
  ## What are specials?
27
27
 
28
- Many!
29
- Just take a peek at the code, you'll notice that:
30
-
31
- - It builds on top of the [eXtended Keccak Code Package (XKCP)](https://github.com/XKCP/XKCP), an easy-to-use and highly
28
+ - It builds on top of the [K12](https://github.com/XKCP/K12), an easy-to-use and highly
32
29
  optimized library maintained by the Keccak team themselves.
33
- - The binding auto-select and detects CPU features on installation, it supports `AVX512`, `AVX2`, and `SSSE3`
34
- instruction sets out of the box. And able to run on a machine without special instruction sets.
35
- - Thin and stable binding; designed by a proper software architect
30
+ - The instruction set `AVX512`, `AVX2`, and `SSSE3` will be detected at runtime to select the optimization dynamically.
31
+ - Thin and stable binding layer
36
32
  - Not limited to [Matz's Ruby Interpreter (MRI)](https://en.wikipedia.org/wiki/Ruby_MRI), this is due to the gem opting
37
- for [Ruby-FFI](https://github.com/ffi/ffi) instead of native extensions.
33
+ for [Ruby-FFI](https://github.com/ffi/ffi) instead of using the API exposed by `ruby.h`.
38
34
  (I only tested on MRI, though.)
39
- - Compared to other hash functions, this binding actually shipped with the optimized implementation. Some
40
- other hash function might looks more performant on benchmarks, this may or may not translated to real-world
41
- performance.
42
35
 
43
36
  ## Prerequisites
44
37
 
45
- In order to install the gem, your machine should be ready to build the XKCP package. Which mean you should prepare:
38
+ In order to install the gem, your machine should be ready to build the K12 package. Which mean you should prepare:
46
39
 
47
40
  - GCC, the GNU Compiler Collection; our favorite
48
41
  - GNU make
49
42
  - xsltproc executable, normally comes with libxslt package
50
- - And for the sake of completeness: Ruby, Bundler, and Ruby related stuffs
43
+ - Ruby related stuffs
51
44
 
52
45
  ## Installation
53
46
 
@@ -61,20 +54,6 @@ And then execute:
61
54
 
62
55
  $ bundle install
63
56
 
64
- ## Related to containers
65
-
66
- OK, now, we have another issue since we detect CPU features on installation.
67
-
68
- What if we want to build the container image, says Docker image, locally but deploy on a server.
69
- Chances are our workstation is using more recent CPU than the server.
70
-
71
- I would recommend recompilation on container starts, simply do:
72
- ~~~
73
- bundle exec gem pristine sleeping_kangaroo12
74
- ~~~
75
- before the command, you actually want to run.
76
- This will trigger the recompilation of SleepingKangaroo12.
77
-
78
57
  ## Usage Examples
79
58
 
80
59
  Test vectors stolen
@@ -82,58 +61,46 @@ from [konsolebox/digest-kangarootwelve-ruby](https://github.com/konsolebox/diges
82
61
  binding.
83
62
 
84
63
  ~~~ruby
85
- # Shortcuts
86
- #
87
- ::SleepingKangaroo12::Digest.digest('abc')
88
- # Output: "\xAB\x17O2\x8CU\xA5Q\v\v \x97\x91\xBF\x8B`\xE8\x01\xA7\xCF\xC2\xAAB\x04-\xCB\x8FT\x7F\xBE:}"
89
- #
64
+ # basic usage
90
65
  ::SleepingKangaroo12::Digest.hexdigest('abc')
91
- # Output: "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
66
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
92
67
 
93
- # Multiple updates
94
- #
68
+ # streaming
95
69
  digest = ::SleepingKangaroo12::Digest.new
96
- digest.update('a')
97
- digest.update('b')
98
- digest.update('c')
70
+ digest << 'a'
71
+ digest << 'b'
72
+ digest << 'c'
99
73
  digest.hexdigest
100
- # Output: "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
74
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
75
+ # `<<` is an alias of `update`, use the one you like
101
76
 
102
- # Hashing with a key, similar to HMAC
103
- # KangarooTwelve call the key "customization", it is the same thing, FYI
104
- #
77
+ # keyed hash (AKA: customization)
105
78
  digest = ::SleepingKangaroo12::Digest.new(key: 'secret')
106
79
  digest << 'abc' # alternate form of update method
107
80
  digest.hexdigest
108
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
109
- # HMAC requires 2 parses of hashing, the customization is definitely faster
81
+ # => "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
110
82
 
111
- # You can control the output length too
112
- #
113
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 5)
114
- digest << 'abc'
115
- digest.hexdigest
116
- # Output: "dc1fd53f85"
117
- # This is marginally faster than truncating the output yourself.
118
- #
119
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 64)
83
+ # shortcuts
84
+ ::SleepingKangaroo12::Digest.digest('abc')
85
+ # => "\xAB\x17O2\x8CU\xA5Q\v\v \x97\x91\xBF\x8B`\xE8\x01\xA7\xCF\xC2\xAAB\x04-\xCB\x8FT\x7F\xBE:}"
86
+ ::SleepingKangaroo12::Digest.hexdigest('abc', key: 'secret')
87
+ # => "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
88
+ ::SleepingKangaroo12::Digest.base64digest('abc', output_length: 24)
89
+ # => "qxdPMoxVpVELCyCXkb+LYOgBp8/CqkIE"
90
+ # `digest`, `hexdigest`, and `base64digest` are available as shortcuts and also on `Digest` instances.
91
+ # Same for the options, you may use `key`, `key_seed`, and `output_length` on both instance methods and shortcuts
92
+
93
+ # XOF (extendable-output functions)
94
+ digest = ::SleepingKangaroo12::Digest.new(output_length: 64)
120
95
  digest << 'abc'
121
96
  digest.hexdigest
122
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03fc4b18c621b57dbb8967094b160dbf22ee42402d7e3d45ecab4b02ef0db14b105"
123
- # The output is longer now, but the security claim is still the same.
124
- # (as 256-bit output length, which translated to the security level of 128-bit)
125
-
126
- # Weird parameters
127
- #
128
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 1_000_000_000_000)
129
- # This will error; I arbitrary set the limit at 1MiB - 1 bytes as a safety measure. Same for length <= 0
130
- # If you have a use case for something out of range, feel free to discuss.
131
- # You are probably looking for a stream cipher instead of a hash function, though.
97
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d3f5b54d116a705d36aac2a7eac7a19e3f0f058cb3c238ac7f034178ae34f212e"
132
98
 
133
- # The options work with shortcuts too
134
- #
135
- ::SleepingKangaroo12::Digest.hexdigest('abc', key: 'secret')
136
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
99
+ # weird parameters
100
+ ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 1_000_000_000_000)
101
+ # error: Hash length out of range (ArgumentError)
102
+ # I arbitrary set the limit of output length at 1MiB - 1 bytes as a safety measure. Same for length <= 0
103
+ # If you have a use case for something out of range, feel free to discuss.
137
104
  ~~~
138
105
 
139
106
  ## About CPU Throttling
data/ext/Rakefile CHANGED
@@ -9,6 +9,9 @@ platform = ::SleepingKangaroo12::Build::Platform.instance
9
9
  out_dir = "#{platform.arch}-#{platform.os}"
10
10
  lib_name = ::File.join(out_dir, platform.map_library_name('SleepingKangaroo12'))
11
11
 
12
+ k12_prefix = 'k12/bin/'
13
+ build_prefix = 'bin/.build/'
14
+
12
15
  feature_set = ::POSIX::Spawn::Child.new('gcc -march=native -dM -E - < /dev/null').then(&:out).then do |output|
13
16
  output.lines.select do |line|
14
17
  line.include?('AVX') || line.include?('SSE') || line.include?('64')
@@ -19,55 +22,27 @@ end.each_with_object(::Set.new) do |line, accumulator|
19
22
  accumulator << matched[1]
20
23
  end
21
24
 
22
- static_target = if feature_set.include?('__AVX512F__') && feature_set.include?('__AVX512VL__')
23
- 'libK12-avx512.a'
24
- elsif feature_set.include?('__AVX2__') && feature_set.include?('__SSSE3__')
25
- 'libK12-avx2-ssse3.a'
26
- elsif feature_set.include?('__AVX2__')
27
- 'libK12-avx2.a'
28
- elsif feature_set.include?('__LP64__') && feature_set.include?('__SSSE3__')
29
- 'libK12-ssse3-64.a'
30
- elsif feature_set.include?('__LP64__')
31
- 'libK12-generic-64.a'
32
- elsif feature_set.include?('__SSSE3__')
33
- 'libK12-ssse3.a'
25
+ static_target = if feature_set.include?('__LP64__')
26
+ 'generic64/libk12.a'
34
27
  else
35
- 'libK12-generic.a'
28
+ 'generic32/libk12.a'
36
29
  end
37
30
 
38
- xkcp_static_target = "xkcp/bin/#{static_target}"
39
-
40
31
  task default: [lib_name]
41
32
 
42
- file lib_name => FileList['bin/.build/sleeping_kangaroo12.o', xkcp_static_target] do |t|
33
+ file lib_name => FileList["#{build_prefix}sleeping_kangaroo12.o", "#{k12_prefix}#{static_target}"] do |t|
43
34
  ::FileUtils.mkdir_p(::File.dirname(t.name))
44
35
  static_lib = t.prerequisites.last
45
36
  static_lib_dir = ::File.dirname(static_lib)
46
37
  static_lib_file = ::File.basename(static_lib)
47
- sh "gcc -shared -o #{t.name} #{t.prerequisites.first} -L#{static_lib_dir} -l:#{static_lib_file} -lm -lc"
48
- end
49
-
50
- file 'bin/.build/sleeping_kangaroo12.o' => FileList['binding/sleeping_kangaroo12.c', xkcp_static_target] do |t|
51
- sh "gcc -Wall -O3 -march=native -I./xkcp/bin -c #{t.prerequisites.first} -o #{t.name}"
38
+ sh "gcc -shared -flto -o #{t.name} #{t.prerequisites.first} -L#{static_lib_dir} -l:#{static_lib_file} -lm -lc"
52
39
  end
53
40
 
54
- file xkcp_static_target => FileList['bin/.build/Makefile'] do |t|
55
- file_name = ::File.basename(t.name)
56
- sh "cd xkcp && make -f ../#{t.prerequisites.first} #{file_name}"
57
- end
58
-
59
- desc 'Generate XKCP\'s Makefile'
60
- file 'bin/.build/Makefile' => FileList['bin/.build/Makefile.expanded'] do |t|
41
+ file "#{build_prefix}sleeping_kangaroo12.o" => FileList['binding/sleeping_kangaroo12.c', "#{k12_prefix}#{static_target}"] do |t|
61
42
  ::FileUtils.mkdir_p(::File.dirname(t.name))
62
- sh "cd xkcp && xsltproc --xinclude -o ../#{t.name} support/Build/ToGlobalMakefile.xsl ../#{t.prerequisites.last}"
63
- # rewrite Makefile path
64
- original_make = ::File.read(t.name)
65
- modified_make = original_make.gsub(%r{(\s+)(bin/.build/Makefile)}, '\1../\2')
66
- ::File.write(t.name, modified_make, mode: 'wb')
43
+ sh "gcc -Wall -O3 -fPIC -flto -I#{::File.dirname(t.prerequisites.last)} -c #{t.prerequisites.first} -o #{t.name}"
67
44
  end
68
45
 
69
- desc 'Expand XKCP\'s Makefile'
70
- file 'bin/.build/Makefile.expanded' => FileList['config/xkcp.build'] do |t|
71
- ::FileUtils.mkdir_p(::File.dirname(t.name))
72
- sh "cd xkcp && xsltproc --xinclude -o ../#{t.name} support/Build/ExpandProducts.xsl ../#{t.prerequisites.last}"
46
+ file "#{k12_prefix}#{static_target}" => FileList['k12/Makefile'] do |_t|
47
+ sh "cd k12 && (CFLAGS=\"-fPIC -flto\" ASMFLAGS=\"-fPIC -flto\" make #{static_target})"
73
48
  end
@@ -1,20 +1,5 @@
1
- #if defined(__AVX512F__) && defined(__AVX512VL__)
2
- #include "libK12-avx512.a.headers/KangarooTwelve.h"
3
- #elif defined(__AVX2__) && defined(__SSSE3__)
4
- #include "libK12-avx2-ssse3.a.headers/KangarooTwelve.h"
5
- #elif defined(__AVX2__)
6
- #include "libK12-avx2.a.headers/KangarooTwelve.h"
7
- #elif defined(__LP64__) && defined(__SSSE3__)
8
- #include "libK12-ssse3-64.a.headers/KangarooTwelve.h"
9
- #elif defined(__LP64__)
10
- #include "libK12-generic-64.a.headers/KangarooTwelve.h"
11
- #elif defined(__SSSE3__)
12
- #include "libK12-ssse3.a.headers/KangarooTwelve.h"
13
- #else
14
- #include "libK12-generic.a.headers/KangarooTwelve.h"
15
- #endif
16
-
17
1
  #include <stdlib.h>
2
+ #include "libk12.a.headers/KangarooTwelve.h"
18
3
 
19
4
  void * SleepingKangaroo12_Init(int outputLength) {
20
5
  KangarooTwelve_Instance *retVal = malloc(sizeof (KangarooTwelve_Instance)); // TODO: check result
File without changes
@@ -0,0 +1,118 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ K12 based on the eXtended Keccak Code Package (XKCP)
4
+ https://github.com/XKCP/XKCP
5
+
6
+ KangarooTwelve, designed by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
7
+
8
+ Implementation by Gilles Van Assche and Ronny Van Keer, hereby denoted as "the implementer".
9
+
10
+ For more information, feedback or questions, please refer to the Keccak Team website:
11
+ https://keccak.team/
12
+
13
+ To the extent possible under law, the implementer has waived all copyright
14
+ and related or neighboring rights to the source code in this file.
15
+ http://creativecommons.org/publicdomain/zero/1.0/
16
+ -->
17
+ <build xmlns:xi="http://www.w3.org/2001/XInclude">
18
+
19
+ <fragment name="optimized">
20
+ <gcc>-fomit-frame-pointer</gcc>
21
+ <gcc>-O2</gcc>
22
+ <gcc>-g0</gcc>
23
+ </fragment>
24
+
25
+ <!-- Keccak-p[1600] -->
26
+
27
+ <fragment name="inplace32bi" inherits="optimized">
28
+ <c>lib/Inplace32BI/KeccakP-1600-inplace32BI.c</c>
29
+ <h>lib/Inplace32BI/KeccakP-1600-SnP.h</h>
30
+ </fragment>
31
+
32
+ <fragment name="optimized64" inherits="optimized">
33
+ <c>lib/Optimized64/KeccakP-1600-opt64.c</c>
34
+ <h>lib/Optimized64/KeccakP-1600-SnP.h</h>
35
+ <s>lib/Optimized64/KeccakP-1600-AVX2.s</s>
36
+ <s>lib/Optimized64/KeccakP-1600-AVX512.s</s>
37
+ <c gcc="-mssse3">lib/Optimized64/KeccakP-1600-timesN-SSSE3.c</c>
38
+ <c gcc="-mavx2">lib/Optimized64/KeccakP-1600-timesN-AVX2.c</c>
39
+ <c gcc="-mavx512f -mavx512vl">lib/Optimized64/KeccakP-1600-timesN-AVX512.c</c>
40
+ <c>lib/Optimized64/KeccakP-1600-runtimeDispatch.c</c>
41
+ </fragment>
42
+
43
+ <fragment name="optimized64noAsm" inherits="optimized">
44
+ <c>lib/Optimized64/KeccakP-1600-opt64.c</c>
45
+ <c gcc="-mavx512f -mavx512vl">lib/Optimized64/KeccakP-1600-AVX512-plainC.c</c>
46
+ <h>lib/Optimized64/KeccakP-1600-SnP.h</h>
47
+ <c gcc="-mssse3">lib/Optimized64/KeccakP-1600-timesN-SSSE3.c</c>
48
+ <c gcc="-mavx2">lib/Optimized64/KeccakP-1600-timesN-AVX2.c</c>
49
+ <c gcc="-mavx512f -mavx512vl">lib/Optimized64/KeccakP-1600-timesN-AVX512.c</c>
50
+ <c>lib/Optimized64/KeccakP-1600-runtimeDispatch.c</c>
51
+ <define>KeccakP1600_noAssembly</define>
52
+ </fragment>
53
+
54
+ <fragment name="optimized64plain" inherits="optimized">
55
+ <c>lib/Optimized64/KeccakP-1600-opt64.c</c>
56
+ <c>lib/Plain64/KeccakP-1600-plain64.c</c>
57
+ <h>lib/Plain64/KeccakP-1600-SnP.h</h>
58
+ </fragment>
59
+
60
+ <fragment name="ARMv8Asha3" inherits="optimized">
61
+ <c gcc="-march=armv8.4-a+sha3">lib/ARMv8Asha3/KeccakP-1600-opt64.c</c>
62
+ <s gcc="-march=armv8.4-a+sha3">lib/ARMv8Asha3/KeccakP-1600-ARMv8Asha3.S</s>
63
+ <h>lib/ARMv8Asha3/KeccakP-1600-SnP.h</h>
64
+ </fragment>
65
+
66
+ <!-- KangarooTwelve -->
67
+
68
+ <fragment name="KangarooTwelve">
69
+ <h>lib/align.h</h>
70
+ <c>lib/KangarooTwelve.c</c>
71
+ <h>lib/KangarooTwelve.h</h>
72
+ </fragment>
73
+
74
+ <!-- For the name of the targets, please see the end of this file. -->
75
+
76
+ <fragment name="common">
77
+ <h>lib/align.h</h>
78
+ <h>lib/brg_endian.h</h>
79
+ </fragment>
80
+
81
+ <!-- To run many tests -->
82
+ <fragment name="K12Tests" inherits="common KangarooTwelve">
83
+ <c>tests/main.c</c>
84
+ <c>tests/testPerformance.c</c>
85
+ <c>tests/timing.c</c>
86
+ <h>tests/timing.h</h>
87
+ <h>tests/testPerformance.h</h>
88
+ <c>tests/testKangarooTwelve.c</c>
89
+ <h>tests/testKangarooTwelve.h</h>
90
+ <gcc>-lm</gcc>
91
+ <define>KeccakP1600_enable_simd_options</define>
92
+ </fragment>
93
+
94
+ <!-- To make a library -->
95
+ <fragment name="libk12.a" inherits="KangarooTwelve"/>
96
+ <fragment name="libk12.so" inherits="KangarooTwelve"/>
97
+ <fragment name="libk12.dylib" inherits="KangarooTwelve"/>
98
+
99
+ <!-- Generically optimized 32-bit implementation -->
100
+ <fragment name="generic32" inherits="inplace32bi"/>
101
+
102
+ <!-- Generically optimized 64-bit implementation, including SSSE3, AVX2 and AVX512 -->
103
+ <fragment name="generic64" inherits="optimized64"/>
104
+
105
+ <!-- Same, but without the assembly file (for MS Visual Studio) -->
106
+ <fragment name="generic64noAsm" inherits="optimized64noAsm"/>
107
+
108
+ <!-- Plain C optimized 64-bit implementation only -->
109
+ <fragment name="plain64" inherits="optimized64plain"/>
110
+
111
+ <!-- Target names are of the form x/y where x is taken from the first set and y from the second set. -->
112
+ <group all="all">
113
+ <product delimiter="/">
114
+ <factor set="generic32 generic64 generic64noAsm plain64 ARMv8Asha3"/>
115
+ <factor set="K12Tests libk12.a libk12.so libk12.dylib"/>
116
+ </product>
117
+ </group>
118
+ </build>
@@ -0,0 +1,86 @@
1
+ [![Build Status](http://img.shields.io/travis/XKCP/K12.svg)](https://travis-ci.org/XKCP/K12)
2
+
3
+ # What is KangarooTwelve ?
4
+
5
+ [**KangarooTwelve**][k12] (or **K12**) is a fast and secure extendable-output function (XOF), the generalization of hash functions to arbitrary output lengths.
6
+ Derived from Keccak, it aims at higher speeds than FIPS 202's SHA-3 and SHAKE functions, while retaining their flexibility and basis of security.
7
+
8
+ On high-end platforms, it can exploit a high degree of parallelism, whether using multiple cores or the single-instruction multiple-data (SIMD) instruction set of modern processors.
9
+ On Intel's Haswell and Skylake architectures, KangarooTwelve tops at less than 1.5 cycles/byte for long messages on a single core, and at 0.51 cycles/byte on the SkylakeX and Cascade Lake architectures.
10
+ On the latest Apple A14 and M1 processors, KangarooTwelve can take advantage of the ARMv8-A's SHA-3 dedicated instructions to deliver 0.75 cycles/byte for long messages on a single core.
11
+ On low-end platforms, as well as for short messages, it also benefits from about a factor two speed-up compared to the fastest FIPS 202 instance SHAKE128.
12
+
13
+ More details can be found in our [ACNS Paper][eprint].
14
+
15
+ # What can I find here?
16
+
17
+ This repository contains source code that implements the extandable output (or hash) function [**KangarooTwelve**][k12] (or **K12**).
18
+ Its purpose is to offer optimized implementations of K12 and nothing else.
19
+
20
+ The code comes from the [**eXtended Keccak Code Package**][xkcp] (or **XKCP**), after much trimming to keep only what is needed for K12.
21
+ It is still structured like the XKCP in two layers. The lower layer implements the permutation Keccak-_p_[1600, 12] and possibly parallel versions thereof, whereas the higher layer implements the sponge construction and the K12 tree hash mode.
22
+ Also, some sources have been merged to reduce the file count.
23
+
24
+ * For the higher layer, we kept only the code needed for K12.
25
+ * For the lower layer, we removed all the functions that are not needed for K12. The lower layer therefore implements a subset of the SnP and PlSnP interfaces.
26
+
27
+ For Keccak or Xoodoo-based functions other than K12 only, it is recommended to use the XKCP itself instead and not to mix both this repository and the XKCP.
28
+
29
+
30
+ # Is there a tool to compute the K12 hash of a file?
31
+
32
+ Not in this repository, but Jack O'Connor's [`kangarootwelve_xkcp.rs` repository](https://github.com/oconnor663/kangarootwelve_xkcp.rs) contains Rust bindings to this code and a `k12sum` utility.
33
+ Pre-built binaries can be found [there](https://github.com/oconnor663/kangarootwelve_xkcp.rs/releases).
34
+
35
+
36
+ # How can I build this K12 code?
37
+
38
+ This repository uses the same build system as that of the XKCP.
39
+ To build, the following tools are needed:
40
+
41
+ * *GCC*
42
+ * *GNU make*
43
+ * *xsltproc*
44
+
45
+ The different targets are defined in [`Makefile.build`](Makefile.build). This file is expanded into a regular makefile using *xsltproc*. To use it, simply type, e.g.,
46
+
47
+ ```
48
+ make generic64/K12Tests
49
+ ```
50
+
51
+ to build K12Tests generically optimized for 64-bit platforms. The name before the slash indicates the platform, while the part after the slash is the executable to build. As another example, the static (resp. dynamic) library is built by typing `make generic64/libK12.a` (resp. `.so`) or similarly with `generic64` replaced with the appropriate platform name. An alternate C compiler can be specified via the `CC` environment variable.
52
+
53
+ Instead of building an executable with *GCC*, one can choose to select the files needed and make a package. For this, simply append `.pack` to the target name, e.g.,
54
+
55
+ ```
56
+ make generic64/K12Tests.pack
57
+ ```
58
+
59
+ This creates a `.tar.gz` archive with all the necessary files to build the given target.
60
+
61
+ The list of targets can be found at the end of [`Makefile.build`](Makefile.build) or by running `make` without parameters.
62
+
63
+ ## Microsoft Visual Studio support
64
+
65
+ KangarooTwelve can be compiled with Microsoft Visual Studio (MSVC). The XKCP build system offers support for the creation of project files. To get a project file for a given target, simply append `.vcxproj` to the target name, e.g.,
66
+
67
+ ```
68
+ make generic64noAsm/K12Tests.vcxproj
69
+ ```
70
+
71
+ The targets `generic32` and `generic64noAsm` can be used with MSVC, but not `generic64` as it contains assembly implementations in the GCC syntax, which at this point cannot be used with MSVC.
72
+ Please refer to the documention of [XKCP][xkcp] for more details on the limitations of the support of MSVC.
73
+
74
+ [k12]: https://keccak.team/kangarootwelve.html
75
+ [xkcp]: https://github.com/XKCP/XKCP
76
+ [eprint]: https://eprint.iacr.org/2016/770.pdf
77
+
78
+
79
+ # Acknowledgments
80
+
81
+ We wish to thank:
82
+
83
+ - Andy Polyakov for his expertise with the ARMv8-A+SHA3 code, and in particular for his core routine from [CRYPTOGAMS](https://github.com/dot-asm/cryptogams)
84
+ - Duc Tri Nguyen for his benchmark on the Apple M1
85
+ - Jack O'Connor for bug fixes and more importantly for his [Rust bindings](https://github.com/oconnor663/kangarootwelve_xkcp.rs)
86
+ - Kent Ross for his contributions to this code and its quality