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,49 @@
|
|
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 SnP-documentation.h for more details.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#ifndef _KeccakP_1600_SnP_h_
|
19
|
+
#define _KeccakP_1600_SnP_h_
|
20
|
+
|
21
|
+
#include "brg_endian.h"
|
22
|
+
#include "KeccakP-1600-opt64-config.h"
|
23
|
+
|
24
|
+
#define KeccakP1600_implementation "generic 64-bit optimized implementation (" KeccakP1600_implementation_config ")"
|
25
|
+
#define KeccakP1600_stateSizeInBytes 200
|
26
|
+
#define KeccakP1600_stateAlignment 8
|
27
|
+
#define KeccakF1600_FastLoop_supported
|
28
|
+
|
29
|
+
#include <stddef.h>
|
30
|
+
|
31
|
+
#define KeccakP1600_StaticInitialize()
|
32
|
+
void KeccakP1600_Initialize(void *state);
|
33
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
34
|
+
#define KeccakP1600_AddByte(state, byte, offset) \
|
35
|
+
((unsigned char*)(state))[(offset)] ^= (byte)
|
36
|
+
#else
|
37
|
+
void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
|
38
|
+
#endif
|
39
|
+
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
|
40
|
+
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
|
41
|
+
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
|
42
|
+
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
|
43
|
+
void KeccakP1600_Permute_12rounds(void *state);
|
44
|
+
void KeccakP1600_Permute_24rounds(void *state);
|
45
|
+
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
|
46
|
+
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
|
47
|
+
size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen);
|
48
|
+
|
49
|
+
#endif
|
@@ -0,0 +1,541 @@
|
|
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 <string.h>
|
23
|
+
#include <stdlib.h>
|
24
|
+
#include "brg_endian.h"
|
25
|
+
#include "KeccakP-1600-opt64-config.h"
|
26
|
+
|
27
|
+
typedef unsigned char UINT8;
|
28
|
+
typedef unsigned long long int UINT64;
|
29
|
+
|
30
|
+
#if defined(KeccakP1600_useLaneComplementing)
|
31
|
+
#define UseBebigokimisa
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#if defined(_MSC_VER)
|
35
|
+
#define ROL64(a, offset) _rotl64(a, offset)
|
36
|
+
#elif defined(KeccakP1600_useSHLD)
|
37
|
+
#define ROL64(x,N) ({ \
|
38
|
+
register UINT64 __out; \
|
39
|
+
register UINT64 __in = x; \
|
40
|
+
__asm__ ("shld %2,%0,%0" : "=r"(__out) : "0"(__in), "i"(N)); \
|
41
|
+
__out; \
|
42
|
+
})
|
43
|
+
#else
|
44
|
+
#define ROL64(a, offset) ((((UINT64)a) << offset) ^ (((UINT64)a) >> (64-offset)))
|
45
|
+
#endif
|
46
|
+
|
47
|
+
#include "KeccakP-1600-64.macros"
|
48
|
+
#ifdef KeccakP1600_fullUnrolling
|
49
|
+
#define FullUnrolling
|
50
|
+
#else
|
51
|
+
#define Unrolling KeccakP1600_unrolling
|
52
|
+
#endif
|
53
|
+
#include "KeccakP-1600-unrolling.macros"
|
54
|
+
#include "SnP-Relaned.h"
|
55
|
+
|
56
|
+
static const UINT64 KeccakF1600RoundConstants[24] = {
|
57
|
+
0x0000000000000001ULL,
|
58
|
+
0x0000000000008082ULL,
|
59
|
+
0x800000000000808aULL,
|
60
|
+
0x8000000080008000ULL,
|
61
|
+
0x000000000000808bULL,
|
62
|
+
0x0000000080000001ULL,
|
63
|
+
0x8000000080008081ULL,
|
64
|
+
0x8000000000008009ULL,
|
65
|
+
0x000000000000008aULL,
|
66
|
+
0x0000000000000088ULL,
|
67
|
+
0x0000000080008009ULL,
|
68
|
+
0x000000008000000aULL,
|
69
|
+
0x000000008000808bULL,
|
70
|
+
0x800000000000008bULL,
|
71
|
+
0x8000000000008089ULL,
|
72
|
+
0x8000000000008003ULL,
|
73
|
+
0x8000000000008002ULL,
|
74
|
+
0x8000000000000080ULL,
|
75
|
+
0x000000000000800aULL,
|
76
|
+
0x800000008000000aULL,
|
77
|
+
0x8000000080008081ULL,
|
78
|
+
0x8000000000008080ULL,
|
79
|
+
0x0000000080000001ULL,
|
80
|
+
0x8000000080008008ULL };
|
81
|
+
|
82
|
+
/* ---------------------------------------------------------------- */
|
83
|
+
|
84
|
+
void KeccakP1600_Initialize(void *state)
|
85
|
+
{
|
86
|
+
memset(state, 0, 200);
|
87
|
+
#ifdef KeccakP1600_useLaneComplementing
|
88
|
+
((UINT64*)state)[ 1] = ~(UINT64)0;
|
89
|
+
((UINT64*)state)[ 2] = ~(UINT64)0;
|
90
|
+
((UINT64*)state)[ 8] = ~(UINT64)0;
|
91
|
+
((UINT64*)state)[12] = ~(UINT64)0;
|
92
|
+
((UINT64*)state)[17] = ~(UINT64)0;
|
93
|
+
((UINT64*)state)[20] = ~(UINT64)0;
|
94
|
+
#endif
|
95
|
+
}
|
96
|
+
|
97
|
+
/* ---------------------------------------------------------------- */
|
98
|
+
|
99
|
+
void KeccakP1600_AddBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
|
100
|
+
{
|
101
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
102
|
+
UINT64 lane;
|
103
|
+
if (length == 0)
|
104
|
+
return;
|
105
|
+
if (length == 1)
|
106
|
+
lane = data[0];
|
107
|
+
else {
|
108
|
+
lane = 0;
|
109
|
+
memcpy(&lane, data, length);
|
110
|
+
}
|
111
|
+
lane <<= offset*8;
|
112
|
+
#else
|
113
|
+
UINT64 lane = 0;
|
114
|
+
unsigned int i;
|
115
|
+
for(i=0; i<length; i++)
|
116
|
+
lane |= ((UINT64)data[i]) << ((i+offset)*8);
|
117
|
+
#endif
|
118
|
+
((UINT64*)state)[lanePosition] ^= lane;
|
119
|
+
}
|
120
|
+
|
121
|
+
/* ---------------------------------------------------------------- */
|
122
|
+
|
123
|
+
void KeccakP1600_AddLanes(void *state, const unsigned char *data, unsigned int laneCount)
|
124
|
+
{
|
125
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
126
|
+
unsigned int i = 0;
|
127
|
+
#ifdef NO_MISALIGNED_ACCESSES
|
128
|
+
/* If either pointer is misaligned, fall back to byte-wise xor. */
|
129
|
+
if (((((uintptr_t)state) & 7) != 0) || ((((uintptr_t)data) & 7) != 0)) {
|
130
|
+
for (i = 0; i < laneCount * 8; i++) {
|
131
|
+
((unsigned char*)state)[i] ^= data[i];
|
132
|
+
}
|
133
|
+
}
|
134
|
+
else
|
135
|
+
#endif
|
136
|
+
{
|
137
|
+
/* Otherwise... */
|
138
|
+
for( ; (i+8)<=laneCount; i+=8) {
|
139
|
+
((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
|
140
|
+
((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
|
141
|
+
((UINT64*)state)[i+2] ^= ((UINT64*)data)[i+2];
|
142
|
+
((UINT64*)state)[i+3] ^= ((UINT64*)data)[i+3];
|
143
|
+
((UINT64*)state)[i+4] ^= ((UINT64*)data)[i+4];
|
144
|
+
((UINT64*)state)[i+5] ^= ((UINT64*)data)[i+5];
|
145
|
+
((UINT64*)state)[i+6] ^= ((UINT64*)data)[i+6];
|
146
|
+
((UINT64*)state)[i+7] ^= ((UINT64*)data)[i+7];
|
147
|
+
}
|
148
|
+
for( ; (i+4)<=laneCount; i+=4) {
|
149
|
+
((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
|
150
|
+
((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
|
151
|
+
((UINT64*)state)[i+2] ^= ((UINT64*)data)[i+2];
|
152
|
+
((UINT64*)state)[i+3] ^= ((UINT64*)data)[i+3];
|
153
|
+
}
|
154
|
+
for( ; (i+2)<=laneCount; i+=2) {
|
155
|
+
((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
|
156
|
+
((UINT64*)state)[i+1] ^= ((UINT64*)data)[i+1];
|
157
|
+
}
|
158
|
+
if (i<laneCount) {
|
159
|
+
((UINT64*)state)[i+0] ^= ((UINT64*)data)[i+0];
|
160
|
+
}
|
161
|
+
}
|
162
|
+
#else
|
163
|
+
unsigned int i;
|
164
|
+
const UINT8 *curData = data;
|
165
|
+
for(i=0; i<laneCount; i++, curData+=8) {
|
166
|
+
UINT64 lane = (UINT64)curData[0]
|
167
|
+
| ((UINT64)curData[1] << 8)
|
168
|
+
| ((UINT64)curData[2] << 16)
|
169
|
+
| ((UINT64)curData[3] << 24)
|
170
|
+
| ((UINT64)curData[4] << 32)
|
171
|
+
| ((UINT64)curData[5] << 40)
|
172
|
+
| ((UINT64)curData[6] << 48)
|
173
|
+
| ((UINT64)curData[7] << 56);
|
174
|
+
((UINT64*)state)[i] ^= lane;
|
175
|
+
}
|
176
|
+
#endif
|
177
|
+
}
|
178
|
+
|
179
|
+
/* ---------------------------------------------------------------- */
|
180
|
+
|
181
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
182
|
+
void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset)
|
183
|
+
{
|
184
|
+
UINT64 lane = byte;
|
185
|
+
lane <<= (offset%8)*8;
|
186
|
+
((UINT64*)state)[offset/8] ^= lane;
|
187
|
+
}
|
188
|
+
#endif
|
189
|
+
|
190
|
+
/* ---------------------------------------------------------------- */
|
191
|
+
|
192
|
+
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
193
|
+
{
|
194
|
+
SnP_AddBytes(state, data, offset, length, KeccakP1600_AddLanes, KeccakP1600_AddBytesInLane, 8);
|
195
|
+
}
|
196
|
+
|
197
|
+
/* ---------------------------------------------------------------- */
|
198
|
+
|
199
|
+
void KeccakP1600_OverwriteBytesInLane(void *state, unsigned int lanePosition, const unsigned char *data, unsigned int offset, unsigned int length)
|
200
|
+
{
|
201
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
202
|
+
#ifdef KeccakP1600_useLaneComplementing
|
203
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20)) {
|
204
|
+
unsigned int i;
|
205
|
+
for(i=0; i<length; i++)
|
206
|
+
((unsigned char*)state)[lanePosition*8+offset+i] = ~data[i];
|
207
|
+
}
|
208
|
+
else
|
209
|
+
#endif
|
210
|
+
{
|
211
|
+
memcpy((unsigned char*)state+lanePosition*8+offset, data, length);
|
212
|
+
}
|
213
|
+
#else
|
214
|
+
UINT64 lane = ((UINT64*)state)[lanePosition];
|
215
|
+
unsigned int i;
|
216
|
+
for(i=0; i<length; i++) {
|
217
|
+
lane &= ~((UINT64)0xFF << ((offset+i)*8));
|
218
|
+
#ifdef KeccakP1600_useLaneComplementing
|
219
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
220
|
+
lane |= (UINT64)(data[i] ^ 0xFF) << ((offset+i)*8);
|
221
|
+
else
|
222
|
+
#endif
|
223
|
+
lane |= (UINT64)data[i] << ((offset+i)*8);
|
224
|
+
}
|
225
|
+
((UINT64*)state)[lanePosition] = lane;
|
226
|
+
#endif
|
227
|
+
}
|
228
|
+
|
229
|
+
/* ---------------------------------------------------------------- */
|
230
|
+
|
231
|
+
void KeccakP1600_OverwriteLanes(void *state, const unsigned char *data, unsigned int laneCount)
|
232
|
+
{
|
233
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
234
|
+
#ifdef KeccakP1600_useLaneComplementing
|
235
|
+
unsigned int lanePosition;
|
236
|
+
|
237
|
+
for(lanePosition=0; lanePosition<laneCount; lanePosition++)
|
238
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
239
|
+
((UINT64*)state)[lanePosition] = ~((const UINT64*)data)[lanePosition];
|
240
|
+
else
|
241
|
+
((UINT64*)state)[lanePosition] = ((const UINT64*)data)[lanePosition];
|
242
|
+
#else
|
243
|
+
memcpy(state, data, laneCount*8);
|
244
|
+
#endif
|
245
|
+
#else
|
246
|
+
unsigned int lanePosition;
|
247
|
+
const UINT8 *curData = data;
|
248
|
+
for(lanePosition=0; lanePosition<laneCount; lanePosition++, curData+=8) {
|
249
|
+
UINT64 lane = (UINT64)curData[0]
|
250
|
+
| ((UINT64)curData[1] << 8)
|
251
|
+
| ((UINT64)curData[2] << 16)
|
252
|
+
| ((UINT64)curData[3] << 24)
|
253
|
+
| ((UINT64)curData[4] << 32)
|
254
|
+
| ((UINT64)curData[5] << 40)
|
255
|
+
| ((UINT64)curData[6] << 48)
|
256
|
+
| ((UINT64)curData[7] << 56);
|
257
|
+
#ifdef KeccakP1600_useLaneComplementing
|
258
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
259
|
+
((UINT64*)state)[lanePosition] = ~lane;
|
260
|
+
else
|
261
|
+
#endif
|
262
|
+
((UINT64*)state)[lanePosition] = lane;
|
263
|
+
}
|
264
|
+
#endif
|
265
|
+
}
|
266
|
+
|
267
|
+
/* ---------------------------------------------------------------- */
|
268
|
+
|
269
|
+
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
270
|
+
{
|
271
|
+
SnP_OverwriteBytes(state, data, offset, length, KeccakP1600_OverwriteLanes, KeccakP1600_OverwriteBytesInLane, 8);
|
272
|
+
}
|
273
|
+
|
274
|
+
/* ---------------------------------------------------------------- */
|
275
|
+
|
276
|
+
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
|
277
|
+
{
|
278
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
279
|
+
#ifdef KeccakP1600_useLaneComplementing
|
280
|
+
unsigned int lanePosition;
|
281
|
+
|
282
|
+
for(lanePosition=0; lanePosition<byteCount/8; lanePosition++)
|
283
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
284
|
+
((UINT64*)state)[lanePosition] = ~0;
|
285
|
+
else
|
286
|
+
((UINT64*)state)[lanePosition] = 0;
|
287
|
+
if (byteCount%8 != 0) {
|
288
|
+
lanePosition = byteCount/8;
|
289
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
290
|
+
memset((unsigned char*)state+lanePosition*8, 0xFF, byteCount%8);
|
291
|
+
else
|
292
|
+
memset((unsigned char*)state+lanePosition*8, 0, byteCount%8);
|
293
|
+
}
|
294
|
+
#else
|
295
|
+
memset(state, 0, byteCount);
|
296
|
+
#endif
|
297
|
+
#else
|
298
|
+
unsigned int i, j;
|
299
|
+
for(i=0; i<byteCount; i+=8) {
|
300
|
+
unsigned int lanePosition = i/8;
|
301
|
+
if (i+8 <= byteCount) {
|
302
|
+
#ifdef KeccakP1600_useLaneComplementing
|
303
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
304
|
+
((UINT64*)state)[lanePosition] = ~(UINT64)0;
|
305
|
+
else
|
306
|
+
#endif
|
307
|
+
((UINT64*)state)[lanePosition] = 0;
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
UINT64 lane = ((UINT64*)state)[lanePosition];
|
311
|
+
for(j=0; j<byteCount%8; j++) {
|
312
|
+
#ifdef KeccakP1600_useLaneComplementing
|
313
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
314
|
+
lane |= (UINT64)0xFF << (j*8);
|
315
|
+
else
|
316
|
+
#endif
|
317
|
+
lane &= ~((UINT64)0xFF << (j*8));
|
318
|
+
}
|
319
|
+
((UINT64*)state)[lanePosition] = lane;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
#endif
|
323
|
+
}
|
324
|
+
|
325
|
+
/* ---------------------------------------------------------------- */
|
326
|
+
|
327
|
+
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nr)
|
328
|
+
{
|
329
|
+
declareABCDE
|
330
|
+
unsigned int i;
|
331
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
332
|
+
|
333
|
+
copyFromState(A, stateAsLanes)
|
334
|
+
roundsN(nr)
|
335
|
+
copyToState(stateAsLanes, A)
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
/* ---------------------------------------------------------------- */
|
340
|
+
|
341
|
+
void KeccakP1600_Permute_24rounds(void *state)
|
342
|
+
{
|
343
|
+
declareABCDE
|
344
|
+
#ifndef KeccakP1600_fullUnrolling
|
345
|
+
unsigned int i;
|
346
|
+
#endif
|
347
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
348
|
+
|
349
|
+
copyFromState(A, stateAsLanes)
|
350
|
+
rounds24
|
351
|
+
copyToState(stateAsLanes, A)
|
352
|
+
}
|
353
|
+
|
354
|
+
/* ---------------------------------------------------------------- */
|
355
|
+
|
356
|
+
void KeccakP1600_Permute_12rounds(void *state)
|
357
|
+
{
|
358
|
+
declareABCDE
|
359
|
+
#ifndef KeccakP1600_fullUnrolling
|
360
|
+
unsigned int i;
|
361
|
+
#endif
|
362
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
363
|
+
|
364
|
+
copyFromState(A, stateAsLanes)
|
365
|
+
rounds12
|
366
|
+
copyToState(stateAsLanes, A)
|
367
|
+
}
|
368
|
+
|
369
|
+
/* ---------------------------------------------------------------- */
|
370
|
+
|
371
|
+
void KeccakP1600_ExtractBytesInLane(const void *state, unsigned int lanePosition, unsigned char *data, unsigned int offset, unsigned int length)
|
372
|
+
{
|
373
|
+
UINT64 lane = ((UINT64*)state)[lanePosition];
|
374
|
+
#ifdef KeccakP1600_useLaneComplementing
|
375
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
376
|
+
lane = ~lane;
|
377
|
+
#endif
|
378
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
379
|
+
{
|
380
|
+
UINT64 lane1[1];
|
381
|
+
lane1[0] = lane;
|
382
|
+
memcpy(data, (UINT8*)lane1+offset, length);
|
383
|
+
}
|
384
|
+
#else
|
385
|
+
unsigned int i;
|
386
|
+
lane >>= offset*8;
|
387
|
+
for(i=0; i<length; i++) {
|
388
|
+
data[i] = lane & 0xFF;
|
389
|
+
lane >>= 8;
|
390
|
+
}
|
391
|
+
#endif
|
392
|
+
}
|
393
|
+
|
394
|
+
/* ---------------------------------------------------------------- */
|
395
|
+
|
396
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
397
|
+
void fromWordToBytes(UINT8 *bytes, const UINT64 word)
|
398
|
+
{
|
399
|
+
unsigned int i;
|
400
|
+
|
401
|
+
for(i=0; i<(64/8); i++)
|
402
|
+
bytes[i] = (word >> (8*i)) & 0xFF;
|
403
|
+
}
|
404
|
+
#endif
|
405
|
+
|
406
|
+
void KeccakP1600_ExtractLanes(const void *state, unsigned char *data, unsigned int laneCount)
|
407
|
+
{
|
408
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
409
|
+
memcpy(data, state, laneCount*8);
|
410
|
+
#else
|
411
|
+
unsigned int i;
|
412
|
+
|
413
|
+
for(i=0; i<laneCount; i++)
|
414
|
+
fromWordToBytes(data+(i*8), ((const UINT64*)state)[i]);
|
415
|
+
#endif
|
416
|
+
#ifdef KeccakP1600_useLaneComplementing
|
417
|
+
if (laneCount > 1) {
|
418
|
+
((UINT64*)data)[ 1] = ~((UINT64*)data)[ 1];
|
419
|
+
if (laneCount > 2) {
|
420
|
+
((UINT64*)data)[ 2] = ~((UINT64*)data)[ 2];
|
421
|
+
if (laneCount > 8) {
|
422
|
+
((UINT64*)data)[ 8] = ~((UINT64*)data)[ 8];
|
423
|
+
if (laneCount > 12) {
|
424
|
+
((UINT64*)data)[12] = ~((UINT64*)data)[12];
|
425
|
+
if (laneCount > 17) {
|
426
|
+
((UINT64*)data)[17] = ~((UINT64*)data)[17];
|
427
|
+
if (laneCount > 20) {
|
428
|
+
((UINT64*)data)[20] = ~((UINT64*)data)[20];
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
}
|
434
|
+
}
|
435
|
+
#endif
|
436
|
+
}
|
437
|
+
|
438
|
+
/* ---------------------------------------------------------------- */
|
439
|
+
|
440
|
+
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
|
441
|
+
{
|
442
|
+
SnP_ExtractBytes(state, data, offset, length, KeccakP1600_ExtractLanes, KeccakP1600_ExtractBytesInLane, 8);
|
443
|
+
}
|
444
|
+
|
445
|
+
/* ---------------------------------------------------------------- */
|
446
|
+
|
447
|
+
void KeccakP1600_ExtractAndAddBytesInLane(const void *state, unsigned int lanePosition, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
|
448
|
+
{
|
449
|
+
UINT64 lane = ((UINT64*)state)[lanePosition];
|
450
|
+
#ifdef KeccakP1600_useLaneComplementing
|
451
|
+
if ((lanePosition == 1) || (lanePosition == 2) || (lanePosition == 8) || (lanePosition == 12) || (lanePosition == 17) || (lanePosition == 20))
|
452
|
+
lane = ~lane;
|
453
|
+
#endif
|
454
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
455
|
+
{
|
456
|
+
unsigned int i;
|
457
|
+
UINT64 lane1[1];
|
458
|
+
lane1[0] = lane;
|
459
|
+
for(i=0; i<length; i++)
|
460
|
+
output[i] = input[i] ^ ((UINT8*)lane1)[offset+i];
|
461
|
+
}
|
462
|
+
#else
|
463
|
+
unsigned int i;
|
464
|
+
lane >>= offset*8;
|
465
|
+
for(i=0; i<length; i++) {
|
466
|
+
output[i] = input[i] ^ (lane & 0xFF);
|
467
|
+
lane >>= 8;
|
468
|
+
}
|
469
|
+
#endif
|
470
|
+
}
|
471
|
+
|
472
|
+
/* ---------------------------------------------------------------- */
|
473
|
+
|
474
|
+
void KeccakP1600_ExtractAndAddLanes(const void *state, const unsigned char *input, unsigned char *output, unsigned int laneCount)
|
475
|
+
{
|
476
|
+
unsigned int i;
|
477
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
478
|
+
unsigned char temp[8];
|
479
|
+
unsigned int j;
|
480
|
+
#endif
|
481
|
+
|
482
|
+
for(i=0; i<laneCount; i++) {
|
483
|
+
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
484
|
+
((UINT64*)output)[i] = ((UINT64*)input)[i] ^ ((const UINT64*)state)[i];
|
485
|
+
#else
|
486
|
+
fromWordToBytes(temp, ((const UINT64*)state)[i]);
|
487
|
+
for(j=0; j<8; j++)
|
488
|
+
output[i*8+j] = input[i*8+j] ^ temp[j];
|
489
|
+
#endif
|
490
|
+
}
|
491
|
+
#ifdef KeccakP1600_useLaneComplementing
|
492
|
+
if (laneCount > 1) {
|
493
|
+
((UINT64*)output)[ 1] = ~((UINT64*)output)[ 1];
|
494
|
+
if (laneCount > 2) {
|
495
|
+
((UINT64*)output)[ 2] = ~((UINT64*)output)[ 2];
|
496
|
+
if (laneCount > 8) {
|
497
|
+
((UINT64*)output)[ 8] = ~((UINT64*)output)[ 8];
|
498
|
+
if (laneCount > 12) {
|
499
|
+
((UINT64*)output)[12] = ~((UINT64*)output)[12];
|
500
|
+
if (laneCount > 17) {
|
501
|
+
((UINT64*)output)[17] = ~((UINT64*)output)[17];
|
502
|
+
if (laneCount > 20) {
|
503
|
+
((UINT64*)output)[20] = ~((UINT64*)output)[20];
|
504
|
+
}
|
505
|
+
}
|
506
|
+
}
|
507
|
+
}
|
508
|
+
}
|
509
|
+
}
|
510
|
+
#endif
|
511
|
+
}
|
512
|
+
|
513
|
+
/* ---------------------------------------------------------------- */
|
514
|
+
|
515
|
+
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
|
516
|
+
{
|
517
|
+
SnP_ExtractAndAddBytes(state, input, output, offset, length, KeccakP1600_ExtractAndAddLanes, KeccakP1600_ExtractAndAddBytesInLane, 8);
|
518
|
+
}
|
519
|
+
|
520
|
+
/* ---------------------------------------------------------------- */
|
521
|
+
|
522
|
+
size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
|
523
|
+
{
|
524
|
+
size_t originalDataByteLen = dataByteLen;
|
525
|
+
declareABCDE
|
526
|
+
#ifndef KeccakP1600_fullUnrolling
|
527
|
+
unsigned int i;
|
528
|
+
#endif
|
529
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
530
|
+
UINT64 *inDataAsLanes = (UINT64*)data;
|
531
|
+
|
532
|
+
copyFromState(A, stateAsLanes)
|
533
|
+
while(dataByteLen >= laneCount*8) {
|
534
|
+
addInput(A, inDataAsLanes, laneCount)
|
535
|
+
rounds24
|
536
|
+
inDataAsLanes += laneCount;
|
537
|
+
dataByteLen -= laneCount*8;
|
538
|
+
}
|
539
|
+
copyToState(stateAsLanes, A)
|
540
|
+
return originalDataByteLen - dataByteLen;
|
541
|
+
}
|