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,133 +0,0 @@
1
- # XKCP ARM cycle count extension with a Cortex-A57 / RPIB3+ example
2
-
3
- **By Bruno Pairault, 2019**
4
-
5
- ![MacDown logo](https://www.enggwave.com/wp-content/uploads/2015/06/ARM-Logo-150x127.png)
6
-
7
- **ARM** allow the counting of cycles via few techniques :
8
- **DWT** or nowdays **Performance Monitor Unit** (PMU). There is several versions of PMU for the different
9
- Cortex processor.
10
-
11
- The **ARM cycle count implementation** is Linux Kernel dependant to allow the PMU managment for User.
12
- Enabling the PMU on user-mode is provided per **Kernel-PMU** and is independent of XKCP.
13
-
14
- The XKCP PMU implementation supports two architectures yet **Aarch64** and **ARMv7-A**. The two XKCP
15
- PMU implementations to read cycles are coded in the XKCP file `tests/UnitTest/Timing.h` This file
16
- is only updated using the several native preprocessor compilation options. **Performance Monitors Cycle
17
- Counters** are then read when required.
18
-
19
-
20
-
21
- ## Principle of Kernel-PMU
22
- **Kernel-PMU** is a Linux dependant module that has to be loaded to allow the PMU user-mode.
23
- XKCP `tests/UnitTest/Timing.h` will then be abble to read the register.
24
-
25
- The [Cortex-A57](https://en.wikipedia.org/wiki/ARM_Cortex-A57)
26
- documentation can be found on the ARM site for details on the [PMU](https://developer.arm.com/docs/ddi0488/latest/preface) . The Chapter 11
27
- describes the Performance Monitor Unit. For all the **Cortex A**, you can reach the [Cortex-A](https://developer.arm.com/products/processors/cortex-a) technical library.
28
- ##Principle of the computation
29
- When the **Kernel-PMU** is loaded, the processor is likely to answer with the current cycle count for PMU 32
30
- or 64 Architecture. Obviously similar PMU thread exist on Internet however this integration in XKCP follow exactly the principle introduced initially in `Timing.h` by **Doug Whiting**
31
- for Intel via `RTDSC`. Minimal changes are required in **XKCP**. We added the few ASM instructions to read the PMU according to the precompilations options.
32
- The number of cycles of an operation is the difference between the cycle counter before and the cycle
33
- counter after.
34
-
35
- ## Install
36
-
37
- 1. Install the kernel-header version for your kernel release number given per the command `#uname -r`.
38
- The method is dependant on your Packet Manager (zypper, apt-get, dpkg).
39
-
40
- * Raspbian (32 bits): `sudo apt-get install raspberrypi-kernel-headers`
41
-
42
- * OpenSuse Leap 15 (64 bits): Likely on a fresh install `nothing to do` or if the OS has been updated you will have probably to run `sudo zypper in kernel-dev`.
43
-
44
- 2. Compile Kernel-PMU
45
-
46
- #cd Kernel-PMU
47
- #make
48
-
49
- 3. Load Kernel-PMU and Check
50
-
51
-
52
- #sudo ./load-module
53
- #dmesg
54
-
55
-
56
- The expect result for **Cortex-a57** is similar to :
57
-
58
-
59
-
60
- [ 6014.689804] ENABLE_ARM_PMU enabling user PMU access on CPU-Core #0
61
- [ 6014.689809] ENABLE_ARM_PMU enabling user PMU access on CPU-Core #2
62
- [ 6014.689813] ENABLE_ARM_PMU enabling user PMU access on CPU-Core #3
63
- [ 6014.689820] ENABLE_ARM_PMU enabling user PMU access on CPU-Core #1
64
-
65
- ###Know-Issues
66
- * Depending on your Linux OS (Raspbian, Ubuntu Mate, OpenSuse) and your OS release you may also
67
- be required to download from source the kernel files to compile the module. The module will not load if
68
- the matching is not correct. Modify the path in the makefile if required.
69
-
70
- * The module must be reload after rebooting if you do not implement auto-load @reboot.
71
-
72
-
73
- ##Check the CPU configuration and the native GCC options
74
- * The objective is to understand the compilation you need to added if you use `-mnative`.
75
- * Sanity check the CPU configuration and check all the native `-mXXX` compilations options like `march`,`
76
- mtune`.
77
-
78
- # lscpu
79
- # cat /proc/cpuinfo
80
- # gcc -v
81
-
82
- ###Know-Issues Raspbian case with Updated system OS on 2019-01-01
83
- * On Raspbian the Cortex-a53 is declared as an ARMv7l with 4 cores as per `lscpu`. GCC [(gcc
84
- version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1)] come with native ARMv6 `-march`
85
- option. This is due to the implementation. Type `cat /proc/cpuinfo` and you will discover the
86
- **BCM2835** CPU which is the ARMv6 of the first RPI1(2010). It looks like it’s an ARMv6 for each of the 4
87
- cores. The impact is that we have to force the precompiler options to use the PMU 32 bits for ARM.
88
-
89
- * **Cortex-a53** RPIB3+ is an **ARMV8-a 64 bits** running mostly 32 bits as most OS for RPI are 32 bits.
90
-
91
-
92
- * The preprocessor options `-D__ARM_xx` have to be consistent with the processor and the OS. On a
93
- 32 bits implementation the PMU register is the 32 bits PMU while the 64 bits PMU counter will be used
94
- on Aarch64.
95
-
96
- ##XKCP Compilation options tips for Cortex-a53 and RPIB3+
97
-
98
- Depending on what you are trying to achieve you may like to check the compilation options for gcc or
99
- modify the XKCP `lib/LowLevel.build`. Below some suggestions.
100
-
101
- For 32 bits OS on ARM PMU on target
102
-
103
- The RPI3 on 32Bits OS is declared as a ARMv6 per GCC precompilation options. We have then to force
104
- the `ARM_ARCH_7A` option to read the 32 bit Cycle counter.
105
-
106
-
107
- ▪ <gcc>-v</gcc> This option add verbose
108
- ▪ <gcc>-D__ARM_ARCH_7A_</gcc>
109
-
110
- For 64 bits OS on ARM on target : `-mnative` will likely implement natively `__aarch64` . it is
111
- suggested per GCC as good practice to enable `fix-cortex-a53-835769` and
112
- `fix-cortex-a53-843419`.
113
-
114
- For Cross Compilation 32 bits
115
-
116
- ▪ <gcc>-march=armv8-a+crc</gcc>
117
- ▪ <gcc>-mtune=cortex-a53</gcc>
118
- ▪ <gcc>-mlittle-endian</gcc>
119
-
120
- For Cross Compilation 64 bits using aarch64-linux-gnu-gcc
121
-
122
- ▪ <gcc>-march=armv8-a+crc</gcc>
123
- ▪ <gcc>-mtune=cortex-a53</gcc>
124
- ▪ <gcc>-mlittle-endian</gcc>
125
- ▪ <gcc>-mabi=lp64</gcc>
126
-
127
-
128
- Finally compile **KeccakTests**.
129
-
130
-
131
- ##License
132
- This code is for GNU General Public License (GNU GPL or GPL) which guarantees end users the freedom
133
- to run, study, share and modify the Kernel-PMU.
@@ -1,8 +0,0 @@
1
- obj-m := enable_arm_pmu.o
2
- KDIR := /lib/modules/$(shell uname -r)/build
3
- PWD := $(shell pwd)
4
-
5
- all:
6
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
7
- clean:
8
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
@@ -1,129 +0,0 @@
1
- /*
2
- Kernel-PMU
3
- Enabling user-mode access to the performance monitor unit (PMU) on ARMv8 Aarch64 and ARMv7
4
- Copyright (C) 2019 Bruno Pairault
5
-
6
- This program is free software: you can redistribute it and/or modify
7
- it under the terms of the GNU General Public License as published by
8
- the Free Software Foundation, either version 3 of the License, or
9
- (at your option) any later version.
10
-
11
- This program is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- GNU General Public License for more details.
15
-
16
- You should have received a copy of the GNU General Public License
17
- along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- */
19
-
20
- /* Inspired with
21
- https://community.arm.com/dev-platforms/f/discussions/10366/help-configuring-pmu-s
22
- https://patchwork.kernel.org/patch/5217341/
23
- */
24
-
25
- /* Enable user-mode ARM performance counter access on ARMv7 & Armv8 Aarch64 */
26
- #include <linux/kernel.h>
27
- #include <linux/module.h>
28
- #include <linux/smp.h>
29
-
30
-
31
- #if !defined(__arm__) && !defined(__aarch64__)
32
- #error Module can only be compiled on ARM.
33
- #endif
34
-
35
- /* #define from /lib/modules/uname-r/source/arch/arm64/include/asm/perf_event.h in ASM Aarch 64 */
36
- #define ARMV8_PMCR_MASK 0x3f
37
- #define ARMV8_PMCR_E (1 << 0) /* Enable all counters */
38
- #define ARMV8_PMCR_P (1 << 1) /* Reset all counters */
39
- #define ARMV8_PMCR_C (1 << 2) /* Cycle counter reset */
40
- #define ARMV8_PMCR_N_MASK 0x1f
41
-
42
- #define ARMV8_PMUSERENR_EN_EL0 (1 << 0) /* EL0 access enable */
43
- #define ARMV8_PMUSERENR_CR (1 << 2) /* Cycle counter read enable */
44
- #define ARMV8_PMUSERENR_ER (1 << 3) /* Event counter read enable */
45
-
46
- #define ARMV8_PMCNTENSET_EL0_ENABLE (1<<31) /* *< Enable Perf count reg */
47
-
48
- #define PERF_DEF_OPTS (1 | 16)
49
-
50
- static inline u32 armv8pmu_read(void)
51
- {
52
- u64 val=0;
53
- asm volatile("MRS %0, pmcr_el0" : "=r" (val));
54
- return (u32)val;
55
- }
56
- static inline void armv8pmu_write(u32 val)
57
- {
58
- val &= ARMV8_PMCR_MASK;
59
- asm volatile("isb" : : : "memory");
60
- asm volatile("MSR pmcr_el0, %0" : : "r" ((u64)val));
61
- }
62
-
63
- static void
64
- enable_cpu_counters(void* data)
65
- {
66
- printk(KERN_INFO "ENABLE_ARM_PMU enabling user PMU access on CPU-Core #%d", smp_processor_id());
67
- #if __aarch64__
68
- /* Enable user-mode access to counters. */
69
- asm volatile("MSR pmuserenr_el0, %0" : : "r"((u64)ARMV8_PMUSERENR_EN_EL0|ARMV8_PMUSERENR_ER|ARMV8_PMUSERENR_CR));
70
- /* Initialize & Reset PMNC: C and P bits. */
71
- armv8pmu_write(ARMV8_PMCR_P | ARMV8_PMCR_C);
72
- asm volatile("MSR pmintenset_el1, %0" : : "r" ((u64)(0 << 31)));
73
- /* Count Enable Set register bit 31 enable */
74
- asm volatile("MSR pmcntenset_el0, %0" : : "r" (ARMV8_PMCNTENSET_EL0_ENABLE));
75
- armv8pmu_write(armv8pmu_read() | ARMV8_PMCR_E);
76
-
77
- #elif defined(__ARM_ARCH_7A__)
78
-
79
- /* Enable user-mode access to counters. */
80
- asm volatile("MCR p15, 0, %0, c9, c14, 0" :: "r"(1));
81
- /* Program PMU and enable all counters */
82
- asm volatile("MCR p15, 0, %0, c9, c12, 0" :: "r"(PERF_DEF_OPTS));
83
- asm volatile("MCR p15, 0, %0, c9, c12, 1" :: "r"(0x8000000f));
84
- #else
85
- #error Module Does Not Support your ARM
86
- #endif
87
- }
88
-
89
- static void
90
- disable_cpu_counters(void* data)
91
- {
92
- printk(KERN_INFO "ENABLE_ARM_PMU disabling user PMU access on CPU-Core #%d", smp_processor_id());
93
-
94
- #if __aarch64__
95
- /* Performance Monitors Count Enable Set register bit 31:0 disable */
96
- asm volatile("MSR pmcntenset_el0, %0" : : "r" (0<<31));
97
- /* Disable all counters and user-mode access to counters. */
98
- armv8pmu_write(armv8pmu_read() |~ ARMV8_PMCR_E);
99
- asm volatile("MSR pmuserenr_el0, %0" : : "r"((u64)0));
100
- #elif defined(__ARM_ARCH_7A__)
101
- asm volatile("MCR p15, 0, %0, c9, c12, 0" :: "r"(0));
102
- /* Disable all counters and user-mode access to counters. */
103
- asm volatile("MCR p15, 0, %0, c9, c12, 2" :: "r"(0x8000000f));
104
- asm volatile("MCR p15, 0, %0, c9, c14, 0" :: "r"(0));
105
- #else
106
- #error Module Does Not Support your ARM
107
- #endif
108
- }
109
-
110
- static int __init
111
- init(void)
112
- {
113
- on_each_cpu(enable_cpu_counters, NULL, 1);
114
- printk(KERN_INFO "ENABLE_ARM_PMU Initialized");
115
- return 0;
116
- }
117
-
118
- static void __exit
119
- leave(void)
120
- {
121
- on_each_cpu(disable_cpu_counters, NULL, 1);
122
- printk(KERN_INFO "ENABLE_ARM_PMU Unloaded");
123
- }
124
-
125
- MODULE_LICENSE("GPL");
126
- MODULE_DESCRIPTION("Enables user-mode access to ARMv7A-v8 Aarch64 PMU counters");
127
- MODULE_VERSION("1:0.0-dev");
128
- module_init(init);
129
- module_exit(leave);
@@ -1 +0,0 @@
1
- sudo insmod ./enable_arm_pmu.ko
@@ -1,394 +0,0 @@
1
- /*
2
- Implementation by Gilles Van Assche and Ronny Van Keer, hereby denoted as "the implementer".
3
-
4
- For more information, feedback or questions, please refer to our website:
5
- https://keccak.team/
6
-
7
- To the extent possible under law, the implementer has waived all copyright
8
- and related or neighboring rights to the source code in this file.
9
- http://creativecommons.org/publicdomain/zero/1.0/
10
- */
11
-
12
- #include <stdint.h>
13
- #include <stdio.h>
14
- #include <stdlib.h>
15
- #include <string.h>
16
- #include "base64.h"
17
- #include "KeccakHash.h"
18
- #include "KangarooTwelve.h"
19
- #include "SP800-185.h"
20
-
21
- int hexencode(const void* data_buf, size_t dataLength, char* result, size_t resultSize)
22
- {
23
- const char hexchars[] = "0123456789abcdef";
24
- const uint8_t *data = (const uint8_t *)data_buf;
25
- size_t resultIndex = 0;
26
- size_t x;
27
-
28
- for(x=0; x<dataLength; x++) {
29
- if (resultIndex >= resultSize) return 1; /* indicate failure: buffer too small */
30
- result[resultIndex++] = hexchars[(data[x] / 16) % 16];
31
- if (resultIndex >= resultSize) return 1; /* indicate failure: buffer too small */
32
- result[resultIndex++] = hexchars[data[x] % 16];
33
- }
34
- if(resultIndex >= resultSize) return 1; /* indicate failure: buffer too small */
35
- result[resultIndex] = 0;
36
- return 0; /* indicate success */
37
- }
38
-
39
- #define bufferSize 65536
40
- #define algorithm_Keccak 0
41
- #define algorithm_K12 1
42
- #define algorithm_ParallelHash 2
43
-
44
- typedef struct {
45
- unsigned int algorithm;
46
- unsigned int rate;
47
- unsigned int capacity;
48
- unsigned int hashbitlen;
49
- unsigned char delimitedSuffix;
50
- unsigned int blockByteLen;
51
- } Specifications;
52
-
53
- typedef union {
54
- Keccak_HashInstance keccak;
55
- KangarooTwelve_Instance k12;
56
- ParallelHash_Instance ph;
57
- } Instance;
58
-
59
- int hashInitialize(Instance *instance, const Specifications *specs)
60
- {
61
- if (specs->algorithm == algorithm_Keccak) {
62
- if (Keccak_HashInitialize(&instance->keccak, specs->rate, specs->capacity, specs->hashbitlen, specs->delimitedSuffix)) {
63
- printf("Incorrect Keccak parameters (%d, %d, %d, 0x%02x).\n", specs->rate, specs->capacity, specs->hashbitlen, specs->delimitedSuffix);
64
- return -1;
65
- }
66
- else
67
- return 0;
68
- }
69
- else if (specs->algorithm == algorithm_K12) {
70
- if (KangarooTwelve_Initialize(&instance->k12, specs->hashbitlen/8)) {
71
- printf("Incorrect KangarooTwelve parameters.\n");
72
- return -1;
73
- }
74
- else
75
- return 0;
76
- }
77
- else if (specs->algorithm == algorithm_ParallelHash) {
78
- if (specs->capacity == 256) {
79
- if (ParallelHash128_Initialize(&instance->ph, specs->blockByteLen, specs->hashbitlen, "", 0)) {
80
- printf("Incorrect ParallelHash128 parameters.\n");
81
- return -1;
82
- }
83
- else
84
- return 0;
85
- }
86
- else if (specs->capacity == 512) {
87
- if (ParallelHash256_Initialize(&instance->ph, specs->blockByteLen, specs->hashbitlen, "", 0)) {
88
- printf("Incorrect ParallelHash256 parameters.\n");
89
- return -1;
90
- }
91
- else
92
- return 0;
93
- }
94
- else {
95
- printf("Incorrect ParallelHash parameters.\n");
96
- return -1;
97
- }
98
- }
99
- else
100
- return -1;
101
- }
102
-
103
- int hashUpdate(Instance *instance, const Specifications *specs, const unsigned char *buffer, size_t size)
104
- {
105
- if (specs->algorithm == algorithm_Keccak)
106
- Keccak_HashUpdate(&instance->keccak, buffer, size*8);
107
- else if (specs->algorithm == algorithm_K12)
108
- KangarooTwelve_Update(&instance->k12, buffer, size);
109
- else if ((specs->algorithm == algorithm_ParallelHash) && (specs->capacity == 256))
110
- ParallelHash128_Update(&instance->ph, buffer, size*8);
111
- else if ((specs->algorithm == algorithm_ParallelHash) && (specs->capacity == 512))
112
- ParallelHash256_Update(&instance->ph, buffer, size*8);
113
- return 0;
114
- }
115
-
116
- int hashFinal(Instance *instance, const Specifications *specs, unsigned char *buffer)
117
- {
118
- if (specs->algorithm == algorithm_Keccak)
119
- Keccak_HashFinal(&instance->keccak, buffer);
120
- else if (specs->algorithm == algorithm_K12)
121
- KangarooTwelve_Final(&instance->k12, buffer, "", 0);
122
- else if ((specs->algorithm == algorithm_ParallelHash) && (specs->capacity == 256))
123
- ParallelHash128_Final(&instance->ph, buffer);
124
- else if ((specs->algorithm == algorithm_ParallelHash) && (specs->capacity == 512))
125
- ParallelHash256_Final(&instance->ph, buffer);
126
- return 0;
127
- }
128
-
129
- int processFile(const char *fileName, const Specifications *specs, int base64)
130
- {
131
- FILE *fp;
132
- Instance instance;
133
- size_t read;
134
- unsigned char buffer[bufferSize];
135
- char display[bufferSize*2+1];
136
-
137
- if (specs->hashbitlen > (bufferSize*8)) {
138
- printf("The requested digest length (%d bits) does not fit in the buffer.\n", specs->hashbitlen);
139
- return -1;
140
- }
141
- if (strcmp("-", fileName) == 0) {
142
- fp = stdin;
143
- }
144
- else {
145
- fp = fopen(fileName, "rb");
146
- if (fp == NULL) {
147
- printf("File '%s' could not be opened.\n", fileName);
148
- return -1;
149
- }
150
- }
151
- if (hashInitialize(&instance, specs)) {
152
- fclose(fp);
153
- return -1;
154
- }
155
- do {
156
- read = fread(buffer, 1, bufferSize, fp);
157
- if (read > 0)
158
- hashUpdate(&instance, specs, buffer, read);
159
- } while(read>0);
160
- if (fp != stdin) {
161
- fclose(fp);
162
- }
163
- hashFinal(&instance, specs, buffer);
164
- if (base64) {
165
- if (base64encode(buffer, (specs->hashbitlen+7)/8, display, bufferSize*2)) {
166
- printf("Error while converting to base64.\n");
167
- return -1;
168
- }
169
- }
170
- else {
171
- if (hexencode(buffer, (specs->hashbitlen+7)/8, display, bufferSize*2)) {
172
- printf("Error while converting to hex.\n");
173
- return -1;
174
- }
175
- }
176
- printf("%s ", display);
177
- printf("%s\n", fileName);
178
- return 0;
179
- }
180
-
181
- int processString(const char *input, const Specifications *specs, int base64)
182
- {
183
- Instance instance;
184
- unsigned char buffer[bufferSize];
185
- char display[bufferSize*2+1];
186
-
187
- if (specs->hashbitlen > (bufferSize*8)) {
188
- printf("The requested digest length (%d bits) does not fit in the buffer.\n", specs->hashbitlen);
189
- return -1;
190
- }
191
- if (hashInitialize(&instance, specs)) {
192
- return -1;
193
- }
194
- hashUpdate(&instance, specs, input, strlen(input));
195
- hashFinal(&instance, specs, buffer);
196
- if (base64) {
197
- if (base64encode(buffer, (specs->hashbitlen+7)/8, display, bufferSize*2)) {
198
- printf("Error while converting to base64.\n");
199
- return -1;
200
- }
201
- }
202
- else {
203
- if (hexencode(buffer, (specs->hashbitlen+7)/8, display, bufferSize*2)) {
204
- printf("Error while converting to hex.\n");
205
- return -1;
206
- }
207
- }
208
- printf("%s ", display);
209
- printf("\"%s\"\n", input);
210
- return 0;
211
- }
212
-
213
- void printHelp()
214
- {
215
- printf("Usage: KeccakSum [options] [file names] [options] [file names] ...\n\n");
216
- printf(" --help or -h To display this page\n");
217
- printf(" --base64 Print in base64\n");
218
- printf(" --hex Print in hexadecimal\n");
219
- printf(" --outputbits <numberOfBits> Number of bits as output\n");
220
- printf(" --shake128 Use SHAKE128\n");
221
- printf(" --shake256 Use SHAKE256\n");
222
- printf(" --sha3-224 Use SHA3-224\n");
223
- printf(" --sha3-256 Use SHA3-256\n");
224
- printf(" --sha3-384 Use SHA3-384\n");
225
- printf(" --sha3-512 Use SHA3-512\n");
226
- printf(" --no-suffix Use 0x01 as delimited suffix (pure Keccak)\n");
227
- printf(" --ethereum Equivalent to --sha3-256 --no-suffix\n");
228
- printf(" --kangarootwelve or --k12 Use KangarooTwelve\n");
229
- printf(" --ph128 Use ParallelHash128\n");
230
- printf(" --ph256 Use ParallelHash256\n");
231
- printf(" -B <block size in bytes> ParallelHash's B parameter\n");
232
- printf(" --string <string> String to hash\n");
233
- printf(" <file name> File to hash\n\n");
234
- printf("The options are processed in order.\nBy default, it uses SHAKE128 and base64 display.\n");
235
- printf("With no file names, or when file name is -, it reads standard input.\n");
236
- }
237
-
238
- int process(int argc, char* argv[])
239
- {
240
- Specifications specs;
241
- int base64 = 1;
242
- int i, r;
243
- int was_filename = 0;
244
- specs.algorithm = algorithm_Keccak;
245
- specs.rate = 1344;
246
- specs.capacity = 256;
247
- specs.hashbitlen = 264;
248
- specs.delimitedSuffix = 0x1F;
249
-
250
- for(i=1; i<argc; i++) {
251
- int outputbits;
252
- if (strcmp("--base64", argv[i]) == 0)
253
- base64 = 1;
254
- else if (strcmp("--hex", argv[i]) == 0)
255
- base64 = 0;
256
- else if ((strcmp("--outputbits", argv[i]) == 0) || (strcmp("-n", argv[i]) == 0)) {
257
- if ((i+1) >= argc) {
258
- printf("Error: missing argument for --outputbits\n");
259
- return -1;
260
- }
261
- outputbits = 0;
262
- if (sscanf(argv[i+1], "%d", &outputbits) && (outputbits > 0) && ((outputbits % 8) == 0)) {
263
- specs.hashbitlen = outputbits;
264
- i++;
265
- }
266
- else {
267
- printf("Error: argument for --outputbits option must be a positive integer multiple of 8\n");
268
- return -1;
269
- }
270
- }
271
- else if (strcmp("--shake128", argv[i]) == 0) {
272
- specs.rate = 1344;
273
- specs.capacity = 256;
274
- specs.hashbitlen = 264;
275
- specs.delimitedSuffix = 0x1F;
276
- base64 = 1;
277
- }
278
- else if (strcmp("--shake256", argv[i]) == 0) {
279
- specs.rate = 1088;
280
- specs.capacity = 512;
281
- specs.hashbitlen = 528;
282
- specs.delimitedSuffix = 0x1F;
283
- base64 = 1;
284
- }
285
- else if (strcmp("--sha3-224", argv[i]) == 0) {
286
- specs.rate = 1152;
287
- specs.capacity = 448;
288
- specs.hashbitlen = 224;
289
- specs.delimitedSuffix = 0x06;
290
- base64 = 0;
291
- }
292
- else if (strcmp("--sha3-256", argv[i]) == 0) {
293
- specs.rate = 1088;
294
- specs.capacity = 512;
295
- specs.hashbitlen = 256;
296
- specs.delimitedSuffix = 0x06;
297
- base64 = 0;
298
- }
299
- else if (strcmp("--sha3-384", argv[i]) == 0) {
300
- specs.rate = 832;
301
- specs.capacity = 768;
302
- specs.hashbitlen = 384;
303
- specs.delimitedSuffix = 0x06;
304
- base64 = 0;
305
- }
306
- else if (strcmp("--sha3-512", argv[i]) == 0) {
307
- specs.rate = 576;
308
- specs.capacity = 1024;
309
- specs.hashbitlen = 512;
310
- specs.delimitedSuffix = 0x06;
311
- base64 = 0;
312
- }
313
- else if (strcmp("--no-suffix", argv[i]) == 0) {
314
- specs.delimitedSuffix = 0x01;
315
- }
316
- else if (strcmp("--ethereum", argv[i]) == 0) {
317
- specs.rate = 1088;
318
- specs.capacity = 512;
319
- specs.hashbitlen = 256;
320
- specs.delimitedSuffix = 0x01;
321
- base64 = 0;
322
- }
323
- else if ((strcmp("--kangarootwelve", argv[i]) == 0) || (strcmp("--k12", argv[i]) == 0)) {
324
- specs.algorithm = algorithm_K12;
325
- specs.hashbitlen = 264;
326
- base64 = 1;
327
- }
328
- else if (strcmp("--ph128", argv[i]) == 0) {
329
- specs.algorithm = algorithm_ParallelHash;
330
- specs.capacity = 256;
331
- specs.hashbitlen = 264;
332
- specs.blockByteLen = 8192;
333
- base64 = 1;
334
- }
335
- else if (strcmp("--ph256", argv[i]) == 0) {
336
- specs.algorithm = algorithm_ParallelHash;
337
- specs.capacity = 512;
338
- specs.hashbitlen = 528;
339
- specs.blockByteLen = 8192;
340
- base64 = 1;
341
- }
342
- else if (strcmp("-B", argv[i]) == 0) {
343
- int blockByteLen;
344
- if ((i+1) >= argc) {
345
- printf("Error: missing argument for -B\n");
346
- return -1;
347
- }
348
- blockByteLen = 0;
349
- if (sscanf(argv[i+1], "%d", &blockByteLen) && (blockByteLen > 0)) {
350
- specs.blockByteLen = blockByteLen;
351
- i++;
352
- }
353
- else {
354
- printf("Error: argument for -B option must be a positive power of 2\n");
355
- return -1;
356
- }
357
- }
358
- else if (strcmp("--string", argv[i]) == 0) {
359
- if ((i+1) >= argc) {
360
- printf("Error: missing argument for --string\n");
361
- return -1;
362
- }
363
- i++;
364
- processString(argv[i], &specs, base64);
365
- }
366
- else if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) {
367
- printHelp();
368
- return 0;
369
- }
370
- else {
371
- if (strlen(argv[i]) > 2) {
372
- if ((argv[i][0] == '-') && (argv[i][1] == '-')) {
373
- printf("Unrecognized command '%s'\n", argv[i]);
374
- return -1;
375
- }
376
- }
377
- was_filename = 1;
378
- r = processFile(argv[i], &specs, base64);
379
- if (r)
380
- return r;
381
- }
382
- }
383
- if (was_filename == 0) {
384
- r = processFile("-", &specs, base64);
385
- if (r)
386
- return r;
387
- }
388
- return 0;
389
- }
390
-
391
- int main(int argc, char* argv[])
392
- {
393
- return process(argc, argv);
394
- }