sleeping_kangaroo12 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +127 -0
- data/ext/Rakefile +73 -0
- data/ext/binding/sleeping_kangaroo12.c +39 -0
- data/ext/config/xkcp.build +17 -0
- data/ext/xkcp/LICENSE +1 -0
- data/ext/xkcp/Makefile +15 -0
- data/ext/xkcp/Makefile.build +200 -0
- data/ext/xkcp/README.markdown +296 -0
- data/ext/xkcp/lib/HighLevel.build +143 -0
- data/ext/xkcp/lib/LowLevel.build +757 -0
- data/ext/xkcp/lib/common/align.h +33 -0
- data/ext/xkcp/lib/common/brg_endian.h +143 -0
- data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.c +301 -0
- data/ext/xkcp/lib/high/KangarooTwelve/KangarooTwelve.h +97 -0
- data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.c +81 -0
- data/ext/xkcp/lib/high/Keccak/FIPS202/KeccakHash.h +125 -0
- data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.c +48 -0
- data/ext/xkcp/lib/high/Keccak/FIPS202/SimpleFIPS202.h +79 -0
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.c +81 -0
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.h +73 -0
- data/ext/xkcp/lib/high/Keccak/KeccakDuplex.inc +195 -0
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.c +111 -0
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.h +76 -0
- data/ext/xkcp/lib/high/Keccak/KeccakSponge.inc +314 -0
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.c +61 -0
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.h +67 -0
- data/ext/xkcp/lib/high/Keccak/PRG/KeccakPRG.inc +128 -0
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.c +93 -0
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.h +599 -0
- data/ext/xkcp/lib/high/Keccak/SP800-185/SP800-185.inc +573 -0
- data/ext/xkcp/lib/high/Ketje/Ketjev2.c +87 -0
- data/ext/xkcp/lib/high/Ketje/Ketjev2.h +88 -0
- data/ext/xkcp/lib/high/Ketje/Ketjev2.inc +274 -0
- data/ext/xkcp/lib/high/Keyak/Keyakv2.c +132 -0
- data/ext/xkcp/lib/high/Keyak/Keyakv2.h +217 -0
- data/ext/xkcp/lib/high/Keyak/Keyakv2.inc +81 -0
- data/ext/xkcp/lib/high/Keyak/Motorist.inc +953 -0
- data/ext/xkcp/lib/high/Kravatte/Kravatte.c +533 -0
- data/ext/xkcp/lib/high/Kravatte/Kravatte.h +115 -0
- data/ext/xkcp/lib/high/Kravatte/KravatteModes.c +557 -0
- data/ext/xkcp/lib/high/Kravatte/KravatteModes.h +247 -0
- data/ext/xkcp/lib/high/Xoodyak/Cyclist.h +66 -0
- data/ext/xkcp/lib/high/Xoodyak/Cyclist.inc +336 -0
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak-parameters.h +26 -0
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak.c +55 -0
- data/ext/xkcp/lib/high/Xoodyak/Xoodyak.h +35 -0
- data/ext/xkcp/lib/high/Xoofff/Xoofff.c +634 -0
- data/ext/xkcp/lib/high/Xoofff/Xoofff.h +147 -0
- data/ext/xkcp/lib/high/Xoofff/XoofffModes.c +483 -0
- data/ext/xkcp/lib/high/Xoofff/XoofffModes.h +241 -0
- data/ext/xkcp/lib/high/common/Phases.h +25 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-SnP.h +41 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-armcc.s +1666 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv6m-le-gcc.s +1655 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-armcc.s +1268 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7a-le-gcc.s +1264 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-armcc.s +1178 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +1175 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-armcc.s +1338 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u1-32bi-armv6m-le-gcc.s +1336 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-armcc.s +1343 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARM/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +1339 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-armcc.s +823 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.s +831 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-SnP.h +31 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ARMv8A/KeccakP-1600-armv8a-neon.s +540 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-compact.s +733 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVR8/KeccakP-1600-avr8-fast.s +1121 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-AVX2.s +1100 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX2/KeccakP-1600-SnP.h +52 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-AVX512.c +623 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/KeccakP-1600-SnP.h +47 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u12/KeccakP-1600-AVX512-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/u6/KeccakP-1600-AVX512-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/C/ua/KeccakP-1600-AVX512-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-AVX512.s +1031 -0
- data/ext/xkcp/lib/low/KeccakP-1600/AVX512/KeccakP-1600-SnP.h +53 -0
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-SnP.h +44 -0
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/KeccakP-1600-XOP.c +476 -0
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/u6/KeccakP-1600-XOP-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/XOP/ua/KeccakP-1600-XOP-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-64.macros +748 -0
- data/ext/xkcp/lib/low/KeccakP-1600/common/KeccakP-1600-unrolling.macros +305 -0
- data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-SnP.h +40 -0
- data/ext/xkcp/lib/low/KeccakP-1600/compact/KeccakP-1600-compact64.c +420 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-SnP.h +43 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-32bits-inplace/KeccakP-1600-inplace32BI.c +1163 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-SnP.h +54 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/KeccakP-1600-opt64.c +565 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcu6/KeccakP-1600-opt64-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua/KeccakP-1600-opt64-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/lcua-shld/KeccakP-1600-opt64-config.h +8 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/u6/KeccakP-1600-opt64-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/plain-64bits/ua/KeccakP-1600-opt64-config.h +6 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-SnP.h +44 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference.h +23 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-32bits/KeccakP-1600-reference32BI.c +625 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-SnP.h +44 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.c +440 -0
- data/ext/xkcp/lib/low/KeccakP-1600/ref-64bits/KeccakP-1600-reference.h +23 -0
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas.s +1196 -0
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-gas_Apple.s +1124 -0
- data/ext/xkcp/lib/low/KeccakP-1600/x86-64/KeccakP-1600-x86-64-shld-gas.s +1196 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-armcc.s +1392 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +1394 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/ARMv7A-NEON/KeccakP-1600-times2-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u12/SIMD512-2-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512u4/SIMD512-2-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/AVX512ufull/SIMD512-2-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SIMD512.c +850 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/AVX512/KeccakP-1600-times2-SnP.h +51 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SIMD128.c +957 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/KeccakP-1600-times2-SnP.h +49 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-u2/SIMD128-config.h +8 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/SSSE3-ua/SIMD128-config.h +8 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-u2/SIMD128-config.h +9 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/SIMD128/XOP-ua/SIMD128-config.h +9 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times2/fallback-on1/KeccakP-1600-times2-on1.c +37 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SIMD256.c +1321 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/KeccakP-1600-times4-SnP.h +55 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u12/SIMD256-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/u6/SIMD256-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX2/ua/SIMD256-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u12/SIMD512-4-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512u4/SIMD512-4-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/AVX512ufull/SIMD512-4-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SIMD512.c +881 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/AVX512/KeccakP-1600-times4-SnP.h +51 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on1/KeccakP-1600-times4-on1.c +37 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times4/fallback-on2/KeccakP-1600-times4-on2.c +38 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SIMD512.c +1615 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/KeccakP-1600-times8-SnP.h +57 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u12/SIMD512-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/u4/SIMD512-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/AVX512/ua/SIMD512-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on1/KeccakP-1600-times8-on1.c +37 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on2/KeccakP-1600-times8-on2.c +38 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/xkcp/lib/low/KeccakP-1600-times8/fallback-on4/KeccakP-1600-times8-on4.c +38 -0
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-SnP.h +41 -0
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-armcc.s +442 -0
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv6m-le-gcc.s +446 -0
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-armcc.s +419 -0
- data/ext/xkcp/lib/low/KeccakP-200/ARM/KeccakP-200-armv7m-le-gcc.s +427 -0
- data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-SnP.h +41 -0
- data/ext/xkcp/lib/low/KeccakP-200/AVR8/KeccakP-200-avr8-fast.s +647 -0
- data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-SnP.h +39 -0
- data/ext/xkcp/lib/low/KeccakP-200/compact/KeccakP-200-compact.c +190 -0
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-SnP.h +43 -0
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.c +412 -0
- data/ext/xkcp/lib/low/KeccakP-200/ref/KeccakP-200-reference.h +23 -0
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-SnP.h +41 -0
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-armcc.s +454 -0
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv6m-le-gcc.s +458 -0
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-armcc.s +455 -0
- data/ext/xkcp/lib/low/KeccakP-400/ARM/KeccakP-400-armv7m-le-gcc.s +458 -0
- data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-SnP.h +41 -0
- data/ext/xkcp/lib/low/KeccakP-400/AVR8/KeccakP-400-avr8-fast.s +728 -0
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-SnP.h +43 -0
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.c +414 -0
- data/ext/xkcp/lib/low/KeccakP-400/ref/KeccakP-400-reference.h +23 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-armcc.s +527 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u1-armv6m-le-gcc.s +533 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-armcc.s +528 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv6m-le-gcc.s +534 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-armcc.s +521 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7a-le-gcc.s +527 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-armcc.s +517 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-u2-armv7m-le-gcc.s +523 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-armcc.s +550 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARM/KeccakP-800-uf-armv7m-le-gcc.s +556 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-SnP.h +32 -0
- data/ext/xkcp/lib/low/KeccakP-800/ARMv8A/KeccakP-800-armv8a-neon.s +432 -0
- data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-SnP.h +42 -0
- data/ext/xkcp/lib/low/KeccakP-800/AVR8/KeccakP-800-avr8-fast.s +929 -0
- data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-SnP.h +40 -0
- data/ext/xkcp/lib/low/KeccakP-800/compact/KeccakP-800-compact.c +244 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-SnP.h +46 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32-bis.macros +184 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.c +454 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-opt32.macros +459 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling-bis.macros +83 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/KeccakP-800-unrolling.macros +88 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/lcu2/KeccakP-800-opt32-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/lcua/KeccakP-800-opt32-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/u2/KeccakP-800-opt32-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-800/plain/ua/KeccakP-800-opt32-config.h +7 -0
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-SnP.h +44 -0
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.c +437 -0
- data/ext/xkcp/lib/low/KeccakP-800/ref/KeccakP-800-reference.h +23 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/Ket.h +57 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-armcc.s +475 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeJr-armv7m-le-gcc.s +480 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-armcc.s +590 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedAsmARM/KetjeSr-armv7m-le-gcc.s +590 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.c +126 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.h +68 -0
- data/ext/xkcp/lib/low/Ketje/OptimizedLE/Ket.inc +174 -0
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.c +80 -0
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.h +68 -0
- data/ext/xkcp/lib/low/Ketje/SnP-compliant/Ket.inc +142 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-SnP.h +55 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-armcc.s +1086 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-u1-armv6m-le-gcc.s +1092 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-armcc.s +721 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv6-le-gcc.s +726 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-armcc.s +723 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodoo-uf-armv7m-le-gcc.s +729 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-armcc.s +1164 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-u1-armv6m-le-gcc.s +1165 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-armcc.s +562 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv6-le-gcc.s +563 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-armcc.s +563 -0
- data/ext/xkcp/lib/low/Xoodoo/ARM/Xoodyak-uf-armv7m-le-gcc.s +565 -0
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-SnP.h +55 -0
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-armcc.s +476 -0
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodoo-uf-armv7a-neon-le-gcc.s +485 -0
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-armcc.s +362 -0
- data/ext/xkcp/lib/low/Xoodoo/ARMv7A-NEON/Xoodyak-uf-armv7a-neon-le-gcc.s +367 -0
- data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-SnP.h +43 -0
- data/ext/xkcp/lib/low/Xoodoo/AVR8/Xoodoo-avr8-u1.s +1341 -0
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SIMD512.c +581 -0
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodoo-SnP.h +58 -0
- data/ext/xkcp/lib/low/Xoodoo/AVX512/Xoodyak-full-block-SIMD512.c +332 -0
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SIMD128.c +329 -0
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodoo-SnP.h +53 -0
- data/ext/xkcp/lib/low/Xoodoo/SSE2/Xoodyak-full-block-SIMD128.c +355 -0
- data/ext/xkcp/lib/low/Xoodoo/Xoodoo.h +79 -0
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-SnP.h +56 -0
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodoo-optimized.c +399 -0
- data/ext/xkcp/lib/low/Xoodoo/plain/Xoodyak-full-blocks.c +127 -0
- data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-SnP.h +43 -0
- data/ext/xkcp/lib/low/Xoodoo/ref/Xoodoo-reference.c +253 -0
- data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SIMD512.c +1044 -0
- data/ext/xkcp/lib/low/Xoodoo-times16/AVX512/Xoodoo-times16-SnP.h +49 -0
- data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-SnP.h +45 -0
- data/ext/xkcp/lib/low/Xoodoo-times16/fallback-on1/Xoodoo-times16-on1.c +37 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-ARMv7A.s +1587 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/ARMv7A-NEON/Xoodoo-times4-SnP.h +48 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SIMD512.c +1202 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/AVX512/Xoodoo-times4-SnP.h +48 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SIMD128.c +484 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/SSSE3/Xoodoo-times4-SnP.h +44 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-SnP.h +45 -0
- data/ext/xkcp/lib/low/Xoodoo-times4/fallback-on1/Xoodoo-times4-on1.c +37 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SIMD256.c +939 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX2/Xoodoo-times8-SnP.h +49 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SIMD512.c +1216 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/AVX512/Xoodoo-times8-SnP.h +48 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-SnP.h +45 -0
- data/ext/xkcp/lib/low/Xoodoo-times8/fallback-on1/Xoodoo-times8-on1.c +37 -0
- data/ext/xkcp/lib/low/common/PlSnP-Fallback.inc +290 -0
- data/ext/xkcp/lib/low/common/SnP-Relaned.h +141 -0
- data/ext/xkcp/support/Build/ExpandProducts.xsl +79 -0
- data/ext/xkcp/support/Build/ToGlobalMakefile.xsl +206 -0
- data/ext/xkcp/support/Build/ToOneTarget.xsl +89 -0
- data/ext/xkcp/support/Build/ToTargetConfigFile.xsl +37 -0
- data/ext/xkcp/support/Build/ToTargetMakefile.xsl +298 -0
- data/ext/xkcp/support/Build/ToVCXProj.xsl +198 -0
- data/ext/xkcp/support/Kernel-PMU/Kernel-pmu.md +133 -0
- data/ext/xkcp/support/Kernel-PMU/Makefile +8 -0
- data/ext/xkcp/support/Kernel-PMU/enable_arm_pmu.c +129 -0
- data/ext/xkcp/support/Kernel-PMU/load-module +1 -0
- data/ext/xkcp/util/KeccakSum/KeccakSum.c +394 -0
- data/ext/xkcp/util/KeccakSum/base64.c +86 -0
- data/ext/xkcp/util/KeccakSum/base64.h +12 -0
- data/lib/sleeping_kangaroo12/binding.rb +15 -0
- data/lib/sleeping_kangaroo12/build/loader.rb +40 -0
- data/lib/sleeping_kangaroo12/build/platform.rb +37 -0
- data/lib/sleeping_kangaroo12/build.rb +4 -0
- data/lib/sleeping_kangaroo12/digest.rb +103 -0
- data/lib/sleeping_kangaroo12/version.rb +5 -0
- data/lib/sleeping_kangaroo12.rb +7 -0
- metadata +372 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by the designers, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#ifndef _KeccakHashInterface_h_
|
18
|
+
#define _KeccakHashInterface_h_
|
19
|
+
|
20
|
+
#include "config.h"
|
21
|
+
#ifdef XKCP_has_KeccakP1600
|
22
|
+
|
23
|
+
#include <stdint.h>
|
24
|
+
#include <string.h>
|
25
|
+
#include "KeccakSponge.h"
|
26
|
+
|
27
|
+
#ifndef _Keccak_BitTypes_
|
28
|
+
#define _Keccak_BitTypes_
|
29
|
+
typedef uint8_t BitSequence;
|
30
|
+
|
31
|
+
typedef size_t BitLength;
|
32
|
+
#endif
|
33
|
+
|
34
|
+
typedef enum { KECCAK_SUCCESS = 0, KECCAK_FAIL = 1, KECCAK_BAD_HASHLEN = 2 } HashReturn;
|
35
|
+
|
36
|
+
typedef struct {
|
37
|
+
KeccakWidth1600_SpongeInstance sponge;
|
38
|
+
unsigned int fixedOutputLength;
|
39
|
+
unsigned char delimitedSuffix;
|
40
|
+
} Keccak_HashInstance;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Function to initialize the Keccak[r, c] sponge function instance used in sequential hashing mode.
|
44
|
+
* @param hashInstance Pointer to the hash instance to be initialized.
|
45
|
+
* @param rate The value of the rate r.
|
46
|
+
* @param capacity The value of the capacity c.
|
47
|
+
* @param hashbitlen The desired number of output bits,
|
48
|
+
* or 0 for an arbitrarily-long output.
|
49
|
+
* @param delimitedSuffix Bits that will be automatically appended to the end
|
50
|
+
* of the input message, as in domain separation.
|
51
|
+
* This is a byte containing from 0 to 7 bits
|
52
|
+
* formatted like the @a delimitedData parameter of
|
53
|
+
* the Keccak_SpongeAbsorbLastFewBits() function.
|
54
|
+
* @pre One must have r+c=1600 and the rate a multiple of 8 bits in this implementation.
|
55
|
+
* @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
|
56
|
+
*/
|
57
|
+
HashReturn Keccak_HashInitialize(Keccak_HashInstance *hashInstance, unsigned int rate, unsigned int capacity, unsigned int hashbitlen, unsigned char delimitedSuffix);
|
58
|
+
|
59
|
+
/** Macro to initialize a SHAKE128 instance as specified in the FIPS 202 standard.
|
60
|
+
*/
|
61
|
+
#define Keccak_HashInitialize_SHAKE128(hashInstance) Keccak_HashInitialize(hashInstance, 1344, 256, 0, 0x1F)
|
62
|
+
|
63
|
+
/** Macro to initialize a SHAKE256 instance as specified in the FIPS 202 standard.
|
64
|
+
*/
|
65
|
+
#define Keccak_HashInitialize_SHAKE256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 0, 0x1F)
|
66
|
+
|
67
|
+
/** Macro to initialize a SHA3-224 instance as specified in the FIPS 202 standard.
|
68
|
+
*/
|
69
|
+
#define Keccak_HashInitialize_SHA3_224(hashInstance) Keccak_HashInitialize(hashInstance, 1152, 448, 224, 0x06)
|
70
|
+
|
71
|
+
/** Macro to initialize a SHA3-256 instance as specified in the FIPS 202 standard.
|
72
|
+
*/
|
73
|
+
#define Keccak_HashInitialize_SHA3_256(hashInstance) Keccak_HashInitialize(hashInstance, 1088, 512, 256, 0x06)
|
74
|
+
|
75
|
+
/** Macro to initialize a SHA3-384 instance as specified in the FIPS 202 standard.
|
76
|
+
*/
|
77
|
+
#define Keccak_HashInitialize_SHA3_384(hashInstance) Keccak_HashInitialize(hashInstance, 832, 768, 384, 0x06)
|
78
|
+
|
79
|
+
/** Macro to initialize a SHA3-512 instance as specified in the FIPS 202 standard.
|
80
|
+
*/
|
81
|
+
#define Keccak_HashInitialize_SHA3_512(hashInstance) Keccak_HashInitialize(hashInstance, 576, 1024, 512, 0x06)
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Function to give input data to be absorbed.
|
85
|
+
* @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
|
86
|
+
* @param data Pointer to the input data.
|
87
|
+
* When @a databitLen is not a multiple of 8, the last bits of data must be
|
88
|
+
* in the least significant bits of the last byte (little-endian convention).
|
89
|
+
* In this case, the (8 - @a databitLen mod 8) most significant bits
|
90
|
+
* of the last byte are ignored.
|
91
|
+
* @param databitLen The number of input bits provided in the input data.
|
92
|
+
* @pre In the previous call to Keccak_HashUpdate(), databitlen was a multiple of 8.
|
93
|
+
* @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
|
94
|
+
*/
|
95
|
+
HashReturn Keccak_HashUpdate(Keccak_HashInstance *hashInstance, const BitSequence *data, BitLength databitlen);
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Function to call after all input blocks have been input and to get
|
99
|
+
* output bits if the length was specified when calling Keccak_HashInitialize().
|
100
|
+
* @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
|
101
|
+
* If @a hashbitlen was not 0 in the call to Keccak_HashInitialize(), the number of
|
102
|
+
* output bits is equal to @a hashbitlen.
|
103
|
+
* If @a hashbitlen was 0 in the call to Keccak_HashInitialize(), the output bits
|
104
|
+
* must be extracted using the Keccak_HashSqueeze() function.
|
105
|
+
* @param hashval Pointer to the buffer where to store the output data.
|
106
|
+
* @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
|
107
|
+
*/
|
108
|
+
HashReturn Keccak_HashFinal(Keccak_HashInstance *hashInstance, BitSequence *hashval);
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Function to squeeze output data.
|
112
|
+
* @param hashInstance Pointer to the hash instance initialized by Keccak_HashInitialize().
|
113
|
+
* @param data Pointer to the buffer where to store the output data.
|
114
|
+
* @param databitlen The number of output bits desired (must be a multiple of 8).
|
115
|
+
* @pre Keccak_HashFinal() must have been already called.
|
116
|
+
* @pre @a databitlen is a multiple of 8.
|
117
|
+
* @return KECCAK_SUCCESS if successful, KECCAK_FAIL otherwise.
|
118
|
+
*/
|
119
|
+
HashReturn Keccak_HashSqueeze(Keccak_HashInstance *hashInstance, BitSequence *data, BitLength databitlen);
|
120
|
+
|
121
|
+
#else
|
122
|
+
#error This requires an implementation of Keccak-p[1600]
|
123
|
+
#endif
|
124
|
+
|
125
|
+
#endif
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by Gilles Van Assche, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "KeccakSponge.h"
|
18
|
+
#include "SimpleFIPS202.h"
|
19
|
+
|
20
|
+
int SHAKE128(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen)
|
21
|
+
{
|
22
|
+
return KeccakWidth1600_Sponge(1344, 256, input, inputByteLen, 0x1F, output, outputByteLen);
|
23
|
+
}
|
24
|
+
|
25
|
+
int SHAKE256(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen)
|
26
|
+
{
|
27
|
+
return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x1F, output, outputByteLen);
|
28
|
+
}
|
29
|
+
|
30
|
+
int SHA3_224(unsigned char *output, const unsigned char *input, size_t inputByteLen)
|
31
|
+
{
|
32
|
+
return KeccakWidth1600_Sponge(1152, 448, input, inputByteLen, 0x06, output, 224/8);
|
33
|
+
}
|
34
|
+
|
35
|
+
int SHA3_256(unsigned char *output, const unsigned char *input, size_t inputByteLen)
|
36
|
+
{
|
37
|
+
return KeccakWidth1600_Sponge(1088, 512, input, inputByteLen, 0x06, output, 256/8);
|
38
|
+
}
|
39
|
+
|
40
|
+
int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByteLen)
|
41
|
+
{
|
42
|
+
return KeccakWidth1600_Sponge( 832, 768, input, inputByteLen, 0x06, output, 384/8);
|
43
|
+
}
|
44
|
+
|
45
|
+
int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen)
|
46
|
+
{
|
47
|
+
return KeccakWidth1600_Sponge(576, 1024, input, inputByteLen, 0x06, output, 512/8);
|
48
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by Gilles Van Assche, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#ifndef _SimpleFIPS202_h_
|
18
|
+
#define _SimpleFIPS202_h_
|
19
|
+
|
20
|
+
#include "config.h"
|
21
|
+
#ifdef XKCP_has_KeccakP1600
|
22
|
+
|
23
|
+
#include <string.h>
|
24
|
+
|
25
|
+
/** Implementation of the SHAKE128 extendable output function (XOF) [FIPS 202].
|
26
|
+
* @param output Pointer to the output buffer.
|
27
|
+
* @param outputByteLen The desired number of output bytes.
|
28
|
+
* @param input Pointer to the input message.
|
29
|
+
* @param inputByteLen The length of the input message in bytes.
|
30
|
+
* @return 0 if successful, 1 otherwise.
|
31
|
+
*/
|
32
|
+
int SHAKE128(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen);
|
33
|
+
|
34
|
+
/** Implementation of the SHAKE256 extendable output function (XOF) [FIPS 202].
|
35
|
+
* @param output Pointer to the output buffer.
|
36
|
+
* @param outputByteLen The desired number of output bytes.
|
37
|
+
* @param input Pointer to the input message.
|
38
|
+
* @param inputByteLen The length of the input message in bytes.
|
39
|
+
* @return 0 if successful, 1 otherwise.
|
40
|
+
*/
|
41
|
+
int SHAKE256(unsigned char *output, size_t outputByteLen, const unsigned char *input, size_t inputByteLen);
|
42
|
+
|
43
|
+
/** Implementation of SHA3-224 [FIPS 202].
|
44
|
+
* @param output Pointer to the output buffer (28 bytes).
|
45
|
+
* @param input Pointer to the input message.
|
46
|
+
* @param inputByteLen The length of the input message in bytes.
|
47
|
+
* @return 0 if successful, 1 otherwise.
|
48
|
+
*/
|
49
|
+
int SHA3_224(unsigned char *output, const unsigned char *input, size_t inputByteLen);
|
50
|
+
|
51
|
+
/** Implementation of SHA3-256 [FIPS 202].
|
52
|
+
* @param output Pointer to the output buffer (32 bytes).
|
53
|
+
* @param input Pointer to the input message.
|
54
|
+
* @param inputByteLen The length of the input message in bytes.
|
55
|
+
* @return 0 if successful, 1 otherwise.
|
56
|
+
*/
|
57
|
+
int SHA3_256(unsigned char *output, const unsigned char *input, size_t inputByteLen);
|
58
|
+
|
59
|
+
/** Implementation of SHA3-384 [FIPS 202].
|
60
|
+
* @param output Pointer to the output buffer (48 bytes).
|
61
|
+
* @param input Pointer to the input message.
|
62
|
+
* @param inputByteLen The length of the input message in bytes.
|
63
|
+
* @return 0 if successful, 1 otherwise.
|
64
|
+
*/
|
65
|
+
int SHA3_384(unsigned char *output, const unsigned char *input, size_t inputByteLen);
|
66
|
+
|
67
|
+
/** Implementation of SHA3-512 [FIPS 202].
|
68
|
+
* @param output Pointer to the output buffer (64 bytes).
|
69
|
+
* @param input Pointer to the input message.
|
70
|
+
* @param inputByteLen The length of the input message in bytes.
|
71
|
+
* @return 0 if successful, 1 otherwise.
|
72
|
+
*/
|
73
|
+
int SHA3_512(unsigned char *output, const unsigned char *input, size_t inputByteLen);
|
74
|
+
|
75
|
+
#else
|
76
|
+
#error This requires an implementation of Keccak-p[1600]
|
77
|
+
#endif
|
78
|
+
|
79
|
+
#endif
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by the designers, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#include "KeccakDuplex.h"
|
18
|
+
|
19
|
+
#ifdef KeccakReference
|
20
|
+
#include "displayIntermediateValues.h"
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifdef XKCP_has_KeccakP200
|
24
|
+
#include "KeccakP-200-SnP.h"
|
25
|
+
|
26
|
+
#define prefix KeccakWidth200
|
27
|
+
#define SnP KeccakP200
|
28
|
+
#define SnP_width 200
|
29
|
+
#define SnP_Permute KeccakP200_Permute_18rounds
|
30
|
+
#include "KeccakDuplex.inc"
|
31
|
+
#undef prefix
|
32
|
+
#undef SnP
|
33
|
+
#undef SnP_width
|
34
|
+
#undef SnP_Permute
|
35
|
+
#undef SnP_FastLoop_Absorb
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef XKCP_has_KeccakP400
|
39
|
+
#include "KeccakP-400-SnP.h"
|
40
|
+
|
41
|
+
#define prefix KeccakWidth400
|
42
|
+
#define SnP KeccakP400
|
43
|
+
#define SnP_width 400
|
44
|
+
#define SnP_Permute KeccakP400_Permute_20rounds
|
45
|
+
#include "KeccakDuplex.inc"
|
46
|
+
#undef prefix
|
47
|
+
#undef SnP
|
48
|
+
#undef SnP_width
|
49
|
+
#undef SnP_Permute
|
50
|
+
#undef SnP_FastLoop_Absorb
|
51
|
+
#endif
|
52
|
+
|
53
|
+
#ifdef XKCP_has_KeccakP800
|
54
|
+
#include "KeccakP-800-SnP.h"
|
55
|
+
|
56
|
+
#define prefix KeccakWidth800
|
57
|
+
#define SnP KeccakP800
|
58
|
+
#define SnP_width 800
|
59
|
+
#define SnP_Permute KeccakP800_Permute_22rounds
|
60
|
+
#include "KeccakDuplex.inc"
|
61
|
+
#undef prefix
|
62
|
+
#undef SnP
|
63
|
+
#undef SnP_width
|
64
|
+
#undef SnP_Permute
|
65
|
+
#undef SnP_FastLoop_Absorb
|
66
|
+
#endif
|
67
|
+
|
68
|
+
#ifdef XKCP_has_KeccakP1600
|
69
|
+
#include "KeccakP-1600-SnP.h"
|
70
|
+
|
71
|
+
#define prefix KeccakWidth1600
|
72
|
+
#define SnP KeccakP1600
|
73
|
+
#define SnP_width 1600
|
74
|
+
#define SnP_Permute KeccakP1600_Permute_24rounds
|
75
|
+
#include "KeccakDuplex.inc"
|
76
|
+
#undef prefix
|
77
|
+
#undef SnP
|
78
|
+
#undef SnP_width
|
79
|
+
#undef SnP_Permute
|
80
|
+
#undef SnP_FastLoop_Absorb
|
81
|
+
#endif
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by the designers, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#ifndef _KeccakDuplex_h_
|
18
|
+
#define _KeccakDuplex_h_
|
19
|
+
|
20
|
+
/* For the documentation, please follow the link: */
|
21
|
+
/* #include "KeccakDuplex-documentation.h" */
|
22
|
+
|
23
|
+
#include <string.h>
|
24
|
+
#include "align.h"
|
25
|
+
#include "config.h"
|
26
|
+
|
27
|
+
#define XKCP_DeclareDuplexStructure(prefix, size, alignment) \
|
28
|
+
ALIGN(alignment) typedef struct prefix##_DuplexInstanceStruct { \
|
29
|
+
unsigned char state[size]; \
|
30
|
+
unsigned int rate; \
|
31
|
+
unsigned int byteInputIndex; \
|
32
|
+
unsigned int byteOutputIndex; \
|
33
|
+
} prefix##_DuplexInstance;
|
34
|
+
|
35
|
+
#define XKCP_DeclareDuplexFunctions(prefix) \
|
36
|
+
int prefix##_DuplexInitialize(prefix##_DuplexInstance *duplexInstance, unsigned int rate, unsigned int capacity); \
|
37
|
+
int prefix##_Duplexing(prefix##_DuplexInstance *duplexInstance, const unsigned char *sigmaBegin, unsigned int sigmaBeginByteLen, unsigned char *Z, unsigned int ZByteLen, unsigned char delimitedSigmaEnd); \
|
38
|
+
int prefix##_DuplexingFeedPartialInput(prefix##_DuplexInstance *duplexInstance, const unsigned char *input, unsigned int inputByteLen); \
|
39
|
+
int prefix##_DuplexingFeedZeroes(prefix##_DuplexInstance *duplexInstance, unsigned int inputByteLen); \
|
40
|
+
int prefix##_DuplexingOverwritePartialInput(prefix##_DuplexInstance *duplexInstance, const unsigned char *input, unsigned int inputByteLen); \
|
41
|
+
int prefix##_DuplexingOverwriteWithZeroes(prefix##_DuplexInstance *duplexInstance, unsigned int inputByteLen); \
|
42
|
+
int prefix##_DuplexingGetFurtherOutput(prefix##_DuplexInstance *duplexInstance, unsigned char *out, unsigned int outByteLen); \
|
43
|
+
int prefix##_DuplexingGetFurtherOutputAndAdd(prefix##_DuplexInstance *duplexInstance, const unsigned char *input, unsigned char *output, unsigned int outputByteLen);
|
44
|
+
|
45
|
+
#ifdef XKCP_has_KeccakP200
|
46
|
+
#include "KeccakP-200-SnP.h"
|
47
|
+
XKCP_DeclareDuplexStructure(KeccakWidth200, KeccakP200_stateSizeInBytes, KeccakP200_stateAlignment)
|
48
|
+
XKCP_DeclareDuplexFunctions(KeccakWidth200)
|
49
|
+
#define XKCP_has_Duplex_Keccak_width200
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#ifdef XKCP_has_KeccakP400
|
53
|
+
#include "KeccakP-400-SnP.h"
|
54
|
+
XKCP_DeclareDuplexStructure(KeccakWidth400, KeccakP400_stateSizeInBytes, KeccakP400_stateAlignment)
|
55
|
+
XKCP_DeclareDuplexFunctions(KeccakWidth400)
|
56
|
+
#define XKCP_has_Duplex_Keccak_width400
|
57
|
+
#endif
|
58
|
+
|
59
|
+
#ifdef XKCP_has_KeccakP800
|
60
|
+
#include "KeccakP-800-SnP.h"
|
61
|
+
XKCP_DeclareDuplexStructure(KeccakWidth800, KeccakP800_stateSizeInBytes, KeccakP800_stateAlignment)
|
62
|
+
XKCP_DeclareDuplexFunctions(KeccakWidth800)
|
63
|
+
#define XKCP_has_Duplex_Keccak_width800
|
64
|
+
#endif
|
65
|
+
|
66
|
+
#ifdef XKCP_has_KeccakP1600
|
67
|
+
#include "KeccakP-1600-SnP.h"
|
68
|
+
XKCP_DeclareDuplexStructure(KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment)
|
69
|
+
XKCP_DeclareDuplexFunctions(KeccakWidth1600)
|
70
|
+
#define XKCP_has_Duplex_Keccak_width1600
|
71
|
+
#endif
|
72
|
+
|
73
|
+
#endif
|
@@ -0,0 +1,195 @@
|
|
1
|
+
/*
|
2
|
+
The eXtended Keccak Code Package (XKCP)
|
3
|
+
https://github.com/XKCP/XKCP
|
4
|
+
|
5
|
+
Keccak, designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
|
6
|
+
|
7
|
+
Implementation by the designers, hereby denoted as "the implementer".
|
8
|
+
|
9
|
+
For more information, feedback or questions, please refer to the Keccak Team website:
|
10
|
+
https://keccak.team/
|
11
|
+
|
12
|
+
To the extent possible under law, the implementer has waived all copyright
|
13
|
+
and related or neighboring rights to the source code in this file.
|
14
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
15
|
+
*/
|
16
|
+
|
17
|
+
#define JOIN0(a, b) a ## b
|
18
|
+
#define JOIN(a, b) JOIN0(a, b)
|
19
|
+
|
20
|
+
#define DuplexInstance JOIN(prefix, _DuplexInstance)
|
21
|
+
#define DuplexInitialize JOIN(prefix, _DuplexInitialize)
|
22
|
+
#define Duplexing JOIN(prefix, _Duplexing)
|
23
|
+
#define DuplexingFeedPartialInput JOIN(prefix, _DuplexingFeedPartialInput)
|
24
|
+
#define DuplexingFeedZeroes JOIN(prefix, _DuplexingFeedZeroes)
|
25
|
+
#define DuplexingOverwritePartialInput JOIN(prefix, _DuplexingOverwritePartialInput)
|
26
|
+
#define DuplexingOverwriteWithZeroes JOIN(prefix, _DuplexingOverwriteWithZeroes)
|
27
|
+
#define DuplexingGetFurtherOutput JOIN(prefix, _DuplexingGetFurtherOutput)
|
28
|
+
#define DuplexingGetFurtherOutputAndAdd JOIN(prefix, _DuplexingGetFurtherOutputAndAdd)
|
29
|
+
|
30
|
+
#define SnP_stateSizeInBytes JOIN(SnP, _stateSizeInBytes)
|
31
|
+
#define SnP_stateAlignment JOIN(SnP, _stateAlignment)
|
32
|
+
#define SnP_StaticInitialize JOIN(SnP, _StaticInitialize)
|
33
|
+
#define SnP_Initialize JOIN(SnP, _Initialize)
|
34
|
+
#define SnP_AddByte JOIN(SnP, _AddByte)
|
35
|
+
#define SnP_AddBytes JOIN(SnP, _AddBytes)
|
36
|
+
#define SnP_OverwriteBytes JOIN(SnP, _OverwriteBytes)
|
37
|
+
#define SnP_OverwriteWithZeroes JOIN(SnP, _OverwriteWithZeroes)
|
38
|
+
#define SnP_ExtractBytes JOIN(SnP, _ExtractBytes)
|
39
|
+
#define SnP_ExtractAndAddBytes JOIN(SnP, _ExtractAndAddBytes)
|
40
|
+
|
41
|
+
int DuplexInitialize(DuplexInstance *instance, unsigned int rate, unsigned int capacity)
|
42
|
+
{
|
43
|
+
if (rate+capacity != SnP_width)
|
44
|
+
return 1;
|
45
|
+
if ((rate <= 2) || (rate > SnP_width))
|
46
|
+
return 1;
|
47
|
+
SnP_StaticInitialize();
|
48
|
+
instance->rate = rate;
|
49
|
+
SnP_Initialize(instance->state);
|
50
|
+
instance->byteInputIndex = 0;
|
51
|
+
instance->byteOutputIndex = (instance->rate+7)/8;
|
52
|
+
return 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
int Duplexing(DuplexInstance *instance, const unsigned char *sigmaBegin, unsigned int sigmaBeginByteLen, unsigned char *Z, unsigned int ZByteLen, unsigned char delimitedSigmaEnd)
|
56
|
+
{
|
57
|
+
const unsigned int rho_max = instance->rate - 2;
|
58
|
+
|
59
|
+
if (delimitedSigmaEnd == 0)
|
60
|
+
return 1;
|
61
|
+
if ((instance->byteInputIndex+sigmaBeginByteLen)*8 > rho_max)
|
62
|
+
return 1;
|
63
|
+
if (rho_max - sigmaBeginByteLen*8 < 7) {
|
64
|
+
unsigned int maxBitsInDelimitedSigmaEnd = rho_max - sigmaBeginByteLen*8;
|
65
|
+
if (delimitedSigmaEnd >= (1 << (maxBitsInDelimitedSigmaEnd+1)))
|
66
|
+
return 1;
|
67
|
+
}
|
68
|
+
if (ZByteLen > (instance->rate+7)/8)
|
69
|
+
return 1; /* The output length must not be greater than the rate (rounded up to a byte) */
|
70
|
+
|
71
|
+
SnP_AddBytes(instance->state, sigmaBegin, instance->byteInputIndex, sigmaBeginByteLen);
|
72
|
+
#ifdef KeccakReference
|
73
|
+
{
|
74
|
+
unsigned char block[SnP_width/8];
|
75
|
+
memcpy(block, sigmaBegin, sigmaBeginByteLen);
|
76
|
+
block[sigmaBeginByteLen] = delimitedSigmaEnd;
|
77
|
+
memset(block+sigmaBeginByteLen+1, 0, sizeof(block)-sigmaBeginByteLen-1);
|
78
|
+
block[(instance->rate-1)/8] |= 1 << ((instance->rate-1) % 8);
|
79
|
+
displayBytes(1, "Block to be absorbed (after padding)", block, (instance->rate+7)/8);
|
80
|
+
}
|
81
|
+
#endif
|
82
|
+
|
83
|
+
/* Last few bits, whose delimiter coincides with first bit of padding */
|
84
|
+
SnP_AddByte(instance->state, delimitedSigmaEnd, instance->byteInputIndex+sigmaBeginByteLen);
|
85
|
+
/* Second bit of padding */
|
86
|
+
SnP_AddByte(instance->state, (unsigned char)1 << ((instance->rate - 1)%8), (instance->rate - 1)/8);
|
87
|
+
SnP_Permute(instance->state);
|
88
|
+
SnP_ExtractBytes(instance->state, Z, 0, ZByteLen);
|
89
|
+
|
90
|
+
if (ZByteLen*8 > instance->rate) {
|
91
|
+
unsigned char mask = (unsigned char)(1 << (instance->rate % 8)) - 1;
|
92
|
+
Z[ZByteLen-1] &= mask;
|
93
|
+
}
|
94
|
+
|
95
|
+
instance->byteInputIndex = 0;
|
96
|
+
instance->byteOutputIndex = ZByteLen;
|
97
|
+
|
98
|
+
return 0;
|
99
|
+
}
|
100
|
+
|
101
|
+
int DuplexingFeedPartialInput(DuplexInstance *instance, const unsigned char *input, unsigned int inputByteLen)
|
102
|
+
{
|
103
|
+
const unsigned int rho_max = instance->rate - 2;
|
104
|
+
|
105
|
+
if ((instance->byteInputIndex+inputByteLen)*8 > rho_max)
|
106
|
+
return 1;
|
107
|
+
|
108
|
+
SnP_AddBytes(instance->state, input, instance->byteInputIndex, inputByteLen);
|
109
|
+
instance->byteInputIndex += inputByteLen;
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
int DuplexingFeedZeroes(DuplexInstance *instance, unsigned int inputByteLen)
|
114
|
+
{
|
115
|
+
const unsigned int rho_max = instance->rate - 2;
|
116
|
+
|
117
|
+
if ((instance->byteInputIndex+inputByteLen)*8 > rho_max)
|
118
|
+
return 1;
|
119
|
+
|
120
|
+
instance->byteInputIndex += inputByteLen;
|
121
|
+
return 0;
|
122
|
+
}
|
123
|
+
|
124
|
+
int DuplexingOverwritePartialInput(DuplexInstance *instance, const unsigned char *input, unsigned int inputByteLen)
|
125
|
+
{
|
126
|
+
const unsigned int rho_max = instance->rate - 2;
|
127
|
+
|
128
|
+
if ((instance->byteInputIndex+inputByteLen)*8 > rho_max)
|
129
|
+
return 1;
|
130
|
+
|
131
|
+
SnP_OverwriteBytes(instance->state, input, instance->byteInputIndex, inputByteLen);
|
132
|
+
instance->byteInputIndex += inputByteLen;
|
133
|
+
return 0;
|
134
|
+
}
|
135
|
+
|
136
|
+
int DuplexingOverwriteWithZeroes(DuplexInstance *instance, unsigned int inputByteLen)
|
137
|
+
{
|
138
|
+
const unsigned int rho_max = instance->rate - 2;
|
139
|
+
|
140
|
+
if ((instance->byteInputIndex != 0) || (inputByteLen*8 > rho_max))
|
141
|
+
return 1;
|
142
|
+
|
143
|
+
SnP_OverwriteWithZeroes(instance->state, inputByteLen);
|
144
|
+
instance->byteInputIndex = inputByteLen;
|
145
|
+
|
146
|
+
return 0;
|
147
|
+
}
|
148
|
+
|
149
|
+
int DuplexingGetFurtherOutput(DuplexInstance *instance, unsigned char *output, unsigned int outputByteLen)
|
150
|
+
{
|
151
|
+
if ((outputByteLen+instance->byteOutputIndex) > (instance->rate+7)/8)
|
152
|
+
return 1; /* The output length must not be greater than the rate (rounded up to a byte) */
|
153
|
+
|
154
|
+
SnP_ExtractBytes(instance->state, output, instance->byteOutputIndex, outputByteLen);
|
155
|
+
instance->byteOutputIndex += outputByteLen;
|
156
|
+
if (instance->byteOutputIndex*8 > instance->rate) {
|
157
|
+
unsigned char mask = (1 << (instance->rate % 8)) - 1;
|
158
|
+
output[outputByteLen-1] &= mask;
|
159
|
+
}
|
160
|
+
return 0;
|
161
|
+
}
|
162
|
+
|
163
|
+
int DuplexingGetFurtherOutputAndAdd(DuplexInstance *instance, const unsigned char *input, unsigned char *output, unsigned int outputByteLen)
|
164
|
+
{
|
165
|
+
if ((outputByteLen+instance->byteOutputIndex) > (instance->rate+7)/8)
|
166
|
+
return 1; /* The output length must not be greater than the rate (rounded up to a byte) */
|
167
|
+
|
168
|
+
SnP_ExtractAndAddBytes(instance->state, input, output, instance->byteOutputIndex, outputByteLen);
|
169
|
+
instance->byteOutputIndex += outputByteLen;
|
170
|
+
if (instance->byteOutputIndex*8 > instance->rate) {
|
171
|
+
unsigned char mask = (1 << (instance->rate % 8)) - 1;
|
172
|
+
output[outputByteLen-1] &= mask;
|
173
|
+
}
|
174
|
+
return 0;
|
175
|
+
}
|
176
|
+
|
177
|
+
#undef DuplexInstance
|
178
|
+
#undef DuplexInitialize
|
179
|
+
#undef Duplexing
|
180
|
+
#undef DuplexingFeedPartialInput
|
181
|
+
#undef DuplexingFeedZeroes
|
182
|
+
#undef DuplexingOverwritePartialInput
|
183
|
+
#undef DuplexingOverwriteWithZeroes
|
184
|
+
#undef DuplexingGetFurtherOutput
|
185
|
+
#undef DuplexingGetFurtherOutputAndAdd
|
186
|
+
#undef SnP_stateSizeInBytes
|
187
|
+
#undef SnP_stateAlignment
|
188
|
+
#undef SnP_StaticInitialize
|
189
|
+
#undef SnP_Initialize
|
190
|
+
#undef SnP_AddByte
|
191
|
+
#undef SnP_AddBytes
|
192
|
+
#undef SnP_OverwriteBytes
|
193
|
+
#undef SnP_OverwriteWithZeroes
|
194
|
+
#undef SnP_ExtractBytes
|
195
|
+
#undef SnP_ExtractAndAddBytes
|