sleeping_kangaroo12 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -67
  3. data/ext/Rakefile +12 -37
  4. data/ext/binding/sleeping_kangaroo12.c +1 -16
  5. data/ext/{xkcp → k12}/Makefile +0 -0
  6. data/ext/k12/Makefile.build +118 -0
  7. data/ext/k12/README.markdown +86 -0
  8. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-ARMv8Asha3.S +623 -0
  9. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-SnP.h +65 -0
  10. data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-opt64.c +227 -0
  11. data/ext/{xkcp/lib/low/KeccakP-1600/compact → k12/lib/Inplace32BI}/KeccakP-1600-SnP.h +4 -9
  12. data/ext/{xkcp/lib/low/KeccakP-1600/plain-32bits-inplace → k12/lib/Inplace32BI}/KeccakP-1600-inplace32BI.c +65 -160
  13. data/ext/k12/lib/KangarooTwelve.c +332 -0
  14. data/ext/{xkcp/lib/high/KangarooTwelve → k12/lib}/KangarooTwelve.h +53 -16
  15. data/ext/{xkcp/lib/low/KeccakP-1600/AVX2 → k12/lib/Optimized64}/KeccakP-1600-AVX2.s +122 -558
  16. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512-plainC.c +241 -0
  17. data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512.s +551 -0
  18. data/ext/k12/lib/Optimized64/KeccakP-1600-SnP.h +74 -0
  19. data/ext/{xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros → k12/lib/Optimized64/KeccakP-1600-opt64.c} +447 -169
  20. data/ext/k12/lib/Optimized64/KeccakP-1600-runtimeDispatch.c +406 -0
  21. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX2.c +419 -0
  22. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX512.c +458 -0
  23. data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-SSSE3.c +438 -0
  24. data/ext/{xkcp/lib/low/KeccakP-1600/plain-64bits → k12/lib/Plain64}/KeccakP-1600-SnP.h +14 -20
  25. data/ext/{xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h → k12/lib/Plain64/KeccakP-1600-plain64.c} +9 -8
  26. data/ext/{xkcp/lib/common → k12/lib}/align.h +3 -2
  27. data/ext/{xkcp/lib/common → k12/lib}/brg_endian.h +0 -0
  28. data/ext/{xkcp → k12}/support/Build/ExpandProducts.xsl +0 -0
  29. data/ext/{xkcp → k12}/support/Build/ToGlobalMakefile.xsl +0 -0
  30. data/ext/{xkcp → k12}/support/Build/ToOneTarget.xsl +0 -0
  31. data/ext/{xkcp → k12}/support/Build/ToTargetConfigFile.xsl +0 -0
  32. data/ext/{xkcp → k12}/support/Build/ToTargetMakefile.xsl +10 -16
  33. data/ext/{xkcp → k12}/support/Build/ToVCXProj.xsl +0 -0
  34. data/lib/sleeping_kangaroo12/version.rb +1 -1
  35. metadata +33 -276
  36. data/ext/config/xkcp.build +0 -17
  37. data/ext/xkcp/LICENSE +0 -1
  38. data/ext/xkcp/Makefile.build +0 -200
  39. data/ext/xkcp/README.markdown +0 -296
  40. data/ext/xkcp/lib/HighLevel.build +0 -143
  41. data/ext/xkcp/lib/LowLevel.build +0 -757
  42. data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +0 -301
  43. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +0 -81
  44. data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +0 -125
  45. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +0 -48
  46. data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +0 -79
  47. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +0 -81
  48. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +0 -73
  49. data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +0 -195
  50. data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +0 -111
  51. data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +0 -76
  52. data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +0 -314
  53. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +0 -61
  54. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +0 -67
  55. data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +0 -128
  56. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +0 -93
  57. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +0 -599
  58. data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +0 -573
  59. data/ext/xkcp/lib/high/Ketje/Ketjev2.c +0 -87
  60. data/ext/xkcp/lib/high/Ketje/Ketjev2.h +0 -88
  61. data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +0 -274
  62. data/ext/xkcp/lib/high/Keyak/Keyakv2.c +0 -132
  63. data/ext/xkcp/lib/high/Keyak/Keyakv2.h +0 -217
  64. data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +0 -81
  65. data/ext/xkcp/lib/high/Keyak/Motorist.inc +0 -953
  66. data/ext/xkcp/lib/high/Kravatte/Kravatte.c +0 -533
  67. data/ext/xkcp/lib/high/Kravatte/Kravatte.h +0 -115
  68. data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +0 -557
  69. data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +0 -247
  70. data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +0 -66
  71. data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +0 -336
  72. data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +0 -26
  73. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +0 -55
  74. data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +0 -35
  75. data/ext/xkcp/lib/high/Xoofff/Xoofff.c +0 -634
  76. data/ext/xkcp/lib/high/Xoofff/Xoofff.h +0 -147
  77. data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +0 -483
  78. data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +0 -241
  79. data/ext/xkcp/lib/high/common/Phases.h +0 -25
  80. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +0 -41
  81. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +0 -1666
  82. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +0 -1655
  83. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +0 -1268
  84. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +0 -1264
  85. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +0 -1178
  86. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +0 -1175
  87. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +0 -1338
  88. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +0 -1336
  89. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +0 -1343
  90. data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +0 -1339
  91. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +0 -42
  92. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +0 -823
  93. data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +0 -831
  94. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +0 -31
  95. data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +0 -540
  96. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +0 -42
  97. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +0 -733
  98. data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +0 -1121
  99. data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +0 -52
  100. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +0 -623
  101. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +0 -47
  102. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +0 -6
  103. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +0 -6
  104. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +0 -6
  105. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -1031
  106. data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +0 -53
  107. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +0 -44
  108. data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +0 -476
  109. data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +0 -6
  110. data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +0 -6
  111. data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +0 -305
  112. data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +0 -420
  113. data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +0 -43
  114. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +0 -565
  115. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +0 -7
  116. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +0 -7
  117. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +0 -8
  118. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +0 -6
  119. data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +0 -6
  120. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +0 -44
  121. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +0 -23
  122. data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +0 -625
  123. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +0 -44
  124. data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +0 -440
  125. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +0 -42
  126. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +0 -1196
  127. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +0 -1124
  128. data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +0 -1196
  129. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +0 -1392
  130. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +0 -1394
  131. data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +0 -42
  132. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +0 -7
  133. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +0 -7
  134. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +0 -7
  135. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +0 -850
  136. data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +0 -51
  137. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +0 -957
  138. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +0 -49
  139. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +0 -8
  140. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +0 -8
  141. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +0 -9
  142. data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +0 -9
  143. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +0 -45
  144. data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +0 -37
  145. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +0 -1321
  146. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +0 -55
  147. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +0 -7
  148. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +0 -7
  149. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +0 -7
  150. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +0 -7
  151. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +0 -7
  152. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +0 -7
  153. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +0 -881
  154. data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +0 -51
  155. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +0 -45
  156. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +0 -37
  157. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +0 -45
  158. data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +0 -38
  159. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +0 -1615
  160. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +0 -57
  161. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +0 -7
  162. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +0 -7
  163. data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +0 -7
  164. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +0 -45
  165. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +0 -37
  166. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +0 -45
  167. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +0 -38
  168. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +0 -45
  169. data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +0 -38
  170. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +0 -41
  171. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +0 -442
  172. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +0 -446
  173. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +0 -419
  174. data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +0 -427
  175. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +0 -41
  176. data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +0 -647
  177. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +0 -39
  178. data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +0 -190
  179. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +0 -43
  180. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +0 -412
  181. data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +0 -23
  182. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +0 -41
  183. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +0 -454
  184. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +0 -458
  185. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +0 -455
  186. data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +0 -458
  187. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +0 -41
  188. data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +0 -728
  189. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +0 -43
  190. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +0 -414
  191. data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +0 -23
  192. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +0 -42
  193. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +0 -527
  194. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +0 -533
  195. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +0 -528
  196. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +0 -534
  197. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +0 -521
  198. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +0 -527
  199. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +0 -517
  200. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +0 -523
  201. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +0 -550
  202. data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +0 -556
  203. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +0 -32
  204. data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +0 -432
  205. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +0 -42
  206. data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +0 -929
  207. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +0 -40
  208. data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +0 -244
  209. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +0 -46
  210. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +0 -184
  211. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +0 -454
  212. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +0 -459
  213. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +0 -83
  214. data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +0 -88
  215. data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +0 -7
  216. data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +0 -7
  217. data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +0 -7
  218. data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +0 -7
  219. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +0 -44
  220. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +0 -437
  221. data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +0 -23
  222. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +0 -57
  223. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +0 -475
  224. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +0 -480
  225. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +0 -590
  226. data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +0 -590
  227. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +0 -126
  228. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +0 -68
  229. data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +0 -174
  230. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +0 -80
  231. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +0 -68
  232. data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +0 -142
  233. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +0 -55
  234. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +0 -1086
  235. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +0 -1092
  236. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +0 -721
  237. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +0 -726
  238. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +0 -723
  239. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +0 -729
  240. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +0 -1164
  241. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +0 -1165
  242. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +0 -562
  243. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +0 -563
  244. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +0 -563
  245. data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +0 -565
  246. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +0 -55
  247. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +0 -476
  248. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +0 -485
  249. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +0 -362
  250. data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +0 -367
  251. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +0 -43
  252. data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +0 -1341
  253. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +0 -581
  254. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +0 -58
  255. data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +0 -332
  256. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +0 -329
  257. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +0 -53
  258. data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +0 -355
  259. data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +0 -79
  260. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +0 -56
  261. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +0 -399
  262. data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +0 -127
  263. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +0 -43
  264. data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +0 -253
  265. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +0 -1044
  266. data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +0 -49
  267. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +0 -45
  268. data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +0 -37
  269. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +0 -1587
  270. data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +0 -48
  271. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +0 -1202
  272. data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +0 -48
  273. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +0 -484
  274. data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +0 -44
  275. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +0 -45
  276. data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +0 -37
  277. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +0 -939
  278. data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +0 -49
  279. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +0 -1216
  280. data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +0 -48
  281. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +0 -45
  282. data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +0 -37
  283. data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +0 -290
  284. data/ext/xkcp/lib/low/common/SnP-Relaned.h +0 -141
  285. data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +0 -133
  286. data/ext/xkcp/support/Kernel-PMU/Makefile +0 -8
  287. data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +0 -129
  288. data/ext/xkcp/support/Kernel-PMU/load-module +0 -1
  289. data/ext/xkcp/util/KeccakSum/KeccakSum.c +0 -394
  290. data/ext/xkcp/util/KeccakSum/base64.c +0 -86
  291. data/ext/xkcp/util/KeccakSum/base64.h +0 -12
@@ -1,301 +0,0 @@
1
- /*
2
- The eXtended Keccak Code Package (XKCP)
3
- https://github.com/XKCP/XKCP
4
-
5
- KangarooTwelve, designed by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, Ronny Van Keer and Benoît Viguier.
6
-
7
- Implementation by Ronny Van Keer, hereby denoted as "the implementer".
8
-
9
- For more information, feedback or questions, please refer to the Keccak Team website:
10
- https://keccak.team/
11
-
12
- To the extent possible under law, the implementer has waived all copyright
13
- and related or neighboring rights to the source code in this file.
14
- http://creativecommons.org/publicdomain/zero/1.0/
15
- */
16
-
17
- #include <string.h>
18
- #include <stdint.h>
19
- #include "KangarooTwelve.h"
20
-
21
- #ifdef XKCP_has_KeccakP1600times2
22
- #include "KeccakP-1600-times2-SnP.h"
23
- #endif
24
-
25
- #ifdef XKCP_has_KeccakP1600times4
26
- #include "KeccakP-1600-times4-SnP.h"
27
- #endif
28
-
29
- #ifdef XKCP_has_KeccakP1600times8
30
- #include "KeccakP-1600-times8-SnP.h"
31
- #endif
32
-
33
- #define chunkSize 8192
34
- #define laneSize 8
35
- #define suffixLeaf 0x0B /* '110': message hop, simple padding, inner node */
36
-
37
- #define security 128
38
- #define capacity (2*security)
39
- #define capacityInBytes (capacity/8)
40
- #define capacityInLanes (capacityInBytes/laneSize)
41
- #define rate (1600-capacity)
42
- #define rateInBytes (rate/8)
43
- #define rateInLanes (rateInBytes/laneSize)
44
-
45
- #define ParallelSpongeFastLoop( Parallellism ) \
46
- while ( inLen >= Parallellism * chunkSize ) { \
47
- ALIGN(KeccakP1600times##Parallellism##_statesAlignment) unsigned char states[KeccakP1600times##Parallellism##_statesSizeInBytes]; \
48
- unsigned char intermediate[Parallellism*capacityInBytes]; \
49
- unsigned int localBlockLen = chunkSize; \
50
- const unsigned char * localInput = input; \
51
- unsigned int i; \
52
- unsigned int fastLoopOffset; \
53
- \
54
- KeccakP1600times##Parallellism##_StaticInitialize(); \
55
- KeccakP1600times##Parallellism##_InitializeAll(states); \
56
- fastLoopOffset = (unsigned int)KeccakP1600times##Parallellism##_12rounds_FastLoop_Absorb(states, rateInLanes, chunkSize / laneSize, rateInLanes, localInput, Parallellism * chunkSize); \
57
- localBlockLen -= fastLoopOffset; \
58
- localInput += fastLoopOffset; \
59
- for ( i = 0; i < Parallellism; ++i, localInput += chunkSize ) { \
60
- KeccakP1600times##Parallellism##_AddBytes(states, i, localInput, 0, localBlockLen); \
61
- KeccakP1600times##Parallellism##_AddByte(states, i, suffixLeaf, localBlockLen); \
62
- KeccakP1600times##Parallellism##_AddByte(states, i, 0x80, rateInBytes-1); \
63
- } \
64
- KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
65
- input += Parallellism * chunkSize; \
66
- inLen -= Parallellism * chunkSize; \
67
- ktInstance->blockNumber += Parallellism; \
68
- KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
69
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
70
- }
71
-
72
- #define ParallelSpongeLoop( Parallellism ) \
73
- while ( inLen >= Parallellism * chunkSize ) { \
74
- ALIGN(KeccakP1600times##Parallellism##_statesAlignment) unsigned char states[KeccakP1600times##Parallellism##_statesSizeInBytes]; \
75
- unsigned char intermediate[Parallellism*capacityInBytes]; \
76
- unsigned int localBlockLen = chunkSize; \
77
- const unsigned char * localInput = input; \
78
- unsigned int i; \
79
- \
80
- KeccakP1600times##Parallellism##_StaticInitialize(); \
81
- KeccakP1600times##Parallellism##_InitializeAll(states); \
82
- while(localBlockLen >= rateInBytes) { \
83
- KeccakP1600times##Parallellism##_AddLanesAll(states, localInput, rateInLanes, chunkSize / laneSize); \
84
- KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
85
- localBlockLen -= rateInBytes; \
86
- localInput += rateInBytes; \
87
- } \
88
- for ( i = 0; i < Parallellism; ++i, localInput += chunkSize ) { \
89
- KeccakP1600times##Parallellism##_AddBytes(states, i, localInput, 0, localBlockLen); \
90
- KeccakP1600times##Parallellism##_AddByte(states, i, suffixLeaf, localBlockLen); \
91
- KeccakP1600times##Parallellism##_AddByte(states, i, 0x80, rateInBytes-1); \
92
- } \
93
- KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
94
- input += Parallellism * chunkSize; \
95
- inLen -= Parallellism * chunkSize; \
96
- ktInstance->blockNumber += Parallellism; \
97
- KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
98
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
99
- }
100
-
101
- #define ProcessLeaves( Parallellism ) \
102
- while ( inLen >= Parallellism * chunkSize ) { \
103
- unsigned char intermediate[Parallellism*capacityInBytes]; \
104
- \
105
- KeccakP1600times##Parallellism##_K12ProcessLeaves(input, intermediate); \
106
- input += Parallellism * chunkSize; \
107
- inLen -= Parallellism * chunkSize; \
108
- ktInstance->blockNumber += Parallellism; \
109
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
110
- }
111
-
112
- static unsigned int right_encode( unsigned char * encbuf, size_t value )
113
- {
114
- unsigned int n, i;
115
- size_t v;
116
-
117
- for ( v = value, n = 0; v && (n < sizeof(size_t)); ++n, v >>= 8 )
118
- ; /* empty */
119
- for ( i = 1; i <= n; ++i )
120
- encbuf[i-1] = (unsigned char)(value >> (8 * (n-i)));
121
- encbuf[n] = (unsigned char)n;
122
- return n + 1;
123
- }
124
-
125
- int KangarooTwelve_Initialize(KangarooTwelve_Instance *ktInstance, size_t outputLen)
126
- {
127
- ktInstance->fixedOutputLength = outputLen;
128
- ktInstance->queueAbsorbedLen = 0;
129
- ktInstance->blockNumber = 0;
130
- ktInstance->phase = ABSORBING;
131
- return KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->finalNode, rate, capacity);
132
- }
133
-
134
- int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned char *input, size_t inLen)
135
- {
136
- if (ktInstance->phase != ABSORBING)
137
- return 1;
138
-
139
- if ( ktInstance->blockNumber == 0 ) {
140
- /* First block, absorb in final node */
141
- unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? (unsigned int)inLen : (chunkSize - ktInstance->queueAbsorbedLen);
142
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, input, len) != 0)
143
- return 1;
144
- input += len;
145
- inLen -= len;
146
- ktInstance->queueAbsorbedLen += len;
147
- if ( (ktInstance->queueAbsorbedLen == chunkSize) && (inLen != 0) ) {
148
- /* First block complete and more input data available, finalize it */
149
- const unsigned char padding = 0x03; /* '110^6': message hop, simple padding */
150
- ktInstance->queueAbsorbedLen = 0;
151
- ktInstance->blockNumber = 1;
152
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, &padding, 1) != 0)
153
- return 1;
154
- ktInstance->finalNode.byteIOIndex = (ktInstance->finalNode.byteIOIndex + 7) & ~7; /* Zero padding up to 64 bits */
155
- }
156
- }
157
- else if ( ktInstance->queueAbsorbedLen != 0 ) {
158
- /* There is data in the queue, absorb further in queue until block complete */
159
- unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? (unsigned int)inLen : (chunkSize - ktInstance->queueAbsorbedLen);
160
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
161
- return 1;
162
- input += len;
163
- inLen -= len;
164
- ktInstance->queueAbsorbedLen += len;
165
- if ( ktInstance->queueAbsorbedLen == chunkSize ) {
166
- unsigned char intermediate[capacityInBytes];
167
- ktInstance->queueAbsorbedLen = 0;
168
- ++ktInstance->blockNumber;
169
- if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
170
- return 1;
171
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
172
- return 1;
173
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
174
- return 1;
175
- }
176
- }
177
-
178
- #if defined(KeccakP1600times8_implementation) && !defined(KeccakP1600times8_isFallback)
179
- #if defined(KeccakP1600times8_K12ProcessLeaves_supported)
180
- ProcessLeaves( 8 )
181
- #elif defined(KeccakP1600times8_12rounds_FastLoop_supported)
182
- ParallelSpongeFastLoop( 8 )
183
- #else
184
- ParallelSpongeLoop( 8 )
185
- #endif
186
- #endif
187
-
188
- #if defined(KeccakP1600times4_implementation) && !defined(KeccakP1600times4_isFallback)
189
- #if defined(KeccakP1600times4_K12ProcessLeaves_supported)
190
- ProcessLeaves( 4 )
191
- #elif defined(KeccakP1600times4_12rounds_FastLoop_supported)
192
- ParallelSpongeFastLoop( 4 )
193
- #else
194
- ParallelSpongeLoop( 4 )
195
- #endif
196
- #endif
197
-
198
- #if defined(KeccakP1600times2_implementation) && !defined(KeccakP1600times2_isFallback)
199
- #if defined(KeccakP1600times2_K12ProcessLeaves_supported)
200
- ProcessLeaves( 2 )
201
- #elif defined(KeccakP1600times2_12rounds_FastLoop_supported)
202
- ParallelSpongeFastLoop( 2 )
203
- #else
204
- ParallelSpongeLoop( 2 )
205
- #endif
206
- #endif
207
-
208
- while ( inLen > 0 ) {
209
- unsigned int len = (inLen < chunkSize) ? (unsigned int)inLen : chunkSize;
210
- if (KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->queueNode, rate, capacity) != 0)
211
- return 1;
212
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
213
- return 1;
214
- input += len;
215
- inLen -= len;
216
- if ( len == chunkSize ) {
217
- unsigned char intermediate[capacityInBytes];
218
- ++ktInstance->blockNumber;
219
- if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
220
- return 1;
221
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
222
- return 1;
223
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
224
- return 1;
225
- }
226
- else
227
- ktInstance->queueAbsorbedLen = len;
228
- }
229
-
230
- return 0;
231
- }
232
-
233
- int KangarooTwelve_Final(KangarooTwelve_Instance *ktInstance, unsigned char * output, const unsigned char * customization, size_t customLen)
234
- {
235
- unsigned char encbuf[sizeof(size_t)+1+2];
236
- unsigned char padding;
237
-
238
- if (ktInstance->phase != ABSORBING)
239
- return 1;
240
-
241
- /* Absorb customization | right_encode(customLen) */
242
- if ((customLen != 0) && (KangarooTwelve_Update(ktInstance, customization, customLen) != 0))
243
- return 1;
244
- if (KangarooTwelve_Update(ktInstance, encbuf, right_encode(encbuf, customLen)) != 0)
245
- return 1;
246
-
247
- if ( ktInstance->blockNumber == 0 ) {
248
- /* Non complete first block in final node, pad it */
249
- padding = 0x07; /* '11': message hop, final node */
250
- }
251
- else {
252
- unsigned int n;
253
-
254
- if ( ktInstance->queueAbsorbedLen != 0 ) {
255
- /* There is data in the queue node */
256
- unsigned char intermediate[capacityInBytes];
257
- ++ktInstance->blockNumber;
258
- if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
259
- return 1;
260
- if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
261
- return 1;
262
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
263
- return 1;
264
- }
265
- --ktInstance->blockNumber; /* Absorb right_encode(number of Chaining Values) || 0xFF || 0xFF */
266
- n = right_encode(encbuf, ktInstance->blockNumber);
267
- encbuf[n++] = 0xFF;
268
- encbuf[n++] = 0xFF;
269
- if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, encbuf, n) != 0)
270
- return 1;
271
- padding = 0x06; /* '01': chaining hop, final node */
272
- }
273
- if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->finalNode, padding) != 0)
274
- return 1;
275
- if ( ktInstance->fixedOutputLength != 0 ) {
276
- ktInstance->phase = FINAL;
277
- return KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, ktInstance->fixedOutputLength);
278
- }
279
- ktInstance->phase = SQUEEZING;
280
- return 0;
281
- }
282
-
283
- int KangarooTwelve_Squeeze(KangarooTwelve_Instance *ktInstance, unsigned char * output, size_t outputLen)
284
- {
285
- if (ktInstance->phase != SQUEEZING)
286
- return 1;
287
- return KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, outputLen);
288
- }
289
-
290
- int KangarooTwelve( const unsigned char * input, size_t inLen, unsigned char * output, size_t outLen, const unsigned char * customization, size_t customLen )
291
- {
292
- KangarooTwelve_Instance ktInstance;
293
-
294
- if (outLen == 0)
295
- return 1;
296
- if (KangarooTwelve_Initialize(&ktInstance, outLen) != 0)
297
- return 1;
298
- if (KangarooTwelve_Update(&ktInstance, input, inLen) != 0)
299
- return 1;
300
- return KangarooTwelve_Final(&ktInstance, output, customization, customLen);
301
- }
@@ -1,81 +0,0 @@
1
- /*
2
- The eXtended Keccak Code Package (XKCP)
3
- https://github.com/XKCP/XKCP
4
-
5
- Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
-
7
- Implementation by the designers, hereby denoted as "the implementer".
8
-
9
- For more information, feedback or questions, please refer to the Keccak Team website:
10
- https://keccak.team/
11
-
12
- To the extent possible under law, the implementer has waived all copyright
13
- and related or neighboring rights to the source code in this file.
14
- http://creativecommons.org/publicdomain/zero/1.0/
15
- */
16
-
17
- #include <string.h>
18
- #include "KeccakHash.h"
19
-
20
- /* ---------------------------------------------------------------- */
21
-
22
- HashReturn Keccak_HashInitialize(Keccak_HashInstance *instance, unsigned int rate, unsigned int capacity, unsigned int hashbitlen, unsigned char delimitedSuffix)
23
- {
24
- HashReturn result;
25
-
26
- if (delimitedSuffix == 0)
27
- return KECCAK_FAIL;
28
- result = (HashReturn)KeccakWidth1600_SpongeInitialize(&instance->sponge, rate, capacity);
29
- if (result != KECCAK_SUCCESS)
30
- return result;
31
- instance->fixedOutputLength = hashbitlen;
32
- instance->delimitedSuffix = delimitedSuffix;
33
- return KECCAK_SUCCESS;
34
- }
35
-
36
- /* ---------------------------------------------------------------- */
37
-
38
- HashReturn Keccak_HashUpdate(Keccak_HashInstance *instance, const BitSequence *data, BitLength databitlen)
39
- {
40
- if ((databitlen % 8) == 0)
41
- return (HashReturn)KeccakWidth1600_SpongeAbsorb(&instance->sponge, data, databitlen/8);
42
- else {
43
- HashReturn ret = (HashReturn)KeccakWidth1600_SpongeAbsorb(&instance->sponge, data, databitlen/8);
44
- if (ret == KECCAK_SUCCESS) {
45
- /* The last partial byte is assumed to be aligned on the least significant bits */
46
- unsigned char lastByte = data[databitlen/8];
47
- /* Concatenate the last few bits provided here with those of the suffix */
48
- unsigned short delimitedLastBytes = (unsigned short)((unsigned short)(lastByte & ((1 << (databitlen % 8)) - 1)) | ((unsigned short)instance->delimitedSuffix << (databitlen % 8)));
49
- if ((delimitedLastBytes & 0xFF00) == 0x0000) {
50
- instance->delimitedSuffix = delimitedLastBytes & 0xFF;
51
- }
52
- else {
53
- unsigned char oneByte[1];
54
- oneByte[0] = delimitedLastBytes & 0xFF;
55
- ret = (HashReturn)KeccakWidth1600_SpongeAbsorb(&instance->sponge, oneByte, 1);
56
- instance->delimitedSuffix = (delimitedLastBytes >> 8) & 0xFF;
57
- }
58
- }
59
- return ret;
60
- }
61
- }
62
-
63
- /* ---------------------------------------------------------------- */
64
-
65
- HashReturn Keccak_HashFinal(Keccak_HashInstance *instance, BitSequence *hashval)
66
- {
67
- HashReturn ret = (HashReturn)KeccakWidth1600_SpongeAbsorbLastFewBits(&instance->sponge, instance->delimitedSuffix);
68
- if (ret == KECCAK_SUCCESS)
69
- return (HashReturn)KeccakWidth1600_SpongeSqueeze(&instance->sponge, hashval, instance->fixedOutputLength/8);
70
- else
71
- return ret;
72
- }
73
-
74
- /* ---------------------------------------------------------------- */
75
-
76
- HashReturn Keccak_HashSqueeze(Keccak_HashInstance *instance, BitSequence *data, BitLength databitlen)
77
- {
78
- if ((databitlen % 8) != 0)
79
- return KECCAK_FAIL;
80
- return (HashReturn)KeccakWidth1600_SpongeSqueeze(&instance->sponge, data, databitlen/8);
81
- }
@@ -1,125 +0,0 @@
1
- /*
2
- The eXtended Keccak Code Package (XKCP)
3
- https://github.com/XKCP/XKCP
4
-
5
- Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
-
7
- Implementation by the designers, hereby denoted as "the implementer".
8
-
9
- For more information, feedback or questions, please refer to the Keccak Team website:
10
- https://keccak.team/
11
-
12
- To the extent possible under law, the implementer has waived all copyright
13
- and related or neighboring rights to the source code in this file.
14
- http://creativecommons.org/publicdomain/zero/1.0/
15
- */
16
-
17
- #ifndef _KeccakHashInterface_h_
18
- #define _KeccakHashInterface_h_
19
-
20
- #include "config.h"
21
- #ifdef XKCP_has_KeccakP1600
22
-
23
- #include <stdint.h>
24
- #include <string.h>
25
- #include "KeccakSponge.h"
26
-
27
- #ifndef _Keccak_BitTypes_
28
- #define _Keccak_BitTypes_
29
- typedef uint8_t BitSequence;
30
-
31
- typedef size_t BitLength;
32
- #endif
33
-
34
- typedef enum { KECCAK_SUCCESS = 0, KECCAK_FAIL = 1, KECCAK_BAD_HASHLEN = 2 } HashReturn;
35
-
36
- typedef struct {
37
- KeccakWidth1600_SpongeInstance sponge;
38
- unsigned int fixedOutputLength;
39
- unsigned char delimitedSuffix;
40
- } Keccak_HashInstance;
41
-
42
- /**
43
- * Function to initialize the Keccak[r, c] sponge function instance used in sequential hashing mode.
44
- * @param hashInstance Pointer to the hash instance to be initialized.
45
- * @param rate The value of the rate r.
46
- * @param capacity The value of the capacity c.
47
- * @param hashbitlen The desired number of output bits,
48
- * or 0 for an arbitrarily-long output.
49
- * @param delimitedSuffix Bits that will be automatically appended to the end
50
- * of the input message, as in domain separation.
51
- * This is a byte containing from 0 to 7 bits
52
- * formatted like the @a delimitedData parameter of
53
- * the Keccak_SpongeAbsorbLastFewBits() function.
54
- * @pre One must have r+c=1600 and the rate a multiple of 8 bits in this implementation.
55
- * @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
56
- */
57
- HashReturn Keccak_HashInitialize(Keccak_HashInstance *hashInstance, unsigned int rate, unsigned int capacity, unsigned int hashbitlen, unsigned char delimitedSuffix);
58
-
59
- /** Macro to initialize a SHAKE128 instance as specified in the FIPS 202 standard.
60
- */
61
- #define Keccak_HashInitialize_SHAKE128(hashInstance) Keccak_HashInitialize(hashInstance, 1344, 256, 0, 0x1F)
62
-
63
- /** Macro to initialize a SHAKE256 instance as specified in the FIPS 202 standard.
64
- */
65
- #define Keccak_HashInitialize_SHAKE256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 0, 0x1F)
66
-
67
- /** Macro to initialize a SHA3-224 instance as specified in the FIPS 202 standard.
68
- */
69
- #define Keccak_HashInitialize_SHA3_224(hashInstance) Keccak_HashInitialize(hashInstance, 1152, 448, 224, 0x06)
70
-
71
- /** Macro to initialize a SHA3-256 instance as specified in the FIPS 202 standard.
72
- */
73
- #define Keccak_HashInitialize_SHA3_256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 256, 0x06)
74
-
75
- /** Macro to initialize a SHA3-384 instance as specified in the FIPS 202 standard.
76
- */
77
- #define Keccak_HashInitialize_SHA3_384(hashInstance) Keccak_HashInitialize(hashInstance, 832, 768, 384, 0x06)
78
-
79
- /** Macro to initialize a SHA3-512 instance as specified in the FIPS 202 standard.
80
- */
81
- #define Keccak_HashInitialize_SHA3_512(hashInstance) Keccak_HashInitialize(hashInstance, 576, 1024, 512, 0x06)
82
-
83
- /**
84
- * Function to give input data to be absorbed.
85
- * @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
86
- * @param data Pointer to the input data.
87
- * When @a databitLen is not a multiple of 8, the last bits of data must be
88
- * in the least significant bits of the last byte (little-endian convention).
89
- * In this case, the (8 - @a databitLen mod 8) most significant bits
90
- * of the last byte are ignored.
91
- * @param databitLen The number of input bits provided in the input data.
92
- * @pre In the previous call to Keccak_HashUpdate(), databitlen was a multiple of 8.
93
- * @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
94
- */
95
- HashReturn Keccak_HashUpdate(Keccak_HashInstance *hashInstance, const BitSequence *data, BitLength databitlen);
96
-
97
- /**
98
- * Function to call after all input blocks have been input and to get
99
- * output bits if the length was specified when calling Keccak_HashInitialize().
100
- * @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
101
- * If @a hashbitlen was not 0 in the call to Keccak_HashInitialize(), the number of
102
- * output bits is equal to @a hashbitlen.
103
- * If @a hashbitlen was 0 in the call to Keccak_HashInitialize(), the output bits
104
- * must be extracted using the Keccak_HashSqueeze() function.
105
- * @param hashval Pointer to the buffer where to store the output data.
106
- * @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
107
- */
108
- HashReturn Keccak_HashFinal(Keccak_HashInstance *hashInstance, BitSequence *hashval);
109
-
110
- /**
111
- * Function to squeeze output data.
112
- * @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
113
- * @param data Pointer to the buffer where to store the output data.
114
- * @param databitlen The number of output bits desired (must be a multiple of 8).
115
- * @pre Keccak_HashFinal() must have been already called.
116
- * @pre @a databitlen is a multiple of 8.
117
- * @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
118
- */
119
- HashReturn Keccak_HashSqueeze(Keccak_HashInstance *hashInstance, BitSequence *data, BitLength databitlen);
120
-
121
- #else
122
- #error This requires an implementation of Keccak-p[1600]
123
- #endif
124
-
125
- #endif
@@ -1,48 +0,0 @@
1
- /*
2
- The eXtended Keccak Code Package (XKCP)
3
- https://github.com/XKCP/XKCP
4
-
5
- Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
-
7
- Implementation by Gilles Van Assche, hereby denoted as "the implementer".
8
-
9
- For more information, feedback or questions, please refer to the Keccak Team website:
10
- https://keccak.team/
11
-
12
- To the extent possible under law, the implementer has waived all copyright
13
- and related or neighboring rights to the source code in this file.
14
- http://creativecommons.org/publicdomain/zero/1.0/
15
- */
16
-
17
- #include "KeccakSponge.h"
18
- #include "SimpleFIPS202.h"
19
-
20
- int SHAKE128(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen)
21
- {
22
- return KeccakWidth1600_Sponge(1344, 256, input, inputByteLen, 0x1F, output, outputByteLen);
23
- }
24
-
25
- int SHAKE256(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen)
26
- {
27
- return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x1F, output, outputByteLen);
28
- }
29
-
30
- int SHA3_224(unsigned char *output, const unsigned char *input, size_t inputByteLen)
31
- {
32
- return KeccakWidth1600_Sponge(1152, 448, input, inputByteLen, 0x06, output, 224/8);
33
- }
34
-
35
- int SHA3_256(unsigned char *output, const unsigned char *input, size_t inputByteLen)
36
- {
37
- return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x06, output, 256/8);
38
- }
39
-
40
- int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByteLen)
41
- {
42
- return KeccakWidth1600_Sponge( 832, 768, input, inputByteLen, 0x06, output, 384/8);
43
- }
44
-
45
- int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen)
46
- {
47
- return KeccakWidth1600_Sponge(576, 1024, input, inputByteLen, 0x06, output, 512/8);
48
- }
@@ -1,79 +0,0 @@
1
- /*
2
- The eXtended Keccak Code Package (XKCP)
3
- https://github.com/XKCP/XKCP
4
-
5
- Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
6
-
7
- Implementation by Gilles Van Assche, hereby denoted as "the implementer".
8
-
9
- For more information, feedback or questions, please refer to the Keccak Team website:
10
- https://keccak.team/
11
-
12
- To the extent possible under law, the implementer has waived all copyright
13
- and related or neighboring rights to the source code in this file.
14
- http://creativecommons.org/publicdomain/zero/1.0/
15
- */
16
-
17
- #ifndef _SimpleFIPS202_h_
18
- #define _SimpleFIPS202_h_
19
-
20
- #include "config.h"
21
- #ifdef XKCP_has_KeccakP1600
22
-
23
- #include <string.h>
24
-
25
- /** Implementation of the SHAKE128 extendable output function (XOF) [FIPS 202].
26
- * @param output Pointer to the output buffer.
27
- * @param outputByteLen The desired number of output bytes.
28
- * @param input Pointer to the input message.
29
- * @param inputByteLen The length of the input message in bytes.
30
- * @return 0 if successful, 1 otherwise.
31
- */
32
- int SHAKE128(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen);
33
-
34
- /** Implementation of the SHAKE256 extendable output function (XOF) [FIPS 202].
35
- * @param output Pointer to the output buffer.
36
- * @param outputByteLen The desired number of output bytes.
37
- * @param input Pointer to the input message.
38
- * @param inputByteLen The length of the input message in bytes.
39
- * @return 0 if successful, 1 otherwise.
40
- */
41
- int SHAKE256(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen);
42
-
43
- /** Implementation of SHA3-224 [FIPS 202].
44
- * @param output Pointer to the output buffer (28 bytes).
45
- * @param input Pointer to the input message.
46
- * @param inputByteLen The length of the input message in bytes.
47
- * @return 0 if successful, 1 otherwise.
48
- */
49
- int SHA3_224(unsigned char *output, const unsigned char *input, size_t inputByteLen);
50
-
51
- /** Implementation of SHA3-256 [FIPS 202].
52
- * @param output Pointer to the output buffer (32 bytes).
53
- * @param input Pointer to the input message.
54
- * @param inputByteLen The length of the input message in bytes.
55
- * @return 0 if successful, 1 otherwise.
56
- */
57
- int SHA3_256(unsigned char *output, const unsigned char *input, size_t inputByteLen);
58
-
59
- /** Implementation of SHA3-384 [FIPS 202].
60
- * @param output Pointer to the output buffer (48 bytes).
61
- * @param input Pointer to the input message.
62
- * @param inputByteLen The length of the input message in bytes.
63
- * @return 0 if successful, 1 otherwise.
64
- */
65
- int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByteLen);
66
-
67
- /** Implementation of SHA3-512 [FIPS 202].
68
- * @param output Pointer to the output buffer (64 bytes).
69
- * @param input Pointer to the input message.
70
- * @param inputByteLen The length of the input message in bytes.
71
- * @return 0 if successful, 1 otherwise.
72
- */
73
- int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen);
74
-
75
- #else
76
- #error This requires an implementation of Keccak-p[1600]
77
- #endif
78
-
79
- #endif