digest-kangarootwelve 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +51 -11
- data/Rakefile +2 -2
- data/digest-kangarootwelve.gemspec +322 -42
- data/ext/digest/kangarootwelve/ext.c +1 -1
- data/ext/digest/kangarootwelve/extconf.rb +13 -1
- data/ext/digest/kangarootwelve/keccak/armv6m/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv6m/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-SnP.h +36 -0
- data/ext/digest/kangarootwelve/{KeccakP-1600-times2-SnP.h → keccak/armv6m/KeccakP-1600-times2-SnP.h} +10 -10
- data/ext/digest/kangarootwelve/{KeccakP-1600-times2-on1.c → keccak/armv6m/KeccakP-1600-times2-on1.c} +13 -7
- data/ext/digest/kangarootwelve/{KeccakP-1600-times4-SnP.h → keccak/armv6m/KeccakP-1600-times4-SnP.h} +10 -10
- data/ext/digest/kangarootwelve/{KeccakP-1600-times4-on1.c → keccak/armv6m/KeccakP-1600-times4-on1.c} +13 -7
- data/ext/digest/kangarootwelve/{KeccakP-1600-times8-SnP.h → keccak/armv6m/KeccakP-1600-times8-SnP.h} +10 -10
- data/ext/digest/kangarootwelve/{KeccakP-1600-times8-on1.c → keccak/armv6m/KeccakP-1600-times8-on1.c} +13 -7
- data/ext/digest/kangarootwelve/keccak/armv6m/KeccakP-1600-u2-32bi-armv6m-le-gcc.s +1334 -0
- data/ext/digest/kangarootwelve/keccak/armv6m/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/{PlSnP-Fallback.inc → keccak/armv6m/PlSnP-Fallback.inc} +11 -7
- data/ext/digest/kangarootwelve/keccak/armv6m/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-SnP.h +37 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-armv7a-le-neon-gcc.s +826 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-inplace-pl2-armv7a-neon-le-gcc.s +1245 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times2-SnP.h +38 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times4-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakP-1600-times8-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/armv7a/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-SnP.h +36 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-inplace-32bi-armv7m-le-gcc.s +1170 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/armv7m/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-SnP.h +28 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-armv8a-neon.s +537 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/armv8a/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-SnP.h +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakP-1600-x86-64-gas.s +1190 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-SnP.h +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakP-1600-x86-64-shld-gas.s +1190 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/asmx86-64shld/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-SnP.h +37 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-avr8-fast.s +1116 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/avr8/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/avr8/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/avr8/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-SnP.h +39 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP-config.h +6 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-XOP.c +473 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SIMD128.c +954 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times2-SnP.h +47 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times4-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-times8-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/bulldozer/SIMD128-config.h +9 -0
- data/ext/digest/kangarootwelve/{SnP-Relaned.h → keccak/bulldozer/SnP-Relaned.h} +13 -7
- data/ext/digest/kangarootwelve/keccak/bulldozer/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/{KangarooTwelve.c → keccak/common/KangarooTwelve.c} +6 -10
- data/ext/digest/kangarootwelve/{KangarooTwelve.h → keccak/common/KangarooTwelve.h} +3 -7
- data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex-common.h +37 -0
- data/ext/digest/kangarootwelve/keccak/common/KeccakDuplex.inc +192 -0
- data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.c +34 -0
- data/ext/digest/kangarootwelve/keccak/common/KeccakDuplexWidth1600.h +25 -0
- data/ext/digest/kangarootwelve/{KeccakSponge-common.h → keccak/common/KeccakSponge-common.h} +5 -7
- data/ext/digest/kangarootwelve/{KeccakSponge.inc → keccak/common/KeccakSponge.inc} +6 -8
- data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.c → keccak/common/KeccakSpongeWidth1600.c} +6 -8
- data/ext/digest/kangarootwelve/{KeccakSpongeWidth1600.h → keccak/common/KeccakSpongeWidth1600.h} +5 -7
- data/ext/digest/kangarootwelve/{Phases.h → keccak/common/Phases.h} +3 -7
- data/ext/digest/kangarootwelve/{align.h → keccak/common/align.h} +5 -7
- data/ext/digest/kangarootwelve/{brg_endian.h → keccak/common/brg_endian.h} +0 -0
- data/ext/digest/kangarootwelve/keccak/compact/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/{KeccakP-1600-SnP.h → keccak/compact/KeccakP-1600-SnP.h} +7 -10
- data/ext/digest/kangarootwelve/{KeccakP-1600-compact64.c → keccak/compact/KeccakP-1600-compact64.c} +11 -7
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/compact/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/compact/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/compact/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/compact/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-SnP.h +38 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-inplace32BI.c +1162 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/generic32/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/generic32/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-SnP.h +38 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-inplace32BI.c +1162 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/generic32lc/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-64.macros +2195 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64-config.h +6 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-opt64.c +541 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/generic64/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/generic64/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/generic64/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-64.macros +2195 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-opt64.c +541 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/generic64lc/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-AVX2.s +993 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-SnP.h +41 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SIMD128.c +954 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times2-SnP.h +47 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SIMD256.c +1303 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times4-SnP.h +53 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-times8-on4.c +38 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/haswell/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/haswell/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/haswell/SIMD128-config.h +8 -0
- data/ext/digest/kangarootwelve/keccak/haswell/SIMD256-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/haswell/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-64.macros +2195 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-opt64.c +541 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SIMD128.c +954 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times2-SnP.h +47 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times4-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-times8-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/SIMD128-config.h +8 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/nehalem/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-SnP.h +41 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.c +424 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-reference.h +20 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.c +176 -0
- data/ext/digest/kangarootwelve/keccak/reference/displayIntermediateValues.h +29 -0
- data/ext/digest/kangarootwelve/keccak/reference/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-SnP.h +41 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference.h +20 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-reference32BI.c +612 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times2-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times4-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakP-1600-times8-on1.c +37 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.c +176 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/displayIntermediateValues.h +29 -0
- data/ext/digest/kangarootwelve/keccak/reference32bits/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-64.macros +2195 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64-config.h +8 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-opt64.c +541 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SIMD128.c +954 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times2-SnP.h +47 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times4-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-SnP.h +45 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-times8-on2.c +38 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakP-1600-unrolling.macros +302 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/PlSnP-Fallback.inc +287 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/SIMD128-config.h +8 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/SnP-Relaned.h +140 -0
- data/ext/digest/kangarootwelve/keccak/sandybridge/ext.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KangarooTwelve.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakDuplexWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512-config.h +6 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-AVX512.c +621 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-SnP.h +42 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SIMD512.c +852 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times2-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SIMD512.c +883 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times4-SnP.h +49 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SIMD512.c +1473 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakP-1600-times8-SnP.h +53 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/KeccakSpongeWidth1600.link.c +1 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-2-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-4-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/SIMD512-config.h +7 -0
- data/ext/digest/kangarootwelve/keccak/skylakex/ext.link.c +1 -0
- data/lib/digest/kangarootwelve/version.rb +1 -1
- metadata +299 -21
@@ -0,0 +1,424 @@
|
|
1
|
+
/*
|
2
|
+
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
3
|
+
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
4
|
+
hereby denoted as "the implementer".
|
5
|
+
|
6
|
+
For more information, feedback or questions, please refer to our website:
|
7
|
+
https://keccak.team/
|
8
|
+
|
9
|
+
To the extent possible under law, the implementer has waived all copyright
|
10
|
+
and related or neighboring rights to the source code in this file.
|
11
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
This file implements Keccak-p[1600] in a SnP-compatible way.
|
16
|
+
Please refer to SnP-documentation.h for more details.
|
17
|
+
|
18
|
+
This implementation comes with KeccakP-1600-SnP.h in the same folder.
|
19
|
+
Please refer to LowLevel.build for the exact list of other files it must be combined with.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <assert.h>
|
23
|
+
#include <stdio.h>
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <string.h>
|
26
|
+
#include "brg_endian.h"
|
27
|
+
#ifdef KeccakReference
|
28
|
+
#include "displayIntermediateValues.h"
|
29
|
+
#endif
|
30
|
+
|
31
|
+
typedef unsigned char UINT8;
|
32
|
+
typedef unsigned long long UINT64;
|
33
|
+
typedef UINT64 tKeccakLane;
|
34
|
+
|
35
|
+
#define maxNrRounds 24
|
36
|
+
#define nrLanes 25
|
37
|
+
#define index(x, y) (((x)%5)+5*((y)%5))
|
38
|
+
|
39
|
+
#ifdef KeccakReference
|
40
|
+
|
41
|
+
static tKeccakLane KeccakRoundConstants[maxNrRounds];
|
42
|
+
static unsigned int KeccakRhoOffsets[nrLanes];
|
43
|
+
|
44
|
+
/* ---------------------------------------------------------------- */
|
45
|
+
|
46
|
+
void KeccakP1600_InitializeRoundConstants(void);
|
47
|
+
void KeccakP1600_InitializeRhoOffsets(void);
|
48
|
+
static int LFSR86540(UINT8 *LFSR);
|
49
|
+
|
50
|
+
void KeccakP1600_StaticInitialize(void)
|
51
|
+
{
|
52
|
+
if (sizeof(tKeccakLane) != 8) {
|
53
|
+
printf("tKeccakLane should be 64-bit wide\n");
|
54
|
+
abort();
|
55
|
+
}
|
56
|
+
KeccakP1600_InitializeRoundConstants();
|
57
|
+
KeccakP1600_InitializeRhoOffsets();
|
58
|
+
}
|
59
|
+
|
60
|
+
void KeccakP1600_InitializeRoundConstants(void)
|
61
|
+
{
|
62
|
+
UINT8 LFSRstate = 0x01;
|
63
|
+
unsigned int i, j, bitPosition;
|
64
|
+
|
65
|
+
for(i=0; i<maxNrRounds; i++) {
|
66
|
+
KeccakRoundConstants[i] = 0;
|
67
|
+
for(j=0; j<7; j++) {
|
68
|
+
bitPosition = (1<<j)-1; /* 2^j-1 */
|
69
|
+
if (LFSR86540(&LFSRstate))
|
70
|
+
KeccakRoundConstants[i] ^= (tKeccakLane)1<<bitPosition;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
void KeccakP1600_InitializeRhoOffsets(void)
|
76
|
+
{
|
77
|
+
unsigned int x, y, t, newX, newY;
|
78
|
+
|
79
|
+
KeccakRhoOffsets[index(0, 0)] = 0;
|
80
|
+
x = 1;
|
81
|
+
y = 0;
|
82
|
+
for(t=0; t<24; t++) {
|
83
|
+
KeccakRhoOffsets[index(x, y)] = ((t+1)*(t+2)/2) % 64;
|
84
|
+
newX = (0*x+1*y) % 5;
|
85
|
+
newY = (2*x+3*y) % 5;
|
86
|
+
x = newX;
|
87
|
+
y = newY;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
static int LFSR86540(UINT8 *LFSR)
|
92
|
+
{
|
93
|
+
int result = ((*LFSR) & 0x01) != 0;
|
94
|
+
if (((*LFSR) & 0x80) != 0)
|
95
|
+
/* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
|
96
|
+
(*LFSR) = ((*LFSR) << 1) ^ 0x71;
|
97
|
+
else
|
98
|
+
(*LFSR) <<= 1;
|
99
|
+
return result;
|
100
|
+
}
|
101
|
+
|
102
|
+
#else
|
103
|
+
|
104
|
+
static const tKeccakLane KeccakRoundConstants[maxNrRounds] =
|
105
|
+
{
|
106
|
+
0x0000000000000001,
|
107
|
+
0x0000000000008082,
|
108
|
+
0x800000000000808a,
|
109
|
+
0x8000000080008000,
|
110
|
+
0x000000000000808b,
|
111
|
+
0x0000000080000001,
|
112
|
+
0x8000000080008081,
|
113
|
+
0x8000000000008009,
|
114
|
+
0x000000000000008a,
|
115
|
+
0x0000000000000088,
|
116
|
+
0x0000000080008009,
|
117
|
+
0x000000008000000a,
|
118
|
+
0x000000008000808b,
|
119
|
+
0x800000000000008b,
|
120
|
+
0x8000000000008089,
|
121
|
+
0x8000000000008003,
|
122
|
+
0x8000000000008002,
|
123
|
+
0x8000000000000080,
|
124
|
+
0x000000000000800a,
|
125
|
+
0x800000008000000a,
|
126
|
+
0x8000000080008081,
|
127
|
+
0x8000000000008080,
|
128
|
+
0x0000000080000001,
|
129
|
+
0x8000000080008008,
|
130
|
+
};
|
131
|
+
|
132
|
+
static const unsigned int KeccakRhoOffsets[nrLanes] =
|
133
|
+
{
|
134
|
+
0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14
|
135
|
+
};
|
136
|
+
|
137
|
+
#endif
|
138
|
+
|
139
|
+
/* ---------------------------------------------------------------- */
|
140
|
+
|
141
|
+
void KeccakP1600_Initialize(void *state)
|
142
|
+
{
|
143
|
+
memset(state, 0, 1600/8);
|
144
|
+
}
|
145
|
+
|
146
|
+
/* ---------------------------------------------------------------- */
|
147
|
+
|
148
|
+
void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset)
|
149
|
+
{
|
150
|
+
assert(offset < 200);
|
151
|
+
((unsigned char *)state)[offset] ^= byte;
|
152
|
+
}
|
153
|
+
|
154
|
+
/* ---------------------------------------------------------------- */
|
155
|
+
|
156
|
+
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
157
|
+
{
|
158
|
+
unsigned int i;
|
159
|
+
|
160
|
+
assert(offset < 200);
|
161
|
+
assert(offset+length <= 200);
|
162
|
+
for(i=0; i<length; i++)
|
163
|
+
((unsigned char *)state)[offset+i] ^= data[i];
|
164
|
+
}
|
165
|
+
|
166
|
+
/* ---------------------------------------------------------------- */
|
167
|
+
|
168
|
+
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
169
|
+
{
|
170
|
+
assert(offset < 200);
|
171
|
+
assert(offset+length <= 200);
|
172
|
+
memcpy((unsigned char*)state+offset, data, length);
|
173
|
+
}
|
174
|
+
|
175
|
+
/* ---------------------------------------------------------------- */
|
176
|
+
|
177
|
+
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
|
178
|
+
{
|
179
|
+
assert(byteCount <= 200);
|
180
|
+
memset(state, 0, byteCount);
|
181
|
+
}
|
182
|
+
|
183
|
+
/* ---------------------------------------------------------------- */
|
184
|
+
|
185
|
+
static void fromBytesToWords(tKeccakLane *stateAsWords, const unsigned char *state);
|
186
|
+
static void fromWordsToBytes(unsigned char *state, const tKeccakLane *stateAsWords);
|
187
|
+
void KeccakP1600OnWords(tKeccakLane *state, unsigned int nrRounds);
|
188
|
+
void KeccakP1600Round(tKeccakLane *state, unsigned int indexRound);
|
189
|
+
static void theta(tKeccakLane *A);
|
190
|
+
static void rho(tKeccakLane *A);
|
191
|
+
static void pi(tKeccakLane *A);
|
192
|
+
static void chi(tKeccakLane *A);
|
193
|
+
static void iota(tKeccakLane *A, unsigned int indexRound);
|
194
|
+
|
195
|
+
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds)
|
196
|
+
{
|
197
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
198
|
+
tKeccakLane stateAsWords[1600/64];
|
199
|
+
#endif
|
200
|
+
|
201
|
+
#ifdef KeccakReference
|
202
|
+
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
203
|
+
#endif
|
204
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
205
|
+
KeccakP1600OnWords((tKeccakLane*)state, nrounds);
|
206
|
+
#else
|
207
|
+
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
208
|
+
KeccakP1600OnWords(stateAsWords, nrounds);
|
209
|
+
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
210
|
+
#endif
|
211
|
+
#ifdef KeccakReference
|
212
|
+
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
213
|
+
#endif
|
214
|
+
}
|
215
|
+
|
216
|
+
void KeccakP1600_Permute_12rounds(void *state)
|
217
|
+
{
|
218
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
219
|
+
tKeccakLane stateAsWords[1600/64];
|
220
|
+
#endif
|
221
|
+
|
222
|
+
#ifdef KeccakReference
|
223
|
+
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
224
|
+
#endif
|
225
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
226
|
+
KeccakP1600OnWords((tKeccakLane*)state, 12);
|
227
|
+
#else
|
228
|
+
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
229
|
+
KeccakP1600OnWords(stateAsWords, 12);
|
230
|
+
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
231
|
+
#endif
|
232
|
+
#ifdef KeccakReference
|
233
|
+
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
234
|
+
#endif
|
235
|
+
}
|
236
|
+
|
237
|
+
void KeccakP1600_Permute_24rounds(void *state)
|
238
|
+
{
|
239
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
240
|
+
tKeccakLane stateAsWords[1600/64];
|
241
|
+
#endif
|
242
|
+
|
243
|
+
#ifdef KeccakReference
|
244
|
+
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
245
|
+
#endif
|
246
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
247
|
+
KeccakP1600OnWords((tKeccakLane*)state, 24);
|
248
|
+
#else
|
249
|
+
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
250
|
+
KeccakP1600OnWords(stateAsWords, 24);
|
251
|
+
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
252
|
+
#endif
|
253
|
+
#ifdef KeccakReference
|
254
|
+
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
255
|
+
#endif
|
256
|
+
}
|
257
|
+
|
258
|
+
static void fromBytesToWords(tKeccakLane *stateAsWords, const unsigned char *state)
|
259
|
+
{
|
260
|
+
unsigned int i, j;
|
261
|
+
|
262
|
+
for(i=0; i<nrLanes; i++) {
|
263
|
+
stateAsWords[i] = 0;
|
264
|
+
for(j=0; j<(64/8); j++)
|
265
|
+
stateAsWords[i] |= (tKeccakLane)(state[i*(64/8)+j]) << (8*j);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
static void fromWordsToBytes(unsigned char *state, const tKeccakLane *stateAsWords)
|
270
|
+
{
|
271
|
+
unsigned int i, j;
|
272
|
+
|
273
|
+
for(i=0; i<nrLanes; i++)
|
274
|
+
for(j=0; j<(64/8); j++)
|
275
|
+
state[i*(64/8)+j] = (unsigned char)((stateAsWords[i] >> (8*j)) & 0xFF);
|
276
|
+
}
|
277
|
+
|
278
|
+
void KeccakP1600OnWords(tKeccakLane *state, unsigned int nrRounds)
|
279
|
+
{
|
280
|
+
unsigned int i;
|
281
|
+
|
282
|
+
#ifdef KeccakReference
|
283
|
+
displayStateAsLanes(3, "Same, with lanes as 64-bit words", state, 1600);
|
284
|
+
#endif
|
285
|
+
|
286
|
+
for(i=(maxNrRounds-nrRounds); i<maxNrRounds; i++)
|
287
|
+
KeccakP1600Round(state, i);
|
288
|
+
}
|
289
|
+
|
290
|
+
void KeccakP1600Round(tKeccakLane *state, unsigned int indexRound)
|
291
|
+
{
|
292
|
+
#ifdef KeccakReference
|
293
|
+
displayRoundNumber(3, indexRound);
|
294
|
+
#endif
|
295
|
+
|
296
|
+
theta(state);
|
297
|
+
#ifdef KeccakReference
|
298
|
+
displayStateAsLanes(3, "After theta", state, 1600);
|
299
|
+
#endif
|
300
|
+
|
301
|
+
rho(state);
|
302
|
+
#ifdef KeccakReference
|
303
|
+
displayStateAsLanes(3, "After rho", state, 1600);
|
304
|
+
#endif
|
305
|
+
|
306
|
+
pi(state);
|
307
|
+
#ifdef KeccakReference
|
308
|
+
displayStateAsLanes(3, "After pi", state, 1600);
|
309
|
+
#endif
|
310
|
+
|
311
|
+
chi(state);
|
312
|
+
#ifdef KeccakReference
|
313
|
+
displayStateAsLanes(3, "After chi", state, 1600);
|
314
|
+
#endif
|
315
|
+
|
316
|
+
iota(state, indexRound);
|
317
|
+
#ifdef KeccakReference
|
318
|
+
displayStateAsLanes(3, "After iota", state, 1600);
|
319
|
+
#endif
|
320
|
+
}
|
321
|
+
|
322
|
+
#define ROL64(a, offset) ((offset != 0) ? ((((tKeccakLane)a) << offset) ^ (((tKeccakLane)a) >> (64-offset))) : a)
|
323
|
+
|
324
|
+
static void theta(tKeccakLane *A)
|
325
|
+
{
|
326
|
+
unsigned int x, y;
|
327
|
+
tKeccakLane C[5], D[5];
|
328
|
+
|
329
|
+
for(x=0; x<5; x++) {
|
330
|
+
C[x] = 0;
|
331
|
+
for(y=0; y<5; y++)
|
332
|
+
C[x] ^= A[index(x, y)];
|
333
|
+
}
|
334
|
+
for(x=0; x<5; x++)
|
335
|
+
D[x] = ROL64(C[(x+1)%5], 1) ^ C[(x+4)%5];
|
336
|
+
for(x=0; x<5; x++)
|
337
|
+
for(y=0; y<5; y++)
|
338
|
+
A[index(x, y)] ^= D[x];
|
339
|
+
}
|
340
|
+
|
341
|
+
static void rho(tKeccakLane *A)
|
342
|
+
{
|
343
|
+
unsigned int x, y;
|
344
|
+
|
345
|
+
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
346
|
+
A[index(x, y)] = ROL64(A[index(x, y)], KeccakRhoOffsets[index(x, y)]);
|
347
|
+
}
|
348
|
+
|
349
|
+
static void pi(tKeccakLane *A)
|
350
|
+
{
|
351
|
+
unsigned int x, y;
|
352
|
+
tKeccakLane tempA[25];
|
353
|
+
|
354
|
+
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
355
|
+
tempA[index(x, y)] = A[index(x, y)];
|
356
|
+
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
357
|
+
A[index(0*x+1*y, 2*x+3*y)] = tempA[index(x, y)];
|
358
|
+
}
|
359
|
+
|
360
|
+
static void chi(tKeccakLane *A)
|
361
|
+
{
|
362
|
+
unsigned int x, y;
|
363
|
+
tKeccakLane C[5];
|
364
|
+
|
365
|
+
for(y=0; y<5; y++) {
|
366
|
+
for(x=0; x<5; x++)
|
367
|
+
C[x] = A[index(x, y)] ^ ((~A[index(x+1, y)]) & A[index(x+2, y)]);
|
368
|
+
for(x=0; x<5; x++)
|
369
|
+
A[index(x, y)] = C[x];
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
static void iota(tKeccakLane *A, unsigned int indexRound)
|
374
|
+
{
|
375
|
+
A[index(0, 0)] ^= KeccakRoundConstants[indexRound];
|
376
|
+
}
|
377
|
+
|
378
|
+
/* ---------------------------------------------------------------- */
|
379
|
+
|
380
|
+
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
|
381
|
+
{
|
382
|
+
assert(offset < 200);
|
383
|
+
assert(offset+length <= 200);
|
384
|
+
memcpy(data, (unsigned char*)state+offset, length);
|
385
|
+
}
|
386
|
+
|
387
|
+
/* ---------------------------------------------------------------- */
|
388
|
+
|
389
|
+
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
|
390
|
+
{
|
391
|
+
unsigned int i;
|
392
|
+
|
393
|
+
assert(offset < 200);
|
394
|
+
assert(offset+length <= 200);
|
395
|
+
for(i=0; i<length; i++)
|
396
|
+
output[i] = input[i] ^ ((unsigned char *)state)[offset+i];
|
397
|
+
}
|
398
|
+
|
399
|
+
/* ---------------------------------------------------------------- */
|
400
|
+
|
401
|
+
void KeccakP1600_DisplayRoundConstants(FILE *f)
|
402
|
+
{
|
403
|
+
unsigned int i;
|
404
|
+
|
405
|
+
for(i=0; i<maxNrRounds; i++) {
|
406
|
+
fprintf(f, "RC[%02i][0][0] = ", i);
|
407
|
+
fprintf(f, "%08X", (unsigned int)(KeccakRoundConstants[i] >> 32));
|
408
|
+
fprintf(f, "%08X", (unsigned int)(KeccakRoundConstants[i] & 0xFFFFFFFFULL));
|
409
|
+
fprintf(f, "\n");
|
410
|
+
}
|
411
|
+
fprintf(f, "\n");
|
412
|
+
}
|
413
|
+
|
414
|
+
void KeccakP1600_DisplayRhoOffsets(FILE *f)
|
415
|
+
{
|
416
|
+
unsigned int x, y;
|
417
|
+
|
418
|
+
for(y=0; y<5; y++) for(x=0; x<5; x++) {
|
419
|
+
fprintf(f, "RhoOffset[%i][%i] = ", x, y);
|
420
|
+
fprintf(f, "%2i", KeccakRhoOffsets[index(x, y)]);
|
421
|
+
fprintf(f, "\n");
|
422
|
+
}
|
423
|
+
fprintf(f, "\n");
|
424
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
3
|
+
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
4
|
+
hereby denoted as "the implementer".
|
5
|
+
|
6
|
+
For more information, feedback or questions, please refer to our website:
|
7
|
+
https://keccak.team/
|
8
|
+
|
9
|
+
To the extent possible under law, the implementer has waived all copyright
|
10
|
+
and related or neighboring rights to the source code in this file.
|
11
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef _KeccakP_1600_reference_h_
|
15
|
+
#define _KeccakP_1600_reference_h_
|
16
|
+
|
17
|
+
void KeccakP1600_DisplayRoundConstants(FILE *f);
|
18
|
+
void KeccakP1600_DisplayRhoOffsets(FILE *f);
|
19
|
+
|
20
|
+
#endif
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/*
|
2
|
+
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
3
|
+
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
4
|
+
hereby denoted as "the implementer".
|
5
|
+
|
6
|
+
For more information, feedback or questions, please refer to our website:
|
7
|
+
https://keccak.team/
|
8
|
+
|
9
|
+
To the extent possible under law, the implementer has waived all copyright
|
10
|
+
and related or neighboring rights to the source code in this file.
|
11
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
Please refer to PlSnP-documentation.h for more details.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#ifndef _KeccakP_1600_times2_SnP_h_
|
19
|
+
#define _KeccakP_1600_times2_SnP_h_
|
20
|
+
|
21
|
+
#include "KeccakP-1600-SnP.h"
|
22
|
+
|
23
|
+
#define KeccakP1600times2_implementation "fallback on serial implementation (" KeccakP1600_implementation ")"
|
24
|
+
#define KeccakP1600times2_statesSizeInBytes (((KeccakP1600_stateSizeInBytes+(KeccakP1600_stateAlignment-1))/KeccakP1600_stateAlignment)*KeccakP1600_stateAlignment*2)
|
25
|
+
#define KeccakP1600times2_statesAlignment KeccakP1600_stateAlignment
|
26
|
+
#define KeccakP1600times2_isFallback
|
27
|
+
|
28
|
+
void KeccakP1600times2_StaticInitialize( void );
|
29
|
+
void KeccakP1600times2_InitializeAll(void *states);
|
30
|
+
void KeccakP1600times2_AddByte(void *states, unsigned int instanceIndex, unsigned char data, unsigned int offset);
|
31
|
+
void KeccakP1600times2_AddBytes(void *states, unsigned int instanceIndex, const unsigned char *data, unsigned int offset, unsigned int length);
|
32
|
+
void KeccakP1600times2_AddLanesAll(void *states, const unsigned char *data, unsigned int laneCount, unsigned int laneOffset);
|
33
|
+
void KeccakP1600times2_OverwriteBytes(void *states, unsigned int instanceIndex, const unsigned char *data, unsigned int offset, unsigned int length);
|
34
|
+
void KeccakP1600times2_OverwriteLanesAll(void *states, const unsigned char *data, unsigned int laneCount, unsigned int laneOffset);
|
35
|
+
void KeccakP1600times2_OverwriteWithZeroes(void *states, unsigned int instanceIndex, unsigned int byteCount);
|
36
|
+
void KeccakP1600times2_PermuteAll_4rounds(void *states);
|
37
|
+
void KeccakP1600times2_PermuteAll_6rounds(void *states);
|
38
|
+
void KeccakP1600times2_PermuteAll_12rounds(void *states);
|
39
|
+
void KeccakP1600times2_PermuteAll_24rounds(void *states);
|
40
|
+
void KeccakP1600times2_ExtractBytes(const void *states, unsigned int instanceIndex, unsigned char *data, unsigned int offset, unsigned int length);
|
41
|
+
void KeccakP1600times2_ExtractLanesAll(const void *states, unsigned char *data, unsigned int laneCount, unsigned int laneOffset);
|
42
|
+
void KeccakP1600times2_ExtractAndAddBytes(const void *states, unsigned int instanceIndex, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
|
43
|
+
void KeccakP1600times2_ExtractAndAddLanesAll(const void *states, const unsigned char *input, unsigned char *output, unsigned int laneCount, unsigned int laneOffset);
|
44
|
+
|
45
|
+
#endif
|