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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4aacaa549cb9d7beeef6977f03383868f29fb143cb35820a02fdbb8fa408ab1
4
- data.tar.gz: e8c27359938bac4abebe69f71de89b4dcfad1880263c5f701af519e9c6a59741
3
+ metadata.gz: 7453def4dc8a8e3a1c2969eae931609fea5407fdba11a56e8e14fd5a09325b5f
4
+ data.tar.gz: ad708b12872beef715a367ba32ecefb0c869fb969a88df41a15fc3cac7379f43
5
5
  SHA512:
6
- metadata.gz: e857ff9f05810ffb2f3ec55ef881f839563c7fe856f973075295b4ecd2cfa14ff864d32aaaadf4142a0fbea5fbef353077ef3a0cf8c58414bbed1eb81caee445
7
- data.tar.gz: 7fa8d7a961a56d25aedd0371e75db9c24874c1812bafc43495084171762d93cc21ae3435fe68ce0f2aaa6caa6f38afb512b1ec7cd276202c372c62e1e44a1e62
6
+ metadata.gz: 1ec13969d3b64f83c29a4b2b7653cc080f442b0818f9e5f818fd2c8ca139b658f9692832f9d9a046320cf16d5988240c06bddc5fd3de3ce0faa920b1af0abb56
7
+ data.tar.gz: 748c612b41ff1460dad89f1e122b466cb052089d95eb552557c6f0ef229ce74ad5d214e9f5d371464dc93aaa65db412af284dafbb83eb62d5bccab413943f84b
data/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ # BSD 3-Clause License
2
+
3
+ _Copyright © `2022`, `Sarun Rattanasiri`_
4
+ _All rights reserved._
5
+
6
+ Redistribution and use in source and binary forms, with or without modification,
7
+ are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice,
10
+ this list of conditions and the following disclaimer.
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+ * Neither the name of the copyright holder nor the names of its contributors
15
+ may be used to endorse or promote products derived from this software
16
+ without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # SleepingKangaroo12
2
2
 
3
+ [![GitHub version](https://badge.fury.io/gh/the-cave%2Fsleeping-kangaroo12.svg)](https://badge.fury.io/gh/the-cave%2Fsleeping-kangaroo12)
4
+ [![Gem Version](https://badge.fury.io/rb/sleeping_kangaroo12.svg)](https://badge.fury.io/rb/sleeping_kangaroo12)
5
+
3
6
  ## What is it?
4
7
 
5
8
  SleepingKangaroo12 is a Ruby binding of [KangarooTwelve](https://keccak.team/kangarootwelve.html), a fast cryptographic
@@ -25,29 +28,22 @@ gem is sleeping. :-D
25
28
 
26
29
  ## What are specials?
27
30
 
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
31
+ - It builds on top of the [K12](https://github.com/XKCP/K12), an easy-to-use and highly
32
32
  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
33
+ - The instruction set `AVX512`, `AVX2`, and `SSSE3` will be detected at runtime to select the optimization dynamically.
34
+ - Thin and stable binding layer
36
35
  - 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.
36
+ for [Ruby-FFI](https://github.com/ffi/ffi) instead of using the API exposed by `ruby.h`.
38
37
  (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
38
 
43
39
  ## Prerequisites
44
40
 
45
- In order to install the gem, your machine should be ready to build the XKCP package. Which mean you should prepare:
41
+ In order to install the gem, your machine should be ready to build the K12 package. Which mean you should prepare:
46
42
 
47
43
  - GCC, the GNU Compiler Collection; our favorite
48
44
  - GNU make
49
45
  - xsltproc executable, normally comes with libxslt package
50
- - And for the sake of completeness: Ruby, Bundler, and Ruby related stuffs
46
+ - Ruby related stuffs
51
47
 
52
48
  ## Installation
53
49
 
@@ -68,60 +64,59 @@ from [konsolebox/digest-kangarootwelve-ruby](https://github.com/konsolebox/diges
68
64
  binding.
69
65
 
70
66
  ~~~ruby
71
- # Shortcuts
72
- #
73
- ::SleepingKangaroo12::Digest.digest('abc')
74
- # Output: "\xAB\x17O2\x8CU\xA5Q\v\v \x97\x91\xBF\x8B`\xE8\x01\xA7\xCF\xC2\xAAB\x04-\xCB\x8FT\x7F\xBE:}"
75
- #
67
+ # basic usage
76
68
  ::SleepingKangaroo12::Digest.hexdigest('abc')
77
- # Output: "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
69
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
78
70
 
79
- # Multiple updates
80
- #
71
+ # streaming
81
72
  digest = ::SleepingKangaroo12::Digest.new
82
- digest.update('a')
83
- digest.update('b')
84
- digest.update('c')
73
+ digest << 'a'
74
+ digest << 'b'
75
+ digest << 'c'
85
76
  digest.hexdigest
86
- # Output: "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
77
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d"
78
+ # `<<` is an alias of `update`, use the one you like
87
79
 
88
- # Hashing with a key, similar to HMAC
89
- # KangarooTwelve call the key "customization", it is the same thing, FYI
90
- #
80
+ # keyed hash (AKA: customization)
91
81
  digest = ::SleepingKangaroo12::Digest.new(key: 'secret')
92
82
  digest << 'abc' # alternate form of update method
93
83
  digest.hexdigest
94
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
95
- # HMAC requires 2 parses of hashing, the customization is definitely faster
84
+ # => "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
96
85
 
97
- # You can control the output length too
98
- #
99
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 5)
100
- digest << 'abc'
101
- digest.hexdigest
102
- # Output: "dc1fd53f85"
103
- # This is marginally faster than truncating the output yourself.
104
- #
105
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 64)
86
+ # shortcuts
87
+ ::SleepingKangaroo12::Digest.digest('abc')
88
+ # => "\xAB\x17O2\x8CU\xA5Q\v\v \x97\x91\xBF\x8B`\xE8\x01\xA7\xCF\xC2\xAAB\x04-\xCB\x8FT\x7F\xBE:}"
89
+ ::SleepingKangaroo12::Digest.hexdigest('abc', key: 'secret')
90
+ # => "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
91
+ ::SleepingKangaroo12::Digest.base64digest('abc', output_length: 24)
92
+ # => "qxdPMoxVpVELCyCXkb+LYOgBp8/CqkIE"
93
+ # `digest`, `hexdigest`, and `base64digest` are available as shortcuts and also on `Digest` instances.
94
+ # Same for the options, you may use `key`, `key_seed`, and `output_length` on both instance methods and shortcuts
95
+
96
+ # XOF (extendable-output functions)
97
+ digest = ::SleepingKangaroo12::Digest.new(output_length: 64)
106
98
  digest << 'abc'
107
99
  digest.hexdigest
108
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03fc4b18c621b57dbb8967094b160dbf22ee42402d7e3d45ecab4b02ef0db14b105"
109
- # The output is longer now, but the security claim is still the same.
110
- # (as 256-bit output length, which translated to the security level of 128-bit)
111
-
112
- # Weird parameters
113
- #
114
- digest = ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 1_000_000_000_000)
115
- # This will error; I arbitrary set the limit at 1MiB - 1 bytes as a safety measure. Same for length <= 0
116
- # If you have a use case for something out of range, feel free to discuss.
117
- # You are probably looking for a stream cipher instead of a hash function, though.
100
+ # => "ab174f328c55a5510b0b209791bf8b60e801a7cfc2aa42042dcb8f547fbe3a7d3f5b54d116a705d36aac2a7eac7a19e3f0f058cb3c238ac7f034178ae34f212e"
118
101
 
119
- # The options work with shortcuts too
120
- #
121
- ::SleepingKangaroo12::Digest.hexdigest('abc', key: 'secret')
122
- # Output: "dc1fd53f85402e2b34fa92bd87593dd9c3fe6cc49d9db6c05dc0cf26c6a7e03f"
102
+ # weird parameters
103
+ ::SleepingKangaroo12::Digest.new(key: 'secret', output_length: 1_000_000_000_000)
104
+ # error: Hash length out of range (ArgumentError)
105
+ # I arbitrary set the limit of output length at 1MiB - 1 bytes as a safety measure. Same for length <= 0
106
+ # If you have a use case for something out of range, feel free to discuss.
123
107
  ~~~
124
108
 
109
+ ## About CPU Throttling
110
+
111
+ At the time of this writing, if you use a lot of AVX-512, your CPU would heat up significantly; this leads to frequency throttling.
112
+
113
+ If you plan to use KangarooTwelve heavily yet still have other functionalities impacted by lower CPU frequencies
114
+ (like [Cloudflare](https://blog.cloudflare.com/on-the-dangers-of-intels-frequency-scaling/)),
115
+ you may want to customize the build to prevent the throttling.
116
+
117
+ If that is the case, please check [konsolebox/digest-kangarootwelve-ruby](https://github.com/konsolebox/digest-kangarootwelve-ruby).
118
+ At the time of this writing, they offer customizable build; in contrast, SleepingKangaroo12 will focus on ease of use.
119
+
125
120
  ## License
126
121
 
127
122
  SleepingKangaroo12 is released under the [BSD 3-Clause License](LICENSE.md). :tada:
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 -Wa,-adhln -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