digest-kangarootwelve 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,621 @@
|
|
1
|
+
/*
|
2
|
+
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
3
|
+
|
4
|
+
For more information, feedback or questions, please refer to our website:
|
5
|
+
https://keccak.team/
|
6
|
+
|
7
|
+
To the extent possible under law, the implementer has waived all copyright
|
8
|
+
and related or neighboring rights to the source code in this file.
|
9
|
+
http://creativecommons.org/publicdomain/zero/1.0/
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
This file implements Keccak-p[1600] in a SnP-compatible way.
|
14
|
+
Please refer to SnP-documentation.h for more details.
|
15
|
+
|
16
|
+
This implementation comes with KeccakP-1600-SnP.h in the same folder.
|
17
|
+
Please refer to LowLevel.build for the exact list of other files it must be combined with.
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
We would like to thank Vladimir Sedach, we have used parts of his Keccak AVX-512 C++ code.
|
22
|
+
*/
|
23
|
+
|
24
|
+
#include <stdio.h>
|
25
|
+
#include <stdlib.h>
|
26
|
+
#include <string.h>
|
27
|
+
#include <stdint.h>
|
28
|
+
#include <smmintrin.h>
|
29
|
+
#include <wmmintrin.h>
|
30
|
+
#include <immintrin.h>
|
31
|
+
#include <emmintrin.h>
|
32
|
+
#include "align.h"
|
33
|
+
#include "brg_endian.h"
|
34
|
+
#include "KeccakP-1600-AVX512-config.h"
|
35
|
+
|
36
|
+
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
37
|
+
#error Expecting a little-endian platform
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#ifdef KeccakP1600_fullUnrolling
|
41
|
+
#define FullUnrolling
|
42
|
+
#else
|
43
|
+
#define Unrolling KeccakP1600_unrolling
|
44
|
+
#endif
|
45
|
+
|
46
|
+
/* Comment the define hereunder when compiling for a CPU with AVX-512 SIMD */
|
47
|
+
/*
|
48
|
+
* Warning: This code has only been tested on Haswell (AVX2) with SIMULATE_AVX512 defined,
|
49
|
+
* errors will occur if we did a bad interpretation of the AVX-512 intrinsics'
|
50
|
+
* API or functionality.
|
51
|
+
*/
|
52
|
+
/* #define SIMULATE_AVX512 */
|
53
|
+
|
54
|
+
typedef uint8_t UINT8;
|
55
|
+
typedef uint64_t UINT64;
|
56
|
+
|
57
|
+
#if defined(SIMULATE_AVX512)
|
58
|
+
|
59
|
+
typedef struct
|
60
|
+
{
|
61
|
+
UINT64 x[8];
|
62
|
+
} __m512i;
|
63
|
+
|
64
|
+
static __m512i _mm512_xor_si512( __m512i a, __m512i b)
|
65
|
+
{
|
66
|
+
__m512i r;
|
67
|
+
unsigned int i;
|
68
|
+
|
69
|
+
for ( i = 0; i < 8; ++i )
|
70
|
+
r.x[i] = a.x[i] ^ b.x[i];
|
71
|
+
return(r);
|
72
|
+
}
|
73
|
+
|
74
|
+
static __m512i _mm512_ternarylogic_epi64(__m512i a, __m512i b, __m512i c, int imm)
|
75
|
+
{
|
76
|
+
|
77
|
+
if (imm == 0x96)
|
78
|
+
return ( _mm512_xor_si512( _mm512_xor_si512( a, b ), c ) );
|
79
|
+
if (imm == 0xD2) {
|
80
|
+
__m512i t;
|
81
|
+
unsigned int i;
|
82
|
+
|
83
|
+
for ( i = 0; i < 8; ++i )
|
84
|
+
t.x[i] = ~b.x[i] & c.x[i];
|
85
|
+
return ( _mm512_xor_si512( a, t ) );
|
86
|
+
}
|
87
|
+
printf( "_mm512_ternarylogic_epi64( a, b, c, %02X) not implemented!\n", imm );
|
88
|
+
exit(1);
|
89
|
+
|
90
|
+
}
|
91
|
+
|
92
|
+
static __m512i _mm512_rol_epi64(__m512i a, int offset)
|
93
|
+
{
|
94
|
+
__m512i r;
|
95
|
+
unsigned int i;
|
96
|
+
|
97
|
+
for ( i = 0; i < 8; ++i )
|
98
|
+
r.x[i] = (a.x[i] << offset) | (a.x[i] >> (64-offset));
|
99
|
+
return(r);
|
100
|
+
}
|
101
|
+
|
102
|
+
static __m512i _mm512_rolv_epi64(__m512i a, __m512i offset)
|
103
|
+
{
|
104
|
+
__m512i r;
|
105
|
+
unsigned int i;
|
106
|
+
|
107
|
+
for ( i = 0; i < 8; ++i )
|
108
|
+
r.x[i] = (a.x[i] << offset.x[i]) | (a.x[i] >> (64-offset.x[i]));
|
109
|
+
return(r);
|
110
|
+
}
|
111
|
+
|
112
|
+
static __m512i _mm512_setr_epi64(UINT64 a, UINT64 b, UINT64 c, UINT64 d, UINT64 e, UINT64 f, UINT64 g, UINT64 h)
|
113
|
+
{
|
114
|
+
__m512i r;
|
115
|
+
|
116
|
+
r.x[0] = a;
|
117
|
+
r.x[1] = b;
|
118
|
+
r.x[2] = c;
|
119
|
+
r.x[3] = d;
|
120
|
+
r.x[4] = e;
|
121
|
+
r.x[5] = f;
|
122
|
+
r.x[6] = g;
|
123
|
+
r.x[7] = h;
|
124
|
+
return(r);
|
125
|
+
}
|
126
|
+
|
127
|
+
static __m512i _mm512_permutexvar_epi64(__m512i idx, __m512i v)
|
128
|
+
{
|
129
|
+
__m512i r;
|
130
|
+
unsigned int i;
|
131
|
+
|
132
|
+
for ( i = 0; i < 8; ++i )
|
133
|
+
r.x[i] = v.x[idx.x[i]];
|
134
|
+
return(r);
|
135
|
+
}
|
136
|
+
|
137
|
+
static __m512i _mm512_permutex2var_epi64(__m512i a, __m512i idx, __m512i b)
|
138
|
+
{
|
139
|
+
__m512i r;
|
140
|
+
unsigned int i;
|
141
|
+
unsigned int index;
|
142
|
+
|
143
|
+
for ( i = 0; i < 8; ++i ) {
|
144
|
+
index = idx.x[i] & 7;
|
145
|
+
r.x[i] = (idx.x[i] & 8) ? b.x[index] : a.x[index];
|
146
|
+
}
|
147
|
+
return(r);
|
148
|
+
}
|
149
|
+
|
150
|
+
static __m512i _mm512_unpacklo_epi64(__m512i a, __m512i b)
|
151
|
+
{
|
152
|
+
__m512i r;
|
153
|
+
unsigned int i;
|
154
|
+
|
155
|
+
for ( i = 0; i < 8; i += 2 ) {
|
156
|
+
r.x[i] = a.x[i];
|
157
|
+
r.x[i+1] = b.x[i];
|
158
|
+
}
|
159
|
+
return(r);
|
160
|
+
}
|
161
|
+
|
162
|
+
static __m512i _mm512_unpackhi_epi64(__m512i a, __m512i b)
|
163
|
+
{
|
164
|
+
__m512i r;
|
165
|
+
unsigned int i;
|
166
|
+
|
167
|
+
for ( i = 0; i < 8; i += 2 ) {
|
168
|
+
r.x[i] = a.x[i+1];
|
169
|
+
r.x[i+1] = b.x[i+1];
|
170
|
+
}
|
171
|
+
return(r);
|
172
|
+
}
|
173
|
+
|
174
|
+
static __m512i _mm512_mask_blend_epi64(unsigned char mask, __m512i a, __m512i b)
|
175
|
+
{
|
176
|
+
__m512i r;
|
177
|
+
unsigned int i;
|
178
|
+
|
179
|
+
for ( i = 0; i < 8; ++i, mask >>= 1 )
|
180
|
+
r.x[i] = (mask & 1) ? b.x[i] : a.x[i];
|
181
|
+
return(r);
|
182
|
+
}
|
183
|
+
|
184
|
+
static __m512i _mm512_maskz_loadu_epi64( unsigned char mask, const void * a)
|
185
|
+
{
|
186
|
+
__m512i r;
|
187
|
+
unsigned int i;
|
188
|
+
const UINT64 *p = a;
|
189
|
+
|
190
|
+
for ( i = 0; i < 8; ++i, mask >>= 1 )
|
191
|
+
r.x[i] = (mask & 1) ? p[i] : 0;
|
192
|
+
return(r);
|
193
|
+
}
|
194
|
+
|
195
|
+
static void _mm512_mask_storeu_epi64( void * a, unsigned char mask, __m512i v)
|
196
|
+
{
|
197
|
+
unsigned int i;
|
198
|
+
UINT64 *p = a;
|
199
|
+
|
200
|
+
for ( i = 0; i < 8; ++i, mask >>= 1 )
|
201
|
+
if ( mask & 1 )
|
202
|
+
p[i] = v.x[i];
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
#endif
|
207
|
+
|
208
|
+
typedef __m512i V512;
|
209
|
+
|
210
|
+
#define XOR(a,b) _mm512_xor_si512(a,b)
|
211
|
+
#define XOR3(a,b,c) _mm512_ternarylogic_epi64(a,b,c,0x96)
|
212
|
+
#define XOR5(a,b,c,d,e) XOR3(XOR3(a,b,c),d,e)
|
213
|
+
#define ROL(a,offset) _mm512_rol_epi64(a,offset)
|
214
|
+
#define Chi(a,b,c) _mm512_ternarylogic_epi64(a,b,c,0xD2)
|
215
|
+
|
216
|
+
#define LOAD_Lanes(m,a) _mm512_maskz_loadu_epi64(m,a)
|
217
|
+
#define LOAD_Lane(a) LOAD_Lanes(0x01,a)
|
218
|
+
#define LOAD_Plane(a) LOAD_Lanes(0x1F,a)
|
219
|
+
#define LOAD_8Lanes(a) LOAD_Lanes(0xFF,a)
|
220
|
+
#define STORE_Lanes(a,m,v) _mm512_mask_storeu_epi64(a,m,v)
|
221
|
+
#define STORE_Lane(a,v) STORE_Lanes(a,0x01,v)
|
222
|
+
#define STORE_Plane(a,v) STORE_Lanes(a,0x1F,v)
|
223
|
+
#define STORE_8Lanes(a,v) STORE_Lanes(a,0xFF,v)
|
224
|
+
|
225
|
+
/* ---------------------------------------------------------------- */
|
226
|
+
|
227
|
+
void KeccakP1600_Initialize(void *state)
|
228
|
+
{
|
229
|
+
memset(state, 0, 1600/8);
|
230
|
+
}
|
231
|
+
|
232
|
+
/* ---------------------------------------------------------------- */
|
233
|
+
|
234
|
+
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
235
|
+
{
|
236
|
+
UINT8 *stateAsBytes;
|
237
|
+
UINT64 *stateAsLanes;
|
238
|
+
|
239
|
+
for( stateAsBytes = (UINT8*)state; ((offset % 8) != 0) && (length != 0); ++offset, --length)
|
240
|
+
stateAsBytes[offset] ^= *(data++);
|
241
|
+
for (stateAsLanes = (UINT64*)(stateAsBytes + offset); length >= 8*8; stateAsLanes += 8, data += 8*8, length -= 8*8)
|
242
|
+
STORE_8Lanes( stateAsLanes, XOR(LOAD_8Lanes(stateAsLanes), LOAD_8Lanes((const UINT64*)data)));
|
243
|
+
for (/* empty */; length >= 8; ++stateAsLanes, data += 8, length -= 8)
|
244
|
+
STORE_Lane( stateAsLanes, XOR(LOAD_Lane(stateAsLanes), LOAD_Lane((const UINT64*)data)));
|
245
|
+
for ( stateAsBytes = (UINT8*)stateAsLanes; length != 0; --length)
|
246
|
+
*(stateAsBytes++) ^= *(data++);
|
247
|
+
}
|
248
|
+
|
249
|
+
/* ---------------------------------------------------------------- */
|
250
|
+
|
251
|
+
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
252
|
+
{
|
253
|
+
memcpy((unsigned char*)state+offset, data, length);
|
254
|
+
}
|
255
|
+
|
256
|
+
/* ---------------------------------------------------------------- */
|
257
|
+
|
258
|
+
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
|
259
|
+
{
|
260
|
+
memset(state, 0, byteCount);
|
261
|
+
}
|
262
|
+
|
263
|
+
/* ---------------------------------------------------------------- */
|
264
|
+
|
265
|
+
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
|
266
|
+
{
|
267
|
+
memcpy(data, (unsigned char*)state+offset, length);
|
268
|
+
}
|
269
|
+
|
270
|
+
/* ---------------------------------------------------------------- */
|
271
|
+
|
272
|
+
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
|
273
|
+
{
|
274
|
+
UINT8 *stateAsBytes;
|
275
|
+
UINT64 *stateAsLanes;
|
276
|
+
|
277
|
+
for( stateAsBytes = (UINT8*)state; ((offset % 8) != 0) && (length != 0); ++offset, --length)
|
278
|
+
*(output++) = stateAsBytes[offset] ^ *(input++);
|
279
|
+
for (stateAsLanes = (UINT64*)(stateAsBytes + offset); length >= 8*8; stateAsLanes += 8, input += 8*8, output += 8*8, length -= 8*8)
|
280
|
+
STORE_8Lanes( (UINT64*)output, XOR(LOAD_8Lanes(stateAsLanes), LOAD_8Lanes((const UINT64*)input)));
|
281
|
+
for (/* empty */; length >= 8; ++stateAsLanes, input += 8, output += 8, length -= 8)
|
282
|
+
STORE_Lane( (UINT64*)output, XOR(LOAD_Lane(stateAsLanes), LOAD_Lane((const UINT64*)input)));
|
283
|
+
for ( stateAsBytes = (UINT8*)stateAsLanes; length != 0; --length)
|
284
|
+
*(output++) = *(stateAsBytes++) ^ *(input++);
|
285
|
+
}
|
286
|
+
|
287
|
+
const UINT64 KeccakP1600RoundConstants[24] = {
|
288
|
+
0x0000000000000001ULL,
|
289
|
+
0x0000000000008082ULL,
|
290
|
+
0x800000000000808aULL,
|
291
|
+
0x8000000080008000ULL,
|
292
|
+
0x000000000000808bULL,
|
293
|
+
0x0000000080000001ULL,
|
294
|
+
0x8000000080008081ULL,
|
295
|
+
0x8000000000008009ULL,
|
296
|
+
0x000000000000008aULL,
|
297
|
+
0x0000000000000088ULL,
|
298
|
+
0x0000000080008009ULL,
|
299
|
+
0x000000008000000aULL,
|
300
|
+
0x000000008000808bULL,
|
301
|
+
0x800000000000008bULL,
|
302
|
+
0x8000000000008089ULL,
|
303
|
+
0x8000000000008003ULL,
|
304
|
+
0x8000000000008002ULL,
|
305
|
+
0x8000000000000080ULL,
|
306
|
+
0x000000000000800aULL,
|
307
|
+
0x800000008000000aULL,
|
308
|
+
0x8000000080008081ULL,
|
309
|
+
0x8000000000008080ULL,
|
310
|
+
0x0000000080000001ULL,
|
311
|
+
0x8000000080008008ULL };
|
312
|
+
|
313
|
+
#define KeccakP_DeclareVars \
|
314
|
+
V512 b0, b1, b2, b3, b4; \
|
315
|
+
V512 Baeiou, Gaeiou, Kaeiou, Maeiou, Saeiou; \
|
316
|
+
V512 moveThetaPrev = _mm512_setr_epi64(4, 0, 1, 2, 3, 5, 6, 7); \
|
317
|
+
V512 moveThetaNext = _mm512_setr_epi64(1, 2, 3, 4, 0, 5, 6, 7); \
|
318
|
+
V512 rhoB = _mm512_setr_epi64( 0, 1, 62, 28, 27, 0, 0, 0); \
|
319
|
+
V512 rhoG = _mm512_setr_epi64(36, 44, 6, 55, 20, 0, 0, 0); \
|
320
|
+
V512 rhoK = _mm512_setr_epi64( 3, 10, 43, 25, 39, 0, 0, 0); \
|
321
|
+
V512 rhoM = _mm512_setr_epi64(41, 45, 15, 21, 8, 0, 0, 0); \
|
322
|
+
V512 rhoS = _mm512_setr_epi64(18, 2, 61, 56, 14, 0, 0, 0); \
|
323
|
+
V512 pi1B = _mm512_setr_epi64(0, 3, 1, 4, 2, 5, 6, 7); \
|
324
|
+
V512 pi1G = _mm512_setr_epi64(1, 4, 2, 0, 3, 5, 6, 7); \
|
325
|
+
V512 pi1K = _mm512_setr_epi64(2, 0, 3, 1, 4, 5, 6, 7); \
|
326
|
+
V512 pi1M = _mm512_setr_epi64(3, 1, 4, 2, 0, 5, 6, 7); \
|
327
|
+
V512 pi1S = _mm512_setr_epi64(4, 2, 0, 3, 1, 5, 6, 7); \
|
328
|
+
V512 pi2S1 = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 0+8, 2+8); \
|
329
|
+
V512 pi2S2 = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 1+8, 3+8); \
|
330
|
+
V512 pi2BG = _mm512_setr_epi64(0, 1, 0+8, 1+8, 6, 5, 6, 7); \
|
331
|
+
V512 pi2KM = _mm512_setr_epi64(2, 3, 2+8, 3+8, 7, 5, 6, 7); \
|
332
|
+
V512 pi2S3 = _mm512_setr_epi64(4, 5, 4+8, 5+8, 4, 5, 6, 7);
|
333
|
+
|
334
|
+
#define copyFromState(pState) \
|
335
|
+
Baeiou = LOAD_Plane(pState+ 0); \
|
336
|
+
Gaeiou = LOAD_Plane(pState+ 5); \
|
337
|
+
Kaeiou = LOAD_Plane(pState+10); \
|
338
|
+
Maeiou = LOAD_Plane(pState+15); \
|
339
|
+
Saeiou = LOAD_Plane(pState+20);
|
340
|
+
|
341
|
+
#define copyToState(pState) \
|
342
|
+
STORE_Plane(pState+ 0, Baeiou); \
|
343
|
+
STORE_Plane(pState+ 5, Gaeiou); \
|
344
|
+
STORE_Plane(pState+10, Kaeiou); \
|
345
|
+
STORE_Plane(pState+15, Maeiou); \
|
346
|
+
STORE_Plane(pState+20, Saeiou);
|
347
|
+
|
348
|
+
#define KeccakP_Round(i) \
|
349
|
+
/* Theta */ \
|
350
|
+
b0 = XOR5( Baeiou, Gaeiou, Kaeiou, Maeiou, Saeiou ); \
|
351
|
+
b1 = _mm512_permutexvar_epi64(moveThetaPrev, b0); \
|
352
|
+
b0 = _mm512_permutexvar_epi64(moveThetaNext, b0); \
|
353
|
+
b0 = _mm512_rol_epi64(b0, 1); \
|
354
|
+
Baeiou = XOR3( Baeiou, b0, b1 ); \
|
355
|
+
Gaeiou = XOR3( Gaeiou, b0, b1 ); \
|
356
|
+
Kaeiou = XOR3( Kaeiou, b0, b1 ); \
|
357
|
+
Maeiou = XOR3( Maeiou, b0, b1 ); \
|
358
|
+
Saeiou = XOR3( Saeiou, b0, b1 ); \
|
359
|
+
/* Rho */ \
|
360
|
+
Baeiou = _mm512_rolv_epi64(Baeiou, rhoB); \
|
361
|
+
Gaeiou = _mm512_rolv_epi64(Gaeiou, rhoG); \
|
362
|
+
Kaeiou = _mm512_rolv_epi64(Kaeiou, rhoK); \
|
363
|
+
Maeiou = _mm512_rolv_epi64(Maeiou, rhoM); \
|
364
|
+
Saeiou = _mm512_rolv_epi64(Saeiou, rhoS); \
|
365
|
+
/* Pi 1 */ \
|
366
|
+
b0 = _mm512_permutexvar_epi64(pi1B, Baeiou); \
|
367
|
+
b1 = _mm512_permutexvar_epi64(pi1G, Gaeiou); \
|
368
|
+
b2 = _mm512_permutexvar_epi64(pi1K, Kaeiou); \
|
369
|
+
b3 = _mm512_permutexvar_epi64(pi1M, Maeiou); \
|
370
|
+
b4 = _mm512_permutexvar_epi64(pi1S, Saeiou); \
|
371
|
+
/* Chi */ \
|
372
|
+
Baeiou = Chi(b0, b1, b2); \
|
373
|
+
Gaeiou = Chi(b1, b2, b3); \
|
374
|
+
Kaeiou = Chi(b2, b3, b4); \
|
375
|
+
Maeiou = Chi(b3, b4, b0); \
|
376
|
+
Saeiou = Chi(b4, b0, b1); \
|
377
|
+
/* Iota */ \
|
378
|
+
Baeiou = XOR(Baeiou, LOAD_Lane(KeccakP1600RoundConstants+i)); \
|
379
|
+
/* Pi 2 */ \
|
380
|
+
b0 = _mm512_unpacklo_epi64(Baeiou, Gaeiou); \
|
381
|
+
b1 = _mm512_unpacklo_epi64(Kaeiou, Maeiou); \
|
382
|
+
b0 = _mm512_permutex2var_epi64(b0, pi2S1, Saeiou); \
|
383
|
+
b2 = _mm512_unpackhi_epi64(Baeiou, Gaeiou); \
|
384
|
+
b3 = _mm512_unpackhi_epi64(Kaeiou, Maeiou); \
|
385
|
+
b2 = _mm512_permutex2var_epi64(b2, pi2S2, Saeiou); \
|
386
|
+
Baeiou = _mm512_permutex2var_epi64(b0, pi2BG, b1); \
|
387
|
+
Gaeiou = _mm512_permutex2var_epi64(b2, pi2BG, b3); \
|
388
|
+
Kaeiou = _mm512_permutex2var_epi64(b0, pi2KM, b1); \
|
389
|
+
Maeiou = _mm512_permutex2var_epi64(b2, pi2KM, b3); \
|
390
|
+
b0 = _mm512_permutex2var_epi64(b0, pi2S3, b1); \
|
391
|
+
Saeiou = _mm512_mask_blend_epi64(0x10, b0, Saeiou)
|
392
|
+
|
393
|
+
#ifdef FullUnrolling
|
394
|
+
|
395
|
+
#define rounds12 \
|
396
|
+
KeccakP_Round( 12 ); \
|
397
|
+
KeccakP_Round( 13 ); \
|
398
|
+
KeccakP_Round( 14 ); \
|
399
|
+
KeccakP_Round( 15 ); \
|
400
|
+
KeccakP_Round( 16 ); \
|
401
|
+
KeccakP_Round( 17 ); \
|
402
|
+
KeccakP_Round( 18 ); \
|
403
|
+
KeccakP_Round( 19 ); \
|
404
|
+
KeccakP_Round( 20 ); \
|
405
|
+
KeccakP_Round( 21 ); \
|
406
|
+
KeccakP_Round( 22 ); \
|
407
|
+
KeccakP_Round( 23 )
|
408
|
+
|
409
|
+
#define rounds24 \
|
410
|
+
KeccakP_Round( 0 ); \
|
411
|
+
KeccakP_Round( 1 ); \
|
412
|
+
KeccakP_Round( 2 ); \
|
413
|
+
KeccakP_Round( 3 ); \
|
414
|
+
KeccakP_Round( 4 ); \
|
415
|
+
KeccakP_Round( 5 ); \
|
416
|
+
KeccakP_Round( 6 ); \
|
417
|
+
KeccakP_Round( 7 ); \
|
418
|
+
KeccakP_Round( 8 ); \
|
419
|
+
KeccakP_Round( 9 ); \
|
420
|
+
KeccakP_Round( 10 ); \
|
421
|
+
KeccakP_Round( 11 ); \
|
422
|
+
KeccakP_Round( 12 ); \
|
423
|
+
KeccakP_Round( 13 ); \
|
424
|
+
KeccakP_Round( 14 ); \
|
425
|
+
KeccakP_Round( 15 ); \
|
426
|
+
KeccakP_Round( 16 ); \
|
427
|
+
KeccakP_Round( 17 ); \
|
428
|
+
KeccakP_Round( 18 ); \
|
429
|
+
KeccakP_Round( 19 ); \
|
430
|
+
KeccakP_Round( 20 ); \
|
431
|
+
KeccakP_Round( 21 ); \
|
432
|
+
KeccakP_Round( 22 ); \
|
433
|
+
KeccakP_Round( 23 )
|
434
|
+
|
435
|
+
#elif (Unrolling == 6)
|
436
|
+
|
437
|
+
#define rounds12 \
|
438
|
+
i = 12; \
|
439
|
+
do { \
|
440
|
+
KeccakP_Round( i+ 0 ); \
|
441
|
+
KeccakP_Round( i+ 1 ); \
|
442
|
+
KeccakP_Round( i+ 2 ); \
|
443
|
+
KeccakP_Round( i+ 3 ); \
|
444
|
+
KeccakP_Round( i+ 4 ); \
|
445
|
+
KeccakP_Round( i+ 5 ); \
|
446
|
+
} while( (i += 6) < 24 )
|
447
|
+
|
448
|
+
#define rounds24 \
|
449
|
+
i = 0; \
|
450
|
+
do { \
|
451
|
+
KeccakP_Round( i+ 0 ); \
|
452
|
+
KeccakP_Round( i+ 1 ); \
|
453
|
+
KeccakP_Round( i+ 2 ); \
|
454
|
+
KeccakP_Round( i+ 3 ); \
|
455
|
+
KeccakP_Round( i+ 4 ); \
|
456
|
+
KeccakP_Round( i+ 5 ); \
|
457
|
+
} while( (i += 6) < 24 )
|
458
|
+
|
459
|
+
#elif (Unrolling == 12)
|
460
|
+
|
461
|
+
#define rounds12 \
|
462
|
+
KeccakP_Round( 12 ); \
|
463
|
+
KeccakP_Round( 13 ); \
|
464
|
+
KeccakP_Round( 14 ); \
|
465
|
+
KeccakP_Round( 15 ); \
|
466
|
+
KeccakP_Round( 16 ); \
|
467
|
+
KeccakP_Round( 17 ); \
|
468
|
+
KeccakP_Round( 18 ); \
|
469
|
+
KeccakP_Round( 19 ); \
|
470
|
+
KeccakP_Round( 20 ); \
|
471
|
+
KeccakP_Round( 21 ); \
|
472
|
+
KeccakP_Round( 22 ); \
|
473
|
+
KeccakP_Round( 23 )
|
474
|
+
|
475
|
+
#define rounds24 \
|
476
|
+
i = 0; \
|
477
|
+
do { \
|
478
|
+
KeccakP_Round( i+ 0 ); \
|
479
|
+
KeccakP_Round( i+ 1 ); \
|
480
|
+
KeccakP_Round( i+ 2 ); \
|
481
|
+
KeccakP_Round( i+ 3 ); \
|
482
|
+
KeccakP_Round( i+ 4 ); \
|
483
|
+
KeccakP_Round( i+ 5 ); \
|
484
|
+
KeccakP_Round( i+ 6 ); \
|
485
|
+
KeccakP_Round( i+ 7 ); \
|
486
|
+
KeccakP_Round( i+ 8 ); \
|
487
|
+
KeccakP_Round( i+ 9 ); \
|
488
|
+
KeccakP_Round( i+10 ); \
|
489
|
+
KeccakP_Round( i+11 ); \
|
490
|
+
} while( (i += 12) < 24 )
|
491
|
+
|
492
|
+
#else
|
493
|
+
#error "Unrolling is not correctly specified!"
|
494
|
+
#endif
|
495
|
+
|
496
|
+
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds)
|
497
|
+
{
|
498
|
+
KeccakP_DeclareVars
|
499
|
+
unsigned int i;
|
500
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
501
|
+
|
502
|
+
copyFromState(stateAsLanes);
|
503
|
+
if ((nrounds & 1) != 0) {
|
504
|
+
KeccakP_Round( 24-nrounds );
|
505
|
+
--nrounds;
|
506
|
+
}
|
507
|
+
if ((nrounds & 2) != 0) {
|
508
|
+
KeccakP_Round( 24+0-nrounds );
|
509
|
+
KeccakP_Round( 24+1-nrounds );
|
510
|
+
nrounds -= 2;
|
511
|
+
}
|
512
|
+
for (i = 24-nrounds; i < 24; i+= 4) {
|
513
|
+
KeccakP_Round( i );
|
514
|
+
KeccakP_Round( i+1 );
|
515
|
+
KeccakP_Round( i+2 );
|
516
|
+
KeccakP_Round( i+3 );
|
517
|
+
}
|
518
|
+
copyToState(stateAsLanes);
|
519
|
+
}
|
520
|
+
|
521
|
+
/* ---------------------------------------------------------------- */
|
522
|
+
|
523
|
+
void KeccakP1600_Permute_12rounds(void *state)
|
524
|
+
{
|
525
|
+
KeccakP_DeclareVars
|
526
|
+
#ifndef KeccakP1600_fullUnrolling
|
527
|
+
unsigned int i;
|
528
|
+
#endif
|
529
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
530
|
+
|
531
|
+
copyFromState(stateAsLanes);
|
532
|
+
rounds12;
|
533
|
+
copyToState(stateAsLanes);
|
534
|
+
}
|
535
|
+
|
536
|
+
/* ---------------------------------------------------------------- */
|
537
|
+
|
538
|
+
void KeccakP1600_Permute_24rounds(void *state)
|
539
|
+
{
|
540
|
+
KeccakP_DeclareVars
|
541
|
+
#ifndef KeccakP1600_fullUnrolling
|
542
|
+
unsigned int i;
|
543
|
+
#endif
|
544
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
545
|
+
|
546
|
+
copyFromState(stateAsLanes);
|
547
|
+
rounds24;
|
548
|
+
copyToState(stateAsLanes);
|
549
|
+
}
|
550
|
+
|
551
|
+
size_t KeccakF1600_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
|
552
|
+
{
|
553
|
+
size_t originalDataByteLen = dataByteLen;
|
554
|
+
|
555
|
+
if (laneCount == 21) {
|
556
|
+
KeccakP_DeclareVars;
|
557
|
+
#ifndef KeccakP1600_fullUnrolling
|
558
|
+
unsigned int i;
|
559
|
+
#endif
|
560
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
561
|
+
UINT64 *inDataAsLanes = (UINT64*)data;
|
562
|
+
|
563
|
+
copyFromState(stateAsLanes);
|
564
|
+
while(dataByteLen >= 21*8) {
|
565
|
+
Baeiou = XOR(Baeiou, LOAD_Plane(inDataAsLanes+ 0));
|
566
|
+
Gaeiou = XOR(Gaeiou, LOAD_Plane(inDataAsLanes+ 5));
|
567
|
+
Kaeiou = XOR(Kaeiou, LOAD_Plane(inDataAsLanes+10));
|
568
|
+
Maeiou = XOR(Maeiou, LOAD_Plane(inDataAsLanes+15));
|
569
|
+
Saeiou = XOR(Saeiou, LOAD_Lane(inDataAsLanes+20));
|
570
|
+
rounds24;
|
571
|
+
inDataAsLanes += 21;
|
572
|
+
dataByteLen -= 21*8;
|
573
|
+
}
|
574
|
+
copyToState(stateAsLanes);
|
575
|
+
}
|
576
|
+
else {
|
577
|
+
while(dataByteLen >= laneCount*8) {
|
578
|
+
KeccakP1600_AddBytes(state, data, 0, laneCount*8);
|
579
|
+
KeccakP1600_Permute_24rounds(state);
|
580
|
+
data += laneCount*8;
|
581
|
+
dataByteLen -= laneCount*8;
|
582
|
+
}
|
583
|
+
}
|
584
|
+
return originalDataByteLen - dataByteLen;
|
585
|
+
}
|
586
|
+
|
587
|
+
size_t KeccakP1600_12rounds_FastLoop_Absorb(void *state, unsigned int laneCount, const unsigned char *data, size_t dataByteLen)
|
588
|
+
{
|
589
|
+
size_t originalDataByteLen = dataByteLen;
|
590
|
+
|
591
|
+
if (laneCount == 21) {
|
592
|
+
KeccakP_DeclareVars;
|
593
|
+
#if !defined(KeccakP1600_fullUnrolling) && (KeccakP1600_unrolling < 12)
|
594
|
+
unsigned int i;
|
595
|
+
#endif
|
596
|
+
UINT64 *stateAsLanes = (UINT64*)state;
|
597
|
+
UINT64 *inDataAsLanes = (UINT64*)data;
|
598
|
+
|
599
|
+
copyFromState(stateAsLanes);
|
600
|
+
while(dataByteLen >= 21*8) {
|
601
|
+
Baeiou = XOR(Baeiou, LOAD_Plane(inDataAsLanes+ 0));
|
602
|
+
Gaeiou = XOR(Gaeiou, LOAD_Plane(inDataAsLanes+ 5));
|
603
|
+
Kaeiou = XOR(Kaeiou, LOAD_Plane(inDataAsLanes+10));
|
604
|
+
Maeiou = XOR(Maeiou, LOAD_Plane(inDataAsLanes+15));
|
605
|
+
Saeiou = XOR(Saeiou, LOAD_Lane(inDataAsLanes+20));
|
606
|
+
rounds12;
|
607
|
+
inDataAsLanes += 21;
|
608
|
+
dataByteLen -= 21*8;
|
609
|
+
}
|
610
|
+
copyToState(stateAsLanes);
|
611
|
+
}
|
612
|
+
else {
|
613
|
+
while(dataByteLen >= laneCount*8) {
|
614
|
+
KeccakP1600_AddBytes(state, data, 0, laneCount*8);
|
615
|
+
KeccakP1600_Permute_24rounds(state);
|
616
|
+
data += laneCount*8;
|
617
|
+
dataByteLen -= laneCount*8;
|
618
|
+
}
|
619
|
+
}
|
620
|
+
return originalDataByteLen - dataByteLen;
|
621
|
+
}
|