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.
- checksums.yaml +4 -4
- data/README.md +34 -67
- 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/version.rb +1 -1
- metadata +33 -276
- 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,953 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
The eXtended Keccak Code Package (XKCP)
|
3
|
-
https://github.com/XKCP/XKCP
|
4
|
-
|
5
|
-
Keyak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer.
|
6
|
-
|
7
|
-
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
8
|
-
|
9
|
-
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
-
https://keccak.team/
|
11
|
-
|
12
|
-
To the extent possible under law, the implementer has waived all copyright
|
13
|
-
and related or neighboring rights to the source code in this file.
|
14
|
-
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
-
*/
|
16
|
-
|
17
|
-
#define W (SnP_width/8/25)
|
18
|
-
#define Ra (SnP_width/8 - W)
|
19
|
-
#define Rs (SnP_width/8 - Capacity)
|
20
|
-
#define Cprime Capacity
|
21
|
-
|
22
|
-
#define OffsetEOM (Ra+0)
|
23
|
-
#define OffsetCryptEnd (Ra+1)
|
24
|
-
#define OffsetInjectStart (Ra+2)
|
25
|
-
#define OffsetInjectEnd (Ra+3)
|
26
|
-
|
27
|
-
#define JOIN0(a, b) a ## b
|
28
|
-
#define JOIN(a, b) JOIN0(a, b)
|
29
|
-
|
30
|
-
#define Engine_Instance JOIN(prefix, _Engine_Instance)
|
31
|
-
#define Engine_Spark JOIN(prefix, _Engine_Spark)
|
32
|
-
#define Engine_Initialize JOIN(prefix, _Engine_Initialize)
|
33
|
-
#define Engine_Crypt JOIN(prefix, _Engine_Crypt)
|
34
|
-
#define Engine_Inject JOIN(prefix, _Engine_Inject)
|
35
|
-
#define Engine_InjectCollectiveStreamer JOIN(prefix, _Engine_InjectCollectiveStreamer)
|
36
|
-
#define Engine_InjectCollective JOIN(prefix, _Engine_InjectCollective)
|
37
|
-
#define Engine_GetTags JOIN(prefix, _Engine_GetTags)
|
38
|
-
#define Engine_FastWrapCryptOnly JOIN(prefix, _Engine_FastWrapCryptOnly)
|
39
|
-
#define Engine_FastWrapInjectOnly JOIN(prefix, _Engine_FastWrapInjectOnly)
|
40
|
-
#define Engine_FastWrapCryptAndInject JOIN(prefix, _Engine_FastWrapCryptAndInject)
|
41
|
-
|
42
|
-
#define Motorist_Instance JOIN(prefix, _Motorist_Instance)
|
43
|
-
#define Motorist_MakeKnot JOIN(prefix, _Motorist_MakeKnot)
|
44
|
-
#define Motorist_HandleTag JOIN(prefix, _Motorist_HandleTag)
|
45
|
-
#define Motorist_Initialize JOIN(prefix, _Motorist_Initialize)
|
46
|
-
#define Motorist_StartEngine JOIN(prefix, _Motorist_StartEngine)
|
47
|
-
#define Motorist_Wrap JOIN(prefix, _Motorist_Wrap)
|
48
|
-
|
49
|
-
|
50
|
-
#if PlSnP_parallelism > 1
|
51
|
-
|
52
|
-
#define DeclarePistonIndex unsigned int indexP;
|
53
|
-
#define ForEveryPiston(argStart) for ( indexP = argStart; indexP < PlSnP_parallelism; ++indexP )
|
54
|
-
|
55
|
-
#define State_StaticInitialize() JOIN(PlSnP, _StaticInitialize)()
|
56
|
-
#define State_Initialize( argS ) JOIN(PlSnP, _InitializeAll)(argS)
|
57
|
-
#define State_Permute( argS ) PlSnP_PermuteAll( argS )
|
58
|
-
#define State_AddBytes( argS, argI, argO, argL ) JOIN(PlSnP, _AddBytes)(argS, indexP, argI, argO, argL)
|
59
|
-
#define State_AddByte( argS, argV, argO ) JOIN(PlSnP, _AddByte)(argS, indexP, argV, argO)
|
60
|
-
#define State_OverwriteBytes( argS, argI, argO, argL ) JOIN(PlSnP, _OverwriteBytes)(argS, indexP, argI, argO, argL)
|
61
|
-
#define State_ExtractBytes( argS, argI, argO, argL ) JOIN(PlSnP, _ExtractBytes)(argS, indexP, argI, argO, argL)
|
62
|
-
#define State_ExtractAndAddBytes( argS, argI, argO, argOfs, argL ) JOIN(PlSnP, _ExtractAndAddBytes)(argS, indexP, argI, argO, argOfs, argL)
|
63
|
-
#define PlSnP_AddLanesAll JOIN(PlSnP, _AddLanesAll)
|
64
|
-
#define PlSnP_ExtractLanesAll JOIN(PlSnP, _ExtractLanesAll)
|
65
|
-
#define PlSnP_ExtractAndAddLanesAll JOIN(PlSnP, _ExtractAndAddLanesAll)
|
66
|
-
|
67
|
-
#if PlSnP_parallelism == 2
|
68
|
-
#define State_AddByteU( argS, argV, argO ) JOIN(PlSnP, _AddByte)(argS, 0, argV, argO); \
|
69
|
-
JOIN(PlSnP, _AddByte)(argS, 1, argV, argO)
|
70
|
-
#elif PlSnP_parallelism == 4
|
71
|
-
#define State_AddByteU( argS, argV, argO ) JOIN(PlSnP, _AddByte)(argS, 0, argV, argO); \
|
72
|
-
JOIN(PlSnP, _AddByte)(argS, 1, argV, argO); \
|
73
|
-
JOIN(PlSnP, _AddByte)(argS, 2, argV, argO); \
|
74
|
-
JOIN(PlSnP, _AddByte)(argS, 3, argV, argO)
|
75
|
-
#else
|
76
|
-
#define State_AddByteU( argS, argV, argO ) JOIN(PlSnP, _AddByte)(argS, 0, argV, argO); \
|
77
|
-
JOIN(PlSnP, _AddByte)(argS, 1, argV, argO); \
|
78
|
-
JOIN(PlSnP, _AddByte)(argS, 2, argV, argO); \
|
79
|
-
JOIN(PlSnP, _AddByte)(argS, 3, argV, argO); \
|
80
|
-
JOIN(PlSnP, _AddByte)(argS, 4, argV, argO); \
|
81
|
-
JOIN(PlSnP, _AddByte)(argS, 5, argV, argO); \
|
82
|
-
JOIN(PlSnP, _AddByte)(argS, 6, argV, argO); \
|
83
|
-
JOIN(PlSnP, _AddByte)(argS, 7, argV, argO)
|
84
|
-
#endif
|
85
|
-
|
86
|
-
#if PlSnP_parallelism == 2
|
87
|
-
#define State_AddBytesU( argS, argI, argO, argL ) JOIN(PlSnP, _AddBytes)(argS, 0, (argI)+0*(argL), argO, argL); \
|
88
|
-
JOIN(PlSnP, _AddBytes)(argS, 1, (argI)+1*(argL), argO, argL)
|
89
|
-
#elif PlSnP_parallelism == 4
|
90
|
-
#define State_AddBytesU( argS, argI, argO, argL ) JOIN(PlSnP, _AddBytes)(argS, 0, (argI)+0*(argL), argO, argL); \
|
91
|
-
JOIN(PlSnP, _AddBytes)(argS, 1, (argI)+1*(argL), argO, argL); \
|
92
|
-
JOIN(PlSnP, _AddBytes)(argS, 2, (argI)+2*(argL), argO, argL); \
|
93
|
-
JOIN(PlSnP, _AddBytes)(argS, 3, (argI)+3*(argL), argO, argL)
|
94
|
-
#else
|
95
|
-
#define State_AddBytesU( argS, argI, argO, argL ) JOIN(PlSnP, _AddBytes)(argS, 0, (argI)+0*(argL), argO, argL); \
|
96
|
-
JOIN(PlSnP, _AddBytes)(argS, 1, (argI)+1*(argL), argO, argL); \
|
97
|
-
JOIN(PlSnP, _AddBytes)(argS, 2, (argI)+2*(argL), argO, argL); \
|
98
|
-
JOIN(PlSnP, _AddBytes)(argS, 3, (argI)+3*(argL), argO, argL); \
|
99
|
-
JOIN(PlSnP, _AddBytes)(argS, 4, (argI)+4*(argL), argO, argL); \
|
100
|
-
JOIN(PlSnP, _AddBytes)(argS, 5, (argI)+5*(argL), argO, argL); \
|
101
|
-
JOIN(PlSnP, _AddBytes)(argS, 6, (argI)+6*(argL), argO, argL); \
|
102
|
-
JOIN(PlSnP, _AddBytes)(argS, 7, (argI)+7*(argL), argO, argL)
|
103
|
-
#endif
|
104
|
-
|
105
|
-
|
106
|
-
#else
|
107
|
-
|
108
|
-
#define DeclarePistonIndex
|
109
|
-
#define indexP 0
|
110
|
-
#define ForEveryPiston(argStart)
|
111
|
-
|
112
|
-
#define State_StaticInitialize() JOIN(SnP, _StaticInitialize)()
|
113
|
-
#define State_Initialize( argS ) JOIN(SnP, _Initialize)( argS )
|
114
|
-
#define State_Permute( argS ) SnP_Permute( argS )
|
115
|
-
#define State_AddBytes( argS, argI, argO, argL ) JOIN(SnP, _AddBytes)(argS, argI, argO, argL)
|
116
|
-
#define State_AddByte( argS, argV, argO ) JOIN(SnP, _AddByte)(argS, argV, argO)
|
117
|
-
#define State_OverwriteBytes( argS, argI, argO, argL ) JOIN(SnP, _OverwriteBytes)(argS, argI, argO, argL)
|
118
|
-
#define State_ExtractBytes( argS, argI, argO, argL ) JOIN(SnP, _ExtractBytes)(argS, argI, argO, argL)
|
119
|
-
#define State_ExtractAndAddBytes( argS, argI, argO, argOfs, argL ) JOIN(SnP, _ExtractAndAddBytes)(argS, argI, argO, argOfs, argL)
|
120
|
-
|
121
|
-
#define State_AddByteU( argS, argV, argO ) JOIN(SnP, _AddByte)(argS, argV, argO)
|
122
|
-
#define State_AddBytesU( argS, argI, argO, argL ) JOIN(SnP, _AddBytes)(argS, argI, argO, argL);
|
123
|
-
|
124
|
-
#endif
|
125
|
-
|
126
|
-
/* ------------------------------------------------------------------------ */
|
127
|
-
|
128
|
-
/**
|
129
|
-
* Function that calls the permutation.
|
130
|
-
*
|
131
|
-
* @param instance Pointer to the Engine instance structure.
|
132
|
-
* @param EOMFlag
|
133
|
-
* @param length The length of the tag for first Piston (zero if no tag).
|
134
|
-
* @param lengthNext The length of the tag for next Pistons.
|
135
|
-
*
|
136
|
-
* @pre phase == readyForIgnition
|
137
|
-
*
|
138
|
-
* @post phase == fresh
|
139
|
-
*
|
140
|
-
* @return 0 if successful, 1 otherwise.
|
141
|
-
*/
|
142
|
-
static int Engine_Spark(Engine_Instance *instance, int EOMFlag, unsigned char length, unsigned char lengthNext );
|
143
|
-
static int Engine_Spark(Engine_Instance *instance, int EOMFlag, unsigned char length, unsigned char lengthNext )
|
144
|
-
{
|
145
|
-
DeclarePistonIndex
|
146
|
-
#ifdef UT_OUTPUT
|
147
|
-
unsigned char s[PlSnP_parallelism][SnP_width/8];
|
148
|
-
#endif
|
149
|
-
|
150
|
-
instance->tagEndIndex = length;
|
151
|
-
#if PlSnP_parallelism > 1
|
152
|
-
instance->tagEndIndexNext = lengthNext;
|
153
|
-
#endif
|
154
|
-
if ( EOMFlag != 0 )
|
155
|
-
{
|
156
|
-
ForEveryPiston(0)
|
157
|
-
{
|
158
|
-
if ( length == 0 )
|
159
|
-
length = 0xFF;
|
160
|
-
State_AddByte(instance->pistons.state, length, OffsetEOM );
|
161
|
-
#if PlSnP_parallelism > 1
|
162
|
-
length = lengthNext;
|
163
|
-
#endif
|
164
|
-
}
|
165
|
-
}
|
166
|
-
#ifdef UT_OUTPUT
|
167
|
-
if ( instance->pistons.file )
|
168
|
-
{
|
169
|
-
ForEveryPiston(0)
|
170
|
-
{
|
171
|
-
State_ExtractBytes( instance->pistons.stateShadow, s[indexP], 0, SnP_width/8 );
|
172
|
-
State_ExtractAndAddBytes( instance->pistons.state, s[indexP], s[indexP], 0, SnP_width/8 );
|
173
|
-
}
|
174
|
-
}
|
175
|
-
#endif
|
176
|
-
State_Permute( instance->pistons.state );
|
177
|
-
#ifdef UT_OUTPUT
|
178
|
-
if ( instance->pistons.file )
|
179
|
-
{
|
180
|
-
memcpy( instance->pistons.stateShadow, instance->pistons.state, sizeof(instance->pistons.state) );
|
181
|
-
ForEveryPiston(0)
|
182
|
-
{
|
183
|
-
fprintf( instance->pistons.file, "motWrap#%u XORed since last time", indexP );
|
184
|
-
UT_displayByteString( instance->pistons.file, "", s[indexP], SnP_width/8 );
|
185
|
-
State_ExtractBytes( instance->pistons.stateShadow, s[indexP], 0, SnP_width/8 );
|
186
|
-
fprintf( instance->pistons.file, "motWrap#%u after f()", indexP );
|
187
|
-
UT_displayByteString( instance->pistons.file, "", s[indexP], SnP_width/8 );
|
188
|
-
}
|
189
|
-
}
|
190
|
-
#endif
|
191
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Fresh;
|
192
|
-
instance->pistons.phaseInject = Pistons_Phase_Fresh;
|
193
|
-
|
194
|
-
return ( Atom_Success );
|
195
|
-
}
|
196
|
-
|
197
|
-
static int Engine_Initialize(Engine_Instance *instance )
|
198
|
-
{
|
199
|
-
State_StaticInitialize();
|
200
|
-
State_Initialize( instance->pistons.state );
|
201
|
-
#ifdef UT_OUTPUT
|
202
|
-
instance->pistons.file = 0;
|
203
|
-
State_Initialize( instance->pistons.stateShadow );
|
204
|
-
#endif
|
205
|
-
instance->tagEndIndex = 0;
|
206
|
-
#if PlSnP_parallelism > 1
|
207
|
-
instance->tagEndIndexNext = 0;
|
208
|
-
#endif
|
209
|
-
instance->phase = Engine_Phase_Fresh;
|
210
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Fresh;
|
211
|
-
instance->pistons.phaseInject = Pistons_Phase_Fresh;
|
212
|
-
return ( Atom_Success );
|
213
|
-
}
|
214
|
-
|
215
|
-
static size_t Engine_FastWrapCryptOnly(Engine_Instance *instance, const unsigned char *I, size_t Ilen, unsigned char *O, int unwrapFlag)
|
216
|
-
{
|
217
|
-
size_t initialIlen = Ilen;
|
218
|
-
|
219
|
-
if (unwrapFlag == Atom_False) {
|
220
|
-
do {
|
221
|
-
#if PlSnP_parallelism > 1
|
222
|
-
PlSnP_AddLanesAll(instance->pistons.state, I, Rs/W, Rs/W);
|
223
|
-
PlSnP_ExtractLanesAll(instance->pistons.state, O, Rs/W, Rs/W);
|
224
|
-
#else
|
225
|
-
State_AddBytes(instance->pistons.state, I, 0, Rs);
|
226
|
-
State_ExtractBytes(instance->pistons.state, O, 0, Rs);
|
227
|
-
#endif
|
228
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetCryptEnd);
|
229
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectStart);
|
230
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectEnd);
|
231
|
-
State_Permute( instance->pistons.state );
|
232
|
-
I += (Rs*PlSnP_parallelism);
|
233
|
-
O += (Rs*PlSnP_parallelism);
|
234
|
-
Ilen -= (Rs*PlSnP_parallelism);
|
235
|
-
}
|
236
|
-
while(Ilen > (Rs*PlSnP_parallelism));
|
237
|
-
}
|
238
|
-
else {
|
239
|
-
do {
|
240
|
-
#if PlSnP_parallelism > 1
|
241
|
-
PlSnP_ExtractAndAddLanesAll(instance->pistons.state, I, O, Rs/W, Rs/W);
|
242
|
-
PlSnP_AddLanesAll(instance->pistons.state, O, Rs/W, Rs/W);
|
243
|
-
#else
|
244
|
-
State_ExtractAndAddBytes(instance->pistons.state, I, O, 0, Rs);
|
245
|
-
State_AddBytes(instance->pistons.state, O, 0, Rs);
|
246
|
-
#endif
|
247
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetCryptEnd);
|
248
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectStart);
|
249
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectEnd);
|
250
|
-
State_Permute(instance->pistons.state);
|
251
|
-
I += (Rs*PlSnP_parallelism);
|
252
|
-
O += (Rs*PlSnP_parallelism);
|
253
|
-
Ilen -= (Rs*PlSnP_parallelism);
|
254
|
-
}
|
255
|
-
while(Ilen > (Rs*PlSnP_parallelism));
|
256
|
-
}
|
257
|
-
return (initialIlen - Ilen); /* number of bytes processed */
|
258
|
-
}
|
259
|
-
|
260
|
-
static size_t Engine_FastWrapInjectOnly(Engine_Instance *instance, const unsigned char *A, size_t Alen)
|
261
|
-
{
|
262
|
-
size_t initialAlen = Alen;
|
263
|
-
|
264
|
-
do
|
265
|
-
{
|
266
|
-
#if PlSnP_parallelism > 1
|
267
|
-
PlSnP_AddLanesAll(instance->pistons.state, A, Ra/W, Ra/W);
|
268
|
-
#else
|
269
|
-
State_AddBytes(instance->pistons.state, A, 0, Ra);
|
270
|
-
#endif
|
271
|
-
State_AddByteU(instance->pistons.state, Ra, OffsetInjectEnd);
|
272
|
-
State_Permute( instance->pistons.state );
|
273
|
-
A += (Ra*PlSnP_parallelism);
|
274
|
-
Alen -= (Ra*PlSnP_parallelism);
|
275
|
-
}
|
276
|
-
while(Alen > (Ra*PlSnP_parallelism));
|
277
|
-
return (initialAlen - Alen); /* number of bytes processed */
|
278
|
-
}
|
279
|
-
|
280
|
-
static size_t Engine_FastWrapCryptAndInject(Engine_Instance *instance, const unsigned char *I, size_t Ilen, size_t *ptrIprocessed, unsigned char *O, const unsigned char *A, size_t Alen, int unwrapFlag)
|
281
|
-
{
|
282
|
-
size_t initialIlen = Ilen;
|
283
|
-
size_t initialAlen = Alen;
|
284
|
-
|
285
|
-
if (unwrapFlag == Atom_False) {
|
286
|
-
do {
|
287
|
-
#if PlSnP_parallelism > 1
|
288
|
-
PlSnP_AddLanesAll(instance->pistons.state, I, Rs/W, Rs/W);
|
289
|
-
PlSnP_ExtractLanesAll(instance->pistons.state, O, Rs/W, Rs/W);
|
290
|
-
#else
|
291
|
-
State_AddBytes(instance->pistons.state, I, 0, Rs);
|
292
|
-
State_ExtractBytes(instance->pistons.state, O, 0, Rs);
|
293
|
-
#endif
|
294
|
-
State_AddBytesU(instance->pistons.state, A, Rs, Ra-Rs );
|
295
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetCryptEnd);
|
296
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectStart);
|
297
|
-
State_AddByteU(instance->pistons.state, Ra, OffsetInjectEnd);
|
298
|
-
State_Permute( instance->pistons.state );
|
299
|
-
I += (Rs*PlSnP_parallelism);
|
300
|
-
O += (Rs*PlSnP_parallelism);
|
301
|
-
A += (Ra-Rs)*PlSnP_parallelism;
|
302
|
-
Ilen -= (Rs*PlSnP_parallelism);
|
303
|
-
Alen -= (Ra-Rs)*PlSnP_parallelism;
|
304
|
-
}
|
305
|
-
while( (Ilen > (Rs*PlSnP_parallelism)) && (Alen > ((Ra-Rs)*PlSnP_parallelism)) );
|
306
|
-
}
|
307
|
-
else {
|
308
|
-
do {
|
309
|
-
#if PlSnP_parallelism > 1
|
310
|
-
PlSnP_ExtractAndAddLanesAll(instance->pistons.state, I, O, Rs/W, Rs/W);
|
311
|
-
PlSnP_AddLanesAll(instance->pistons.state, O, Rs/W, Rs/W);
|
312
|
-
#else
|
313
|
-
State_ExtractAndAddBytes(instance->pistons.state, I, O, 0, Rs);
|
314
|
-
State_AddBytes(instance->pistons.state, O, 0, Rs);
|
315
|
-
#endif
|
316
|
-
State_AddBytesU(instance->pistons.state, A, Rs, Ra-Rs );
|
317
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetCryptEnd);
|
318
|
-
State_AddByteU(instance->pistons.state, Rs, OffsetInjectStart);
|
319
|
-
State_AddByteU(instance->pistons.state, Ra, OffsetInjectEnd);
|
320
|
-
State_Permute( instance->pistons.state );
|
321
|
-
I += (Rs*PlSnP_parallelism);
|
322
|
-
O += (Rs*PlSnP_parallelism);
|
323
|
-
A += (Ra-Rs)*PlSnP_parallelism;
|
324
|
-
Ilen -= (Rs*PlSnP_parallelism);
|
325
|
-
Alen -= (Ra-Rs)*PlSnP_parallelism;
|
326
|
-
}
|
327
|
-
while( (Ilen > (Rs*PlSnP_parallelism)) && (Alen > ((Ra-Rs)*PlSnP_parallelism)) );
|
328
|
-
}
|
329
|
-
*ptrIprocessed = initialIlen - Ilen;
|
330
|
-
return (initialAlen - Alen); /* number of bytes processed */
|
331
|
-
}
|
332
|
-
|
333
|
-
static int Engine_Crypt(Engine_Instance *instance, const unsigned char *I, size_t Ilen, unsigned char *O, int unwrapFlag, int lastFlag )
|
334
|
-
{
|
335
|
-
DeclarePistonIndex
|
336
|
-
unsigned char offset;
|
337
|
-
unsigned int length;
|
338
|
-
#if PlSnP_parallelism > 1
|
339
|
-
int processed;
|
340
|
-
#endif
|
341
|
-
|
342
|
-
if ( instance->pistons.phaseCrypt != Pistons_Phase_Running)
|
343
|
-
{
|
344
|
-
if ( instance->pistons.phaseCrypt != Pistons_Phase_Fresh )
|
345
|
-
{
|
346
|
-
return ( Atom_Error );
|
347
|
-
}
|
348
|
-
#if PlSnP_parallelism > 1
|
349
|
-
instance->pistons.indexCrypt = 0;
|
350
|
-
#endif
|
351
|
-
instance->pistons.offsetCrypt = instance->tagEndIndex;
|
352
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Running;
|
353
|
-
}
|
354
|
-
|
355
|
-
#if PlSnP_parallelism > 1
|
356
|
-
processed = 0;
|
357
|
-
#endif
|
358
|
-
offset = instance->pistons.offsetCrypt;
|
359
|
-
if ( unwrapFlag == Atom_False )
|
360
|
-
{
|
361
|
-
/* Wrap */
|
362
|
-
ForEveryPiston(instance->pistons.indexCrypt)
|
363
|
-
{
|
364
|
-
length = Rs - offset;
|
365
|
-
if (length > Ilen)
|
366
|
-
length = (unsigned int)Ilen;
|
367
|
-
State_AddBytes(instance->pistons.state, I, offset, length );
|
368
|
-
State_ExtractBytes(instance->pistons.state, O, offset, length );
|
369
|
-
#if PlSnP_parallelism > 1
|
370
|
-
I += length;
|
371
|
-
O += length;
|
372
|
-
processed += length;
|
373
|
-
#endif
|
374
|
-
Ilen -= length;
|
375
|
-
offset += (unsigned char)length;
|
376
|
-
if ( offset == Rs )
|
377
|
-
{
|
378
|
-
State_AddByte(instance->pistons.state, offset, OffsetCryptEnd);
|
379
|
-
#if PlSnP_parallelism > 1
|
380
|
-
offset = instance->tagEndIndexNext;
|
381
|
-
++instance->pistons.indexCrypt;
|
382
|
-
#else
|
383
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Full;
|
384
|
-
#endif
|
385
|
-
}
|
386
|
-
}
|
387
|
-
}
|
388
|
-
else
|
389
|
-
{
|
390
|
-
/* Unwrap */
|
391
|
-
ForEveryPiston(instance->pistons.indexCrypt)
|
392
|
-
{
|
393
|
-
length = Rs - offset;
|
394
|
-
if (length > Ilen)
|
395
|
-
length = (unsigned int)Ilen;
|
396
|
-
State_ExtractAndAddBytes(instance->pistons.state, I, O, offset, length);
|
397
|
-
State_AddBytes(instance->pistons.state, O, offset, length);
|
398
|
-
#if PlSnP_parallelism > 1
|
399
|
-
I += length;
|
400
|
-
O += length;
|
401
|
-
processed += length;
|
402
|
-
#endif
|
403
|
-
Ilen -= length;
|
404
|
-
offset += (unsigned char)length;
|
405
|
-
if ( offset == Rs )
|
406
|
-
{
|
407
|
-
State_AddByte(instance->pistons.state, offset, OffsetCryptEnd);
|
408
|
-
#if PlSnP_parallelism > 1
|
409
|
-
offset = instance->tagEndIndexNext;
|
410
|
-
++instance->pistons.indexCrypt;
|
411
|
-
#else
|
412
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Full;
|
413
|
-
#endif
|
414
|
-
}
|
415
|
-
}
|
416
|
-
}
|
417
|
-
instance->pistons.offsetCrypt = offset;
|
418
|
-
|
419
|
-
#if PlSnP_parallelism > 1
|
420
|
-
if ( instance->pistons.indexCrypt == PlSnP_parallelism )
|
421
|
-
{
|
422
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Full;
|
423
|
-
}
|
424
|
-
#endif
|
425
|
-
if ( (Ilen == 0) && ((lastFlag & Motorist_Wrap_LastCryptData) != 0) )
|
426
|
-
{
|
427
|
-
/* Done with crypting (out of fuel) */
|
428
|
-
if ( instance->pistons.phaseCrypt != Pistons_Phase_Full )
|
429
|
-
{
|
430
|
-
ForEveryPiston(instance->pistons.indexCrypt)
|
431
|
-
{
|
432
|
-
State_AddByte(instance->pistons.state, offset, OffsetCryptEnd);
|
433
|
-
#if PlSnP_parallelism > 1
|
434
|
-
offset = instance->tagEndIndexNext;
|
435
|
-
#endif
|
436
|
-
}
|
437
|
-
}
|
438
|
-
instance->pistons.phaseCrypt = Pistons_Phase_Done;
|
439
|
-
instance->phase = Engine_Phase_Crypted;
|
440
|
-
}
|
441
|
-
#if PlSnP_parallelism > 1
|
442
|
-
return ( processed );
|
443
|
-
#else
|
444
|
-
return ( length );
|
445
|
-
#endif
|
446
|
-
}
|
447
|
-
|
448
|
-
int Engine_Inject(Engine_Instance *instance, const unsigned char * A, size_t Alen, int lastFlag)
|
449
|
-
{
|
450
|
-
DeclarePistonIndex
|
451
|
-
unsigned int length;
|
452
|
-
#if PlSnP_parallelism > 1
|
453
|
-
int processed;
|
454
|
-
#endif
|
455
|
-
|
456
|
-
if ( instance->pistons.phaseInject != Pistons_Phase_Running )
|
457
|
-
{
|
458
|
-
if ( instance->pistons.phaseInject != Engine_Phase_Fresh )
|
459
|
-
{
|
460
|
-
return ( Atom_Error );
|
461
|
-
}
|
462
|
-
#if PlSnP_parallelism > 1
|
463
|
-
instance->pistons.indexInject = 0;
|
464
|
-
#endif
|
465
|
-
if ( instance->pistons.phaseCrypt == Pistons_Phase_Fresh )
|
466
|
-
{
|
467
|
-
instance->pistons.offsetInject = 0;
|
468
|
-
}
|
469
|
-
else
|
470
|
-
{
|
471
|
-
instance->pistons.offsetInject = Rs;
|
472
|
-
ForEveryPiston(0)
|
473
|
-
{
|
474
|
-
State_AddByte(instance->pistons.state, instance->pistons.offsetInject, OffsetInjectStart);
|
475
|
-
}
|
476
|
-
}
|
477
|
-
instance->pistons.phaseInject = Pistons_Phase_Running;
|
478
|
-
}
|
479
|
-
|
480
|
-
#if PlSnP_parallelism > 1
|
481
|
-
processed = 0;
|
482
|
-
#endif
|
483
|
-
ForEveryPiston(instance->pistons.indexInject)
|
484
|
-
{
|
485
|
-
length = Ra - instance->pistons.offsetInject;
|
486
|
-
if (length > Alen)
|
487
|
-
length = (unsigned int)Alen;
|
488
|
-
State_AddBytes(instance->pistons.state, A, instance->pistons.offsetInject, length );
|
489
|
-
#if PlSnP_parallelism > 1
|
490
|
-
A += length;
|
491
|
-
processed += (int)length;
|
492
|
-
#endif
|
493
|
-
Alen -= length;
|
494
|
-
instance->pistons.offsetInject += (unsigned char)length;
|
495
|
-
if ( instance->pistons.offsetInject == Ra )
|
496
|
-
{
|
497
|
-
State_AddByte(instance->pistons.state, instance->pistons.offsetInject, OffsetInjectEnd);
|
498
|
-
#if PlSnP_parallelism > 1
|
499
|
-
instance->pistons.offsetInject = (instance->pistons.phaseCrypt == Pistons_Phase_Fresh) ? 0 : Rs;
|
500
|
-
++instance->pistons.indexInject;
|
501
|
-
#else
|
502
|
-
instance->pistons.phaseInject = Pistons_Phase_Full;
|
503
|
-
#endif
|
504
|
-
}
|
505
|
-
}
|
506
|
-
|
507
|
-
#if PlSnP_parallelism > 1
|
508
|
-
if ( instance->pistons.indexInject == PlSnP_parallelism )
|
509
|
-
{
|
510
|
-
instance->pistons.phaseInject = Pistons_Phase_Full;
|
511
|
-
}
|
512
|
-
#endif
|
513
|
-
if ( (Alen == 0) && ((lastFlag & Motorist_Wrap_LastMetaData) != 0) )
|
514
|
-
{
|
515
|
-
/* Done injecting */
|
516
|
-
if ( (instance->pistons.phaseInject != Pistons_Phase_Full) && (instance->pistons.offsetInject != 0) ) /* Optimization: don't xor zeroes */
|
517
|
-
{
|
518
|
-
ForEveryPiston(instance->pistons.indexInject)
|
519
|
-
{
|
520
|
-
State_AddByte(instance->pistons.state, instance->pistons.offsetInject, OffsetInjectEnd);
|
521
|
-
#if PlSnP_parallelism > 1
|
522
|
-
if ( instance->pistons.phaseCrypt == Pistons_Phase_Fresh )
|
523
|
-
break;
|
524
|
-
instance->pistons.offsetInject = Rs;
|
525
|
-
#endif
|
526
|
-
}
|
527
|
-
}
|
528
|
-
instance->pistons.phaseInject = Pistons_Phase_Done;
|
529
|
-
}
|
530
|
-
#if PlSnP_parallelism > 1
|
531
|
-
return ( processed );
|
532
|
-
#else
|
533
|
-
return ( length );
|
534
|
-
#endif
|
535
|
-
}
|
536
|
-
|
537
|
-
static int Engine_InjectCollectiveStreamer(Engine_Instance *instance, unsigned char *X, unsigned int sizeX, unsigned char * pOffset, int diversifyFlag);
|
538
|
-
static int Engine_InjectCollectiveStreamer(Engine_Instance *instance, unsigned char *X, unsigned int sizeX, unsigned char * pOffset, int diversifyFlag)
|
539
|
-
{
|
540
|
-
DeclarePistonIndex
|
541
|
-
unsigned char partSize;
|
542
|
-
unsigned char offset;
|
543
|
-
|
544
|
-
offset = *pOffset;
|
545
|
-
partSize = Ra - offset;
|
546
|
-
if ( partSize > sizeX )
|
547
|
-
partSize = (unsigned char)sizeX;
|
548
|
-
*pOffset += partSize;
|
549
|
-
|
550
|
-
ForEveryPiston(0)
|
551
|
-
{
|
552
|
-
State_AddByte(instance->pistons.state, offset, OffsetInjectEnd); /* remove previous OffsetInjectEnd */
|
553
|
-
State_AddBytes(instance->pistons.state, X, offset, partSize );
|
554
|
-
State_AddByte(instance->pistons.state, *pOffset, OffsetInjectEnd);
|
555
|
-
if ( (diversifyFlag != Atom_False) && (partSize == sizeX) )
|
556
|
-
X[sizeX-1]++;
|
557
|
-
}
|
558
|
-
sizeX -= partSize;
|
559
|
-
|
560
|
-
/* Check block full and more data to follow */
|
561
|
-
if ( *pOffset == Ra )
|
562
|
-
{
|
563
|
-
*pOffset = 0;
|
564
|
-
if ( sizeX != 0 )
|
565
|
-
{
|
566
|
-
Engine_Spark(instance, 0, 0, 0 );
|
567
|
-
}
|
568
|
-
}
|
569
|
-
return ( partSize );
|
570
|
-
}
|
571
|
-
|
572
|
-
int Engine_InjectCollective(Engine_Instance *instance, const unsigned char *X, unsigned int sizeX, int diversifyFlag)
|
573
|
-
{
|
574
|
-
unsigned char offset;
|
575
|
-
int result;
|
576
|
-
unsigned char diversifier[2];
|
577
|
-
int dataAvailableFlag = 0;
|
578
|
-
|
579
|
-
if ( instance->phase != Engine_Phase_Fresh )
|
580
|
-
return ( Atom_Error );
|
581
|
-
offset = 0;
|
582
|
-
|
583
|
-
/* Inject X and spark while full blocks and more X available */
|
584
|
-
if ( sizeX != 0 )
|
585
|
-
{
|
586
|
-
dataAvailableFlag = 1;
|
587
|
-
do
|
588
|
-
{
|
589
|
-
result = Engine_InjectCollectiveStreamer(instance, (unsigned char *)X, sizeX, &offset, 0 );
|
590
|
-
if ( result < 0 )
|
591
|
-
return ( Atom_Error );
|
592
|
-
X += result;
|
593
|
-
}
|
594
|
-
while ( (sizeX -= result) != 0 );
|
595
|
-
}
|
596
|
-
if ( diversifyFlag != Atom_False )
|
597
|
-
{
|
598
|
-
if ( (offset == 0) && (dataAvailableFlag != 0) ) /* spark the last full block */
|
599
|
-
Engine_Spark(instance, 0, 0, 0 );
|
600
|
-
diversifier[0] = PlSnP_parallelism;
|
601
|
-
diversifier[1] = 0;
|
602
|
-
for ( result = 0, sizeX = 2; sizeX != 0; sizeX -= result )
|
603
|
-
{
|
604
|
-
result = Engine_InjectCollectiveStreamer(instance, diversifier + result, sizeX, &offset, 1 );
|
605
|
-
if ( result < 0 )
|
606
|
-
return ( Atom_Error );
|
607
|
-
}
|
608
|
-
}
|
609
|
-
instance->phase = Engine_Phase_EndOfMessage;
|
610
|
-
return ( Atom_Success );
|
611
|
-
}
|
612
|
-
|
613
|
-
int Engine_GetTags(Engine_Instance *instance, unsigned char *tag, unsigned char length, unsigned char lengthNext)
|
614
|
-
{
|
615
|
-
DeclarePistonIndex
|
616
|
-
|
617
|
-
if ( instance->phase != Engine_Phase_EndOfMessage )
|
618
|
-
return ( Atom_Error );
|
619
|
-
if ( Engine_Spark(instance, 1, length, lengthNext) != 0 )
|
620
|
-
return ( Atom_Error );
|
621
|
-
if ( length > Rs )
|
622
|
-
return ( Atom_Error );
|
623
|
-
#if PlSnP_parallelism != 1
|
624
|
-
if ( lengthNext > Rs )
|
625
|
-
return ( Atom_Error );
|
626
|
-
#endif
|
627
|
-
|
628
|
-
ForEveryPiston(0)
|
629
|
-
{
|
630
|
-
State_ExtractBytes(instance->pistons.state, tag, 0, length );
|
631
|
-
#if PlSnP_parallelism != 1
|
632
|
-
tag += length;
|
633
|
-
length = lengthNext;
|
634
|
-
#endif
|
635
|
-
}
|
636
|
-
instance->phase = Engine_Phase_Fresh;
|
637
|
-
return ( Atom_Success );
|
638
|
-
}
|
639
|
-
|
640
|
-
/* ------------------------------------------------------------------------ */
|
641
|
-
|
642
|
-
static int Motorist_MakeKnot(Motorist_Instance *instance );
|
643
|
-
static int Motorist_MakeKnot(Motorist_Instance *instance )
|
644
|
-
{
|
645
|
-
unsigned char tempTags[PlSnP_parallelism*Cprime];
|
646
|
-
|
647
|
-
if ( Engine_GetTags(&instance->engine, tempTags, Cprime, Cprime ) < 0 )
|
648
|
-
return ( Atom_Error );
|
649
|
-
return ( Engine_InjectCollective(&instance->engine, tempTags, PlSnP_parallelism * Cprime, 0) );
|
650
|
-
}
|
651
|
-
|
652
|
-
static int Motorist_HandleTag(Motorist_Instance *instance, int tagFlag, unsigned char * tag, int unwrapFlag );
|
653
|
-
static int Motorist_HandleTag(Motorist_Instance *instance, int tagFlag, unsigned char * tag, int unwrapFlag )
|
654
|
-
{
|
655
|
-
unsigned char tempTag[TagLength];
|
656
|
-
|
657
|
-
if ( tagFlag == Atom_False )
|
658
|
-
{
|
659
|
-
if ( Engine_GetTags(&instance->engine, tempTag, 0, 0 ) < 0 )
|
660
|
-
return ( Atom_Error );
|
661
|
-
}
|
662
|
-
else
|
663
|
-
{
|
664
|
-
if ( Engine_GetTags(&instance->engine, tempTag, TagLength, 0) < 0 )
|
665
|
-
return ( Atom_Error );
|
666
|
-
if ( unwrapFlag == Atom_False )
|
667
|
-
{
|
668
|
-
memcpy( tag, tempTag, TagLength );
|
669
|
-
}
|
670
|
-
else if ( memcmp( tempTag, tag, TagLength ) != 0 )
|
671
|
-
{
|
672
|
-
instance->phase = Motorist_Phase_Failed;
|
673
|
-
return ( Atom_False );
|
674
|
-
}
|
675
|
-
}
|
676
|
-
return ( Atom_True );
|
677
|
-
}
|
678
|
-
|
679
|
-
int Motorist_Initialize(Motorist_Instance *instance)
|
680
|
-
{
|
681
|
-
if ( Engine_Initialize(&instance->engine) != 0 )
|
682
|
-
return ( Atom_Error );
|
683
|
-
instance->phase = Motorist_Phase_Ready;
|
684
|
-
instance->lastFlag = 0;
|
685
|
-
return ( Atom_Success );
|
686
|
-
}
|
687
|
-
|
688
|
-
int Motorist_StartEngine(Motorist_Instance *instance, const unsigned char * SUV, size_t SUVlen, int tagFlag, unsigned char * tag, int unwrapFlag, int forgetFlag )
|
689
|
-
{
|
690
|
-
int result = Atom_False;
|
691
|
-
|
692
|
-
if ( instance->phase != Motorist_Phase_Ready )
|
693
|
-
return ( Atom_Error );
|
694
|
-
if ( Engine_InjectCollective(&instance->engine, SUV, (unsigned int)SUVlen, 1) != 0 )
|
695
|
-
return ( Atom_Error );
|
696
|
-
if ( forgetFlag != Atom_False )
|
697
|
-
if ( Motorist_MakeKnot(instance) < 0 )
|
698
|
-
return ( Atom_Error );
|
699
|
-
result = Motorist_HandleTag(instance, tagFlag, tag, unwrapFlag );
|
700
|
-
if ( result == Atom_True )
|
701
|
-
instance->phase = Motorist_Phase_Riding;
|
702
|
-
return ( result );
|
703
|
-
}
|
704
|
-
|
705
|
-
|
706
|
-
int Motorist_Wrap(Motorist_Instance *instance, const unsigned char * I, size_t Ilen, unsigned char *O,
|
707
|
-
const unsigned char * A, size_t Alen, unsigned char * tag, int unwrapFlag, int forgetFlag,
|
708
|
-
int lastFlag, size_t *processedIlen, size_t *processedAlen)
|
709
|
-
{
|
710
|
-
int resultI;
|
711
|
-
int resultA;
|
712
|
-
unsigned char *initialO;
|
713
|
-
size_t initialOlen;
|
714
|
-
|
715
|
-
initialO = O;
|
716
|
-
initialOlen = Ilen;
|
717
|
-
*processedIlen = 0;
|
718
|
-
*processedAlen = 0;
|
719
|
-
if ( instance->phase != Motorist_Phase_Riding )
|
720
|
-
return ( Atom_Error );
|
721
|
-
|
722
|
-
/* Once a lastFlag has been set, it must remain set during the session */
|
723
|
-
if ( ((instance->lastFlag & Motorist_Wrap_LastCryptData) != 0) && ((lastFlag & Motorist_Wrap_LastCryptData) == 0) )
|
724
|
-
return ( Atom_Error );
|
725
|
-
if ( ((instance->lastFlag & Motorist_Wrap_LastMetaData) != 0) && ((lastFlag & Motorist_Wrap_LastMetaData) == 0) )
|
726
|
-
return ( Atom_Error );
|
727
|
-
instance->lastFlag = (unsigned char)lastFlag;
|
728
|
-
if ( ((lastFlag & Motorist_Wrap_LastCryptData) == 0) && (Ilen != 0) )
|
729
|
-
--Ilen;
|
730
|
-
if ( ((lastFlag & Motorist_Wrap_LastMetaData) == 0) && (Alen != 0) )
|
731
|
-
--Alen;
|
732
|
-
|
733
|
-
if ( instance->engine.phase == Engine_Phase_Fresh )
|
734
|
-
{
|
735
|
-
if ( Ilen != 0 )
|
736
|
-
{
|
737
|
-
/* Caller wants to crypt. */
|
738
|
-
instance->engine.phase = Engine_Phase_Crypting;
|
739
|
-
}
|
740
|
-
else if ( (lastFlag & Motorist_Wrap_LastCryptData) == 0 )
|
741
|
-
{
|
742
|
-
/* Caller does not give input, but does not set lastCrypt flag,
|
743
|
-
** so we don't know how the phase will evolve, do nothing.
|
744
|
-
*/
|
745
|
-
return ( Atom_True );
|
746
|
-
}
|
747
|
-
else
|
748
|
-
{
|
749
|
-
/* Only metadata can follow (input is empty) */
|
750
|
-
instance->engine.phase = Engine_Phase_InjectOnly;
|
751
|
-
if ( (Alen == 0) && ((lastFlag & Motorist_Wrap_LastMetaData) != 0) )
|
752
|
-
{
|
753
|
-
/* Nothing to inject either, perform empty inject */
|
754
|
-
if ( Engine_Inject(&instance->engine, A, 0, Motorist_Wrap_LastMetaData ) != 0 )
|
755
|
-
return ( Atom_Error );
|
756
|
-
instance->engine.phase = Engine_Phase_EndOfMessage;
|
757
|
-
}
|
758
|
-
}
|
759
|
-
}
|
760
|
-
|
761
|
-
if ( instance->engine.phase == Engine_Phase_Crypting )
|
762
|
-
{
|
763
|
-
while ( Ilen != 0 )
|
764
|
-
{
|
765
|
-
/* If more data available and Crypter and Injector are full, then spark */
|
766
|
-
if ( ((Ilen | Alen) != 0) && (instance->engine.pistons.phaseCrypt == Pistons_Phase_Full) )
|
767
|
-
{
|
768
|
-
if ( instance->engine.pistons.phaseInject >= Pistons_Phase_Full ) /* Full or Done */
|
769
|
-
{
|
770
|
-
Engine_Spark(&instance->engine, 0, 0, 0 );
|
771
|
-
}
|
772
|
-
else if ( (Alen == 0) && ((lastFlag & Motorist_Wrap_LastMetaData) != 0) ) /* AD done, but Pistons not aware */
|
773
|
-
{
|
774
|
-
resultA = Engine_Inject(&instance->engine, 0, 0, Motorist_Wrap_LastMetaData );
|
775
|
-
if ( resultA < 0 )
|
776
|
-
return ( Atom_Error );
|
777
|
-
Engine_Spark(&instance->engine, 0, 0, 0 );
|
778
|
-
}
|
779
|
-
}
|
780
|
-
|
781
|
-
if ( (Ilen > (Rs*PlSnP_parallelism)) && (instance->engine.pistons.phaseCrypt == Pistons_Phase_Fresh) && (instance->engine.tagEndIndex == 0) )
|
782
|
-
{
|
783
|
-
if ( Alen > ((Ra-Rs)*PlSnP_parallelism) )
|
784
|
-
{
|
785
|
-
size_t processedI;
|
786
|
-
size_t processedA = Engine_FastWrapCryptAndInject(&instance->engine, I, Ilen, &processedI, O, A, Alen, unwrapFlag);
|
787
|
-
Alen -= processedA;
|
788
|
-
A += processedA;
|
789
|
-
*processedAlen += processedA;
|
790
|
-
Ilen -= processedI;
|
791
|
-
I += processedI;
|
792
|
-
O += processedI;
|
793
|
-
*processedIlen += processedI;
|
794
|
-
}
|
795
|
-
else if ( (Alen == 0) && ((lastFlag & Motorist_Wrap_LastMetaData) != 0) )
|
796
|
-
{
|
797
|
-
size_t processedI = Engine_FastWrapCryptOnly(&instance->engine, I, Ilen, O, unwrapFlag);
|
798
|
-
Ilen -= processedI;
|
799
|
-
I += processedI;
|
800
|
-
O += processedI;
|
801
|
-
*processedIlen += processedI;
|
802
|
-
}
|
803
|
-
}
|
804
|
-
|
805
|
-
if ( instance->engine.pistons.phaseCrypt == Pistons_Phase_Full )
|
806
|
-
resultI = 0;
|
807
|
-
else
|
808
|
-
{
|
809
|
-
resultI = Engine_Crypt(&instance->engine, I, Ilen, O, unwrapFlag, lastFlag & Motorist_Wrap_LastCryptData );
|
810
|
-
if ( resultI < 0 )
|
811
|
-
return ( Atom_Error );
|
812
|
-
*processedIlen += resultI;
|
813
|
-
Ilen -= resultI;
|
814
|
-
I += resultI;
|
815
|
-
O += resultI;
|
816
|
-
}
|
817
|
-
|
818
|
-
if ( instance->engine.pistons.phaseInject >= Pistons_Phase_Full ) /* Full or Done */
|
819
|
-
resultA = 0;
|
820
|
-
else
|
821
|
-
{
|
822
|
-
resultA = Engine_Inject(&instance->engine, A, Alen, lastFlag & Motorist_Wrap_LastMetaData );
|
823
|
-
if ( resultA < 0 )
|
824
|
-
return ( Atom_Error );
|
825
|
-
*processedAlen += resultA;
|
826
|
-
Alen -= resultA;
|
827
|
-
A += resultA;
|
828
|
-
}
|
829
|
-
|
830
|
-
if ( (instance->engine.pistons.phaseCrypt == Pistons_Phase_Done)
|
831
|
-
&& (instance->engine.pistons.phaseInject == Pistons_Phase_Done))
|
832
|
-
{
|
833
|
-
instance->engine.phase = Engine_Phase_EndOfMessage;
|
834
|
-
break;
|
835
|
-
}
|
836
|
-
|
837
|
-
if ( (resultI | resultA) == 0 )
|
838
|
-
{
|
839
|
-
/* Can't do more than that */
|
840
|
-
return ( Atom_True );
|
841
|
-
}
|
842
|
-
}
|
843
|
-
}
|
844
|
-
|
845
|
-
/* Input all done, continue injecting */
|
846
|
-
if ( (instance->engine.phase == Engine_Phase_Crypted)
|
847
|
-
|| (instance->engine.phase == Engine_Phase_InjectOnly) )
|
848
|
-
{
|
849
|
-
while ( (Alen != 0) || ((lastFlag & Motorist_Wrap_LastMetaData) != 0) )
|
850
|
-
{
|
851
|
-
/* If more data available and Injector is full, then spark */
|
852
|
-
if ( instance->engine.pistons.phaseInject == Pistons_Phase_Full )
|
853
|
-
{
|
854
|
-
Engine_Spark(&instance->engine, 0, 0, 0 );
|
855
|
-
}
|
856
|
-
|
857
|
-
if ((Alen > (Ra*PlSnP_parallelism))
|
858
|
-
&& (instance->engine.pistons.phaseInject == Pistons_Phase_Fresh)
|
859
|
-
&& (instance->engine.pistons.phaseCrypt == Pistons_Phase_Fresh) )
|
860
|
-
{
|
861
|
-
size_t processed = Engine_FastWrapInjectOnly(&instance->engine, A, Alen);
|
862
|
-
Alen -= processed;
|
863
|
-
A += processed;
|
864
|
-
*processedAlen += processed;
|
865
|
-
instance->engine.pistons.offsetInject = 0;
|
866
|
-
#if PlSnP_parallelism > 1
|
867
|
-
instance->engine.pistons.indexInject = 0;
|
868
|
-
#endif
|
869
|
-
}
|
870
|
-
|
871
|
-
resultA = Engine_Inject(&instance->engine, A, Alen, lastFlag & Motorist_Wrap_LastMetaData );
|
872
|
-
if ( resultA < 0 )
|
873
|
-
return ( Atom_Error );
|
874
|
-
*processedAlen += resultA;
|
875
|
-
Alen -= resultA;
|
876
|
-
A += resultA;
|
877
|
-
|
878
|
-
if ( instance->engine.pistons.phaseInject == Pistons_Phase_Done )
|
879
|
-
{
|
880
|
-
instance->engine.phase = Engine_Phase_EndOfMessage;
|
881
|
-
break;
|
882
|
-
}
|
883
|
-
}
|
884
|
-
}
|
885
|
-
|
886
|
-
if ( instance->engine.phase == Engine_Phase_EndOfMessage )
|
887
|
-
{
|
888
|
-
instance->lastFlag = 0;
|
889
|
-
|
890
|
-
/* Everything is processed */
|
891
|
-
#if PlSnP_parallelism == 1
|
892
|
-
if ( forgetFlag != Atom_False )
|
893
|
-
#endif
|
894
|
-
if ( Motorist_MakeKnot(instance) < 0 )
|
895
|
-
return ( Atom_Error );
|
896
|
-
resultI = Motorist_HandleTag(instance, Atom_True, tag, unwrapFlag );
|
897
|
-
if ( resultI != Atom_True )
|
898
|
-
memset( initialO, 0, initialOlen );
|
899
|
-
return ( resultI );
|
900
|
-
}
|
901
|
-
return ( Atom_True );
|
902
|
-
}
|
903
|
-
|
904
|
-
#undef W
|
905
|
-
#undef Ra
|
906
|
-
#undef Rs
|
907
|
-
#undef Cprime
|
908
|
-
|
909
|
-
#undef OffsetEOM
|
910
|
-
#undef OffsetCryptEnd
|
911
|
-
#undef OffsetInjectStart
|
912
|
-
#undef OffsetInjectEnd
|
913
|
-
|
914
|
-
#undef Engine_Instance
|
915
|
-
#undef Engine_Spark
|
916
|
-
#undef Engine_Initialize
|
917
|
-
#undef Engine_Crypt
|
918
|
-
#undef Engine_Inject
|
919
|
-
#undef Engine_InjectCollectiveStreamer
|
920
|
-
#undef Engine_InjectCollective
|
921
|
-
#undef Engine_GetTags
|
922
|
-
#undef Engine_FastWrapCryptOnly
|
923
|
-
#undef Engine_FastWrapInjectOnly
|
924
|
-
#undef Engine_FastWrapCryptAndInject
|
925
|
-
|
926
|
-
#undef Motorist_Instance
|
927
|
-
#undef Motorist_MakeKnot
|
928
|
-
#undef Motorist_HandleTag
|
929
|
-
#undef Motorist_Initialize
|
930
|
-
#undef Motorist_StartEngine
|
931
|
-
#undef Motorist_Wrap
|
932
|
-
|
933
|
-
#undef DeclarePistonIndex
|
934
|
-
#if PlSnP_parallelism == 1
|
935
|
-
#undef indexP
|
936
|
-
#endif
|
937
|
-
#undef ForEveryPiston
|
938
|
-
|
939
|
-
#undef State_StaticInitialize
|
940
|
-
#undef State_Initialize
|
941
|
-
#undef State_Permute
|
942
|
-
#undef State_AddBytes
|
943
|
-
#undef State_AddByte
|
944
|
-
#undef State_OverwriteBytes
|
945
|
-
#undef State_ExtractBytes
|
946
|
-
#undef State_ExtractAndAddBytes
|
947
|
-
#if PlSnP_parallelism > 1
|
948
|
-
#undef PlSnP_AddLanesAll
|
949
|
-
#undef PlSnP_ExtractLanesAll
|
950
|
-
#undef PlSnP_ExtractAndAddLanesAll
|
951
|
-
#endif
|
952
|
-
#undef State_AddByteU
|
953
|
-
#undef State_AddBytesU
|