sleeping_kangaroo12 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +27 -0
- data/README.md +48 -53
- data/ext/Rakefile +12 -37
- data/ext/binding/sleeping_kangaroo12.c +1 -16
- data/ext/{xkcp → k12}/Makefile +0 -0
- data/ext/k12/Makefile.build +118 -0
- data/ext/k12/README.markdown +86 -0
- data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-ARMv8Asha3.S +623 -0
- data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-SnP.h +65 -0
- data/ext/k12/lib/ARMv8Asha3/KeccakP-1600-opt64.c +227 -0
- data/ext/{xkcp/lib/low/KeccakP-1600/compact → k12/lib/Inplace32BI}/KeccakP-1600-SnP.h +4 -9
- data/ext/{xkcp/lib/low/KeccakP-1600/plain-32bits-inplace → k12/lib/Inplace32BI}/KeccakP-1600-inplace32BI.c +65 -160
- data/ext/k12/lib/KangarooTwelve.c +332 -0
- data/ext/{xkcp/lib/high/KangarooTwelve → k12/lib}/KangarooTwelve.h +53 -16
- data/ext/{xkcp/lib/low/KeccakP-1600/AVX2 → k12/lib/Optimized64}/KeccakP-1600-AVX2.s +122 -558
- data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512-plainC.c +241 -0
- data/ext/k12/lib/Optimized64/KeccakP-1600-AVX512.s +551 -0
- data/ext/k12/lib/Optimized64/KeccakP-1600-SnP.h +74 -0
- data/ext/{xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros → k12/lib/Optimized64/KeccakP-1600-opt64.c} +447 -169
- data/ext/k12/lib/Optimized64/KeccakP-1600-runtimeDispatch.c +406 -0
- data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX2.c +419 -0
- data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-AVX512.c +458 -0
- data/ext/k12/lib/Optimized64/KeccakP-1600-timesN-SSSE3.c +438 -0
- data/ext/{xkcp/lib/low/KeccakP-1600/plain-64bits → k12/lib/Plain64}/KeccakP-1600-SnP.h +14 -20
- data/ext/{xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h → k12/lib/Plain64/KeccakP-1600-plain64.c} +9 -8
- data/ext/{xkcp/lib/common → k12/lib}/align.h +3 -2
- data/ext/{xkcp/lib/common → k12/lib}/brg_endian.h +0 -0
- data/ext/{xkcp → k12}/support/Build/ExpandProducts.xsl +0 -0
- data/ext/{xkcp → k12}/support/Build/ToGlobalMakefile.xsl +0 -0
- data/ext/{xkcp → k12}/support/Build/ToOneTarget.xsl +0 -0
- data/ext/{xkcp → k12}/support/Build/ToTargetConfigFile.xsl +0 -0
- data/ext/{xkcp → k12}/support/Build/ToTargetMakefile.xsl +10 -16
- data/ext/{xkcp → k12}/support/Build/ToVCXProj.xsl +0 -0
- data/lib/sleeping_kangaroo12/binding.rb +2 -1
- data/lib/sleeping_kangaroo12/build/loader.rb +1 -0
- data/lib/sleeping_kangaroo12/build/platform.rb +1 -0
- data/lib/sleeping_kangaroo12/digest.rb +38 -4
- data/lib/sleeping_kangaroo12/version.rb +1 -1
- metadata +48 -288
- data/ext/config/xkcp.build +0 -17
- data/ext/xkcp/LICENSE +0 -1
- data/ext/xkcp/Makefile.build +0 -200
- data/ext/xkcp/README.markdown +0 -296
- data/ext/xkcp/lib/HighLevel.build +0 -143
- data/ext/xkcp/lib/LowLevel.build +0 -757
- data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +0 -301
- data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +0 -81
- data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +0 -125
- data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +0 -48
- data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +0 -79
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +0 -81
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +0 -73
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +0 -195
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +0 -111
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +0 -76
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +0 -314
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +0 -61
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +0 -67
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +0 -128
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +0 -93
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +0 -599
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +0 -573
- data/ext/xkcp/lib/high/Ketje/Ketjev2.c +0 -87
- data/ext/xkcp/lib/high/Ketje/Ketjev2.h +0 -88
- data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +0 -274
- data/ext/xkcp/lib/high/Keyak/Keyakv2.c +0 -132
- data/ext/xkcp/lib/high/Keyak/Keyakv2.h +0 -217
- data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +0 -81
- data/ext/xkcp/lib/high/Keyak/Motorist.inc +0 -953
- data/ext/xkcp/lib/high/Kravatte/Kravatte.c +0 -533
- data/ext/xkcp/lib/high/Kravatte/Kravatte.h +0 -115
- data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +0 -557
- data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +0 -247
- data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +0 -66
- data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +0 -336
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +0 -26
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +0 -55
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +0 -35
- data/ext/xkcp/lib/high/Xoofff/Xoofff.c +0 -634
- data/ext/xkcp/lib/high/Xoofff/Xoofff.h +0 -147
- data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +0 -483
- data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +0 -241
- data/ext/xkcp/lib/high/common/Phases.h +0 -25
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +0 -41
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +0 -1666
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +0 -1655
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +0 -1268
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +0 -1264
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +0 -1178
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +0 -1175
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +0 -1338
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +0 -1336
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +0 -1343
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +0 -1339
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +0 -823
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +0 -831
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +0 -31
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +0 -540
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +0 -733
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +0 -1121
- data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +0 -52
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +0 -623
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +0 -47
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +0 -1031
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +0 -53
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +0 -44
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +0 -476
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +0 -305
- data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +0 -420
- data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +0 -43
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +0 -565
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +0 -8
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +0 -6
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +0 -44
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +0 -23
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +0 -625
- data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +0 -44
- data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +0 -440
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +0 -1196
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +0 -1124
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +0 -1196
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +0 -1392
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +0 -1394
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +0 -850
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +0 -51
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +0 -957
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +0 -49
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +0 -8
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +0 -8
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +0 -9
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +0 -9
- data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +0 -37
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +0 -1321
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +0 -55
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +0 -881
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +0 -51
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +0 -37
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +0 -38
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +0 -1615
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +0 -57
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +0 -37
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +0 -38
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +0 -45
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +0 -38
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +0 -41
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +0 -442
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +0 -446
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +0 -419
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +0 -427
- data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +0 -41
- data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +0 -647
- data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +0 -39
- data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +0 -190
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +0 -43
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +0 -412
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +0 -23
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +0 -41
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +0 -454
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +0 -458
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +0 -455
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +0 -458
- data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +0 -41
- data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +0 -728
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +0 -43
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +0 -414
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +0 -23
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +0 -527
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +0 -533
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +0 -528
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +0 -534
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +0 -521
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +0 -527
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +0 -517
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +0 -523
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +0 -550
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +0 -556
- data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +0 -32
- data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +0 -432
- data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +0 -42
- data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +0 -929
- data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +0 -40
- data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +0 -244
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +0 -46
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +0 -184
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +0 -454
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +0 -459
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +0 -83
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +0 -88
- data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +0 -7
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +0 -44
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +0 -437
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +0 -23
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +0 -57
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +0 -475
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +0 -480
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +0 -590
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +0 -590
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +0 -126
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +0 -68
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +0 -174
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +0 -80
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +0 -68
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +0 -142
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +0 -55
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +0 -1086
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +0 -1092
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +0 -721
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +0 -726
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +0 -723
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +0 -729
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +0 -1164
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +0 -1165
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +0 -562
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +0 -563
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +0 -563
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +0 -565
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +0 -55
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +0 -476
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +0 -485
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +0 -362
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +0 -367
- data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +0 -43
- data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +0 -1341
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +0 -581
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +0 -58
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +0 -332
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +0 -329
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +0 -53
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +0 -355
- data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +0 -79
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +0 -56
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +0 -399
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +0 -127
- data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +0 -43
- data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +0 -253
- data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +0 -1044
- data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +0 -49
- data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +0 -45
- data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +0 -37
- data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +0 -1587
- data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +0 -48
- data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +0 -1202
- data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +0 -48
- data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +0 -484
- data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +0 -44
- data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +0 -45
- data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +0 -37
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +0 -939
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +0 -49
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +0 -1216
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +0 -48
- data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +0 -45
- data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +0 -37
- data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +0 -290
- data/ext/xkcp/lib/low/common/SnP-Relaned.h +0 -141
- data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +0 -133
- data/ext/xkcp/support/Kernel-PMU/Makefile +0 -8
- data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +0 -129
- data/ext/xkcp/support/Kernel-PMU/load-module +0 -1
- data/ext/xkcp/util/KeccakSum/KeccakSum.c +0 -394
- data/ext/xkcp/util/KeccakSum/base64.c +0 -86
- 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,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
|
-
}
|