sha3-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact.vcproj +207 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakCompact8.vcproj +207 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace.vcproj +203 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakInplace32BI.vcproj +201 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized32.vcproj +267 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakOptimized64.vcproj +267 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference.vcproj +243 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReference32BI.vcproj +243 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakReferenceAndOptimized.sln +62 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple.vcproj +203 -0
- data/ext/sha3/KeccakReferenceAndOptimized/KeccakSimple32BI.vcproj +201 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.h +27 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/AVR8-rotate64.s +285 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-settings.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-test.c +142 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.h +15 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8-util.s +119 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.c +184 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-avr8.h +25 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact-test.c +317 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.c +341 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact.h +50 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-settings.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8-test.c +192 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.c +375 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-compact8.h +47 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +406 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-minimal-test.c +231 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace-test.c +221 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace.c +445 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv6M.s +844 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7A.s +687 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI-armgcc-ARMv7M.s +687 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-inplace32BI.c +849 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-settings.h +3 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple-test.c +221 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple.c +403 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccak-simple32BI.c +673 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.c +68 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakDuplex.h +59 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-rvk.macros +555 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s1.macros +1187 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32-s2.macros +1187 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-32.macros +26 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-64.macros +728 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-arm.c +123 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armcc.s +653 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-armgcc.s +686 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8.c +163 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-compact.s +647 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-avr8asm-fast.s +934 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-inplace-armgcc-ARMv7A-NEON.s +446 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-int-set.h +6 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-interface.h +46 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32-settings.h +4 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt32.c +524 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64-settings.h +7 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-opt64.c +504 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.c +300 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.h +20 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-reference32BI.c +371 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd128.macros +651 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-simd64.macros +517 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-unrolling.macros +124 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-asm.c +62 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-gas.s +766 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-x86-64-shld-gas.s +766 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakF-1600-xop.macros +573 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.h +70 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.c +266 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.h +76 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc1024-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +296 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/Keccakc512-crypto_hash-inplace-armgcc-ARMv7A-NEON.s +429 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/brg_endian.h +142 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/crypto_hash.h +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.c +117 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.h +29 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/genKAT.c +692 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainARM.c +88 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainOptimized.c +23 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/mainReference.c +381 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.c +436 -0
- data/ext/sha3/KeccakReferenceAndOptimized/Sources/timing.h +13 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation-config.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.c +572 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/DoublePermutation.h +38 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/KeccakF-1600-unrolling.macros +124 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc256TreeD2.h +18 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.c +81 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/Keccakc512TreeD2.h +18 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/crypto_hash.h +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/mainOptimized.c +112 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.c +225 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/Sources/timing-Double.h +20 -0
- data/ext/sha3/KeccakReferenceAndOptimized/TreeHashing/makefile +68 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakCompact +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized32 +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakOptimized64 +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakReference32BI +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/KeccakSimple32BI +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/compact/Keccak-compact.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakF-1600-opt32.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/mainOptimized.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized32/timing.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakF-1600-opt64.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/mainOptimized.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/optimized64/timing.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakF-1600-reference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference/mainReference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakDuplex.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakF-1600-reference32BI.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakNISTInterface.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/KeccakSponge.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/displayIntermediateValues.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/genKAT.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/reference32bi/mainReference.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple/Keccak-simple.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple-test.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/bin/simple32BI/Keccak-simple32BI.o +0 -0
- data/ext/sha3/KeccakReferenceAndOptimized/compile64.bat +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccak +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc1024 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc256treed2 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc448 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc512treed2 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/checksum-keccakc768 +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccak.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc1024.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc256.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc448.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc512.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/hash-keccakc768.c +11 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccak.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc1024.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc256.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc448.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc512.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/int-set-keccakc768.h +1 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/populate.py +506 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccak.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc1024.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc256.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc448.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc512.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/eBASH/simple-keccakc768.h +2 -0
- data/ext/sha3/KeccakReferenceAndOptimized/makefile +327 -0
- data/ext/sha3/Makefile +240 -0
- data/ext/sha3/depend +28 -0
- data/ext/sha3/extconf.rb +21 -0
- data/ext/sha3/sha3.c +95 -0
- data/lib/sha3-ruby.rb +27 -0
- data/lib/sha3-ruby/version.rb +5 -0
- data/sha3-ruby.gemspec +21 -0
- metadata +233 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "crypto_hash.h"
|
2
|
+
#include "KeccakSponge.h"
|
3
|
+
|
4
|
+
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
|
5
|
+
{
|
6
|
+
spongeState state;
|
7
|
+
InitSponge(&state, 576, 1024);
|
8
|
+
Absorb(&state, in, inlen*8);
|
9
|
+
Squeeze(&state, out, crypto_hash_BYTES*8);
|
10
|
+
return 0;
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "crypto_hash.h"
|
2
|
+
#include "KeccakSponge.h"
|
3
|
+
|
4
|
+
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
|
5
|
+
{
|
6
|
+
spongeState state;
|
7
|
+
InitSponge(&state, 1344, 256);
|
8
|
+
Absorb(&state, in, inlen*8);
|
9
|
+
Squeeze(&state, out, crypto_hash_BYTES*8);
|
10
|
+
return 0;
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "crypto_hash.h"
|
2
|
+
#include "KeccakSponge.h"
|
3
|
+
|
4
|
+
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
|
5
|
+
{
|
6
|
+
spongeState state;
|
7
|
+
InitSponge(&state, 1152, 448);
|
8
|
+
Absorb(&state, in, inlen*8);
|
9
|
+
Squeeze(&state, out, crypto_hash_BYTES*8);
|
10
|
+
return 0;
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "crypto_hash.h"
|
2
|
+
#include "KeccakSponge.h"
|
3
|
+
|
4
|
+
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
|
5
|
+
{
|
6
|
+
spongeState state;
|
7
|
+
InitSponge(&state, 1088, 512);
|
8
|
+
Absorb(&state, in, inlen*8);
|
9
|
+
Squeeze(&state, out, crypto_hash_BYTES*8);
|
10
|
+
return 0;
|
11
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#include "crypto_hash.h"
|
2
|
+
#include "KeccakSponge.h"
|
3
|
+
|
4
|
+
int crypto_hash(unsigned char *out, const unsigned char *in, unsigned long long inlen)
|
5
|
+
{
|
6
|
+
spongeState state;
|
7
|
+
InitSponge(&state, 832, 768);
|
8
|
+
Absorb(&state, in, inlen*8);
|
9
|
+
Squeeze(&state, out, crypto_hash_BYTES*8);
|
10
|
+
return 0;
|
11
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast1024
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast576
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast1344
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast1152
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast1088
|
@@ -0,0 +1 @@
|
|
1
|
+
#define ProvideFast832
|
@@ -0,0 +1,506 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
import os, shutil
|
3
|
+
|
4
|
+
version = '3.2.5'
|
5
|
+
|
6
|
+
class KeccakInstance:
|
7
|
+
def __init__(self, r, c, n=0):
|
8
|
+
self.r = r
|
9
|
+
self.c = c
|
10
|
+
self.n = n
|
11
|
+
self.name = 'keccak'
|
12
|
+
if (r+c != 1600):
|
13
|
+
self.name = self.name + 'r{0}'.format(r) + 'c{0}'.format(c)
|
14
|
+
elif (c != 576):
|
15
|
+
self.name = self.name + 'c{0}'.format(c)
|
16
|
+
def outputSize(self):
|
17
|
+
if (self.n != 0):
|
18
|
+
return self.n
|
19
|
+
else:
|
20
|
+
return self.r
|
21
|
+
def outputSizeIsRate(self):
|
22
|
+
if (self.n != 0):
|
23
|
+
return False
|
24
|
+
else:
|
25
|
+
return True
|
26
|
+
|
27
|
+
def makeDir(instance, implementation):
|
28
|
+
pathName = instance.name + '/' + implementation
|
29
|
+
try:
|
30
|
+
os.makedirs(pathName)
|
31
|
+
except OSError:
|
32
|
+
pass
|
33
|
+
|
34
|
+
def copySourceFiles(instance, implementation, sourceFiles, sourceLocation='Sources/'):
|
35
|
+
for fileName in sourceFiles:
|
36
|
+
shutil.copyfile('../'+sourceLocation+fileName, instance.name+'/'+implementation+'/'+fileName)
|
37
|
+
|
38
|
+
def writeAPIdotH(instance, implementation):
|
39
|
+
with open(instance.name+'/'+implementation+'/api.h', 'w') as f:
|
40
|
+
f.write('#define CRYPTO_BYTES {0}\n'.format(instance.outputSize()//8))
|
41
|
+
f.write('#define CRYPTO_VERSION "{0}"\n'.format(version))
|
42
|
+
|
43
|
+
def copyWrapperFiles(instance, implementation):
|
44
|
+
shutil.copyfile('hash-'+instance.name+'.c', instance.name+'/'+implementation+'/hash.c')
|
45
|
+
shutil.copyfile('int-set-'+instance.name+'.h', instance.name+'/'+implementation+'/KeccakF-1600-int-set.h')
|
46
|
+
|
47
|
+
def writeImplementors(instance, implementation, implementors):
|
48
|
+
with open(instance.name+'/'+implementation+'/implementors', 'w') as f:
|
49
|
+
for person in implementors:
|
50
|
+
f.write(person+'\n')
|
51
|
+
|
52
|
+
Ronny = ['Ronny Van Keer']
|
53
|
+
Designers = ['Guido Bertoni', 'Joan Daemen', 'Michaël Peeters', 'Gilles Van Assche']
|
54
|
+
|
55
|
+
def makeOpt64(instance, laneComplementing, unrolling, useSHLD=False):
|
56
|
+
implementation = 'opt64'
|
57
|
+
if (laneComplementing):
|
58
|
+
implementation = implementation + 'lc'
|
59
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
60
|
+
if (useSHLD):
|
61
|
+
implementation = implementation + 'shld'
|
62
|
+
print(' Implementation', implementation)
|
63
|
+
makeDir(instance, implementation)
|
64
|
+
with open(instance.name+'/'+implementation+'/KeccakF-1600-opt64-settings.h', 'w') as f:
|
65
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
66
|
+
if (laneComplementing):
|
67
|
+
f.write('#define UseBebigokimisa\n')
|
68
|
+
if (useSHLD):
|
69
|
+
f.write('#define UseSHLD\n')
|
70
|
+
copySourceFiles(instance, implementation,
|
71
|
+
[ 'brg_endian.h',
|
72
|
+
'KeccakSponge.c',
|
73
|
+
'KeccakSponge.h',
|
74
|
+
'KeccakF-1600-interface.h',
|
75
|
+
'KeccakF-1600-unrolling.macros',
|
76
|
+
'KeccakF-1600-64.macros',
|
77
|
+
'KeccakF-1600-opt64.c' ])
|
78
|
+
writeAPIdotH(instance, implementation)
|
79
|
+
copyWrapperFiles(instance, implementation)
|
80
|
+
writeImplementors(instance, implementation, Designers)
|
81
|
+
|
82
|
+
def makeOpt_x86_64_asm(instance):
|
83
|
+
implementation = 'x86_64_asm'
|
84
|
+
print(' Implementation', implementation)
|
85
|
+
makeDir(instance, implementation)
|
86
|
+
copySourceFiles(instance, implementation,
|
87
|
+
[ 'brg_endian.h',
|
88
|
+
'KeccakSponge.c',
|
89
|
+
'KeccakSponge.h',
|
90
|
+
'KeccakF-1600-interface.h',
|
91
|
+
'KeccakF-1600-x86-64-gas.s',
|
92
|
+
'KeccakF-1600-x86-64-asm.c' ])
|
93
|
+
writeAPIdotH(instance, implementation)
|
94
|
+
copyWrapperFiles(instance, implementation)
|
95
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
96
|
+
f.write('amd64\n')
|
97
|
+
writeImplementors(instance, implementation, Ronny)
|
98
|
+
|
99
|
+
def makeOpt_x86_64_shld(instance):
|
100
|
+
implementation = 'x86_64_shld'
|
101
|
+
print(' Implementation', implementation)
|
102
|
+
makeDir(instance, implementation)
|
103
|
+
copySourceFiles(instance, implementation,
|
104
|
+
[ 'brg_endian.h',
|
105
|
+
'KeccakSponge.c',
|
106
|
+
'KeccakSponge.h',
|
107
|
+
'KeccakF-1600-interface.h',
|
108
|
+
'KeccakF-1600-x86-64-shld-gas.s',
|
109
|
+
'KeccakF-1600-x86-64-asm.c' ])
|
110
|
+
writeAPIdotH(instance, implementation)
|
111
|
+
copyWrapperFiles(instance, implementation)
|
112
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
113
|
+
f.write('amd64\n')
|
114
|
+
writeImplementors(instance, implementation, Ronny)
|
115
|
+
|
116
|
+
def makeSSE(instance, unrolling):
|
117
|
+
implementation = 'sse'
|
118
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
119
|
+
print(' Implementation', implementation)
|
120
|
+
makeDir(instance, implementation)
|
121
|
+
with open(instance.name+'/'+implementation+'/KeccakF-1600-opt64-settings.h', 'w') as f:
|
122
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
123
|
+
f.write('#define UseSSE\n')
|
124
|
+
copySourceFiles(instance, implementation,
|
125
|
+
[ 'brg_endian.h',
|
126
|
+
'KeccakSponge.c',
|
127
|
+
'KeccakSponge.h',
|
128
|
+
'KeccakF-1600-interface.h',
|
129
|
+
'KeccakF-1600-unrolling.macros',
|
130
|
+
'KeccakF-1600-simd128.macros',
|
131
|
+
'KeccakF-1600-opt64.c' ])
|
132
|
+
writeAPIdotH(instance, implementation)
|
133
|
+
copyWrapperFiles(instance, implementation)
|
134
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
135
|
+
f.write('amd64\n')
|
136
|
+
f.write('x86\n')
|
137
|
+
writeImplementors(instance, implementation, Designers)
|
138
|
+
|
139
|
+
def makeXOP(instance, unrolling):
|
140
|
+
implementation = 'xop'
|
141
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
142
|
+
print(' Implementation', implementation)
|
143
|
+
makeDir(instance, implementation)
|
144
|
+
with open(instance.name+'/'+implementation+'/KeccakF-1600-opt64-settings.h', 'w') as f:
|
145
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
146
|
+
f.write('#define UseXOP\n')
|
147
|
+
copySourceFiles(instance, implementation,
|
148
|
+
[ 'brg_endian.h',
|
149
|
+
'KeccakSponge.c',
|
150
|
+
'KeccakSponge.h',
|
151
|
+
'KeccakF-1600-interface.h',
|
152
|
+
'KeccakF-1600-unrolling.macros',
|
153
|
+
'KeccakF-1600-xop.macros',
|
154
|
+
'KeccakF-1600-opt64.c' ])
|
155
|
+
writeAPIdotH(instance, implementation)
|
156
|
+
copyWrapperFiles(instance, implementation)
|
157
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
158
|
+
f.write('amd64\n')
|
159
|
+
f.write('x86\n')
|
160
|
+
writeImplementors(instance, implementation, Designers)
|
161
|
+
|
162
|
+
def makeMMX(instance, unrolling):
|
163
|
+
implementation = 'mmx'
|
164
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
165
|
+
print(' Implementation', implementation)
|
166
|
+
makeDir(instance, implementation)
|
167
|
+
with open(instance.name+'/'+implementation+'/KeccakF-1600-opt64-settings.h', 'w') as f:
|
168
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
169
|
+
f.write('#define UseMMX\n')
|
170
|
+
copySourceFiles(instance, implementation,
|
171
|
+
[ 'brg_endian.h',
|
172
|
+
'KeccakSponge.c',
|
173
|
+
'KeccakSponge.h',
|
174
|
+
'KeccakF-1600-interface.h',
|
175
|
+
'KeccakF-1600-unrolling.macros',
|
176
|
+
'KeccakF-1600-simd64.macros',
|
177
|
+
'KeccakF-1600-opt64.c' ])
|
178
|
+
writeAPIdotH(instance, implementation)
|
179
|
+
copyWrapperFiles(instance, implementation)
|
180
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
181
|
+
f.write('amd64\n')
|
182
|
+
f.write('x86\n')
|
183
|
+
writeImplementors(instance, implementation, Designers)
|
184
|
+
|
185
|
+
def makeOpt32(instance, bitInterleavingTable, laneComplementing, schedule, unrolling):
|
186
|
+
implementation = 'opt32bi'
|
187
|
+
if (bitInterleavingTable):
|
188
|
+
implementation = implementation + 'T'
|
189
|
+
if (schedule == 3):
|
190
|
+
implementation = implementation + '-rvk'
|
191
|
+
else:
|
192
|
+
implementation = implementation + '-s{0}'.format(schedule)
|
193
|
+
if (laneComplementing):
|
194
|
+
implementation = implementation + 'lc'
|
195
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
196
|
+
print(' Implementation', implementation)
|
197
|
+
makeDir(instance, implementation)
|
198
|
+
with open(instance.name+'/'+implementation+'/KeccakF-1600-opt32-settings.h', 'w') as f:
|
199
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
200
|
+
if (bitInterleavingTable):
|
201
|
+
f.write('#define UseInterleaveTables\n')
|
202
|
+
if (laneComplementing):
|
203
|
+
f.write('#define UseBebigokimisa\n')
|
204
|
+
f.write('#define UseSchedule {0}\n'.format(schedule))
|
205
|
+
copySourceFiles(instance, implementation,
|
206
|
+
[ 'brg_endian.h',
|
207
|
+
'KeccakSponge.c',
|
208
|
+
'KeccakSponge.h',
|
209
|
+
'KeccakF-1600-interface.h',
|
210
|
+
'KeccakF-1600-unrolling.macros',
|
211
|
+
'KeccakF-1600-32.macros',
|
212
|
+
'KeccakF-1600-opt32.c' ])
|
213
|
+
if (schedule == 3):
|
214
|
+
copySourceFiles(instance, implementation, ['KeccakF-1600-32-rvk.macros'])
|
215
|
+
else:
|
216
|
+
copySourceFiles(instance, implementation, ['KeccakF-1600-32-s{0}.macros'.format(schedule)])
|
217
|
+
writeAPIdotH(instance, implementation)
|
218
|
+
copyWrapperFiles(instance, implementation)
|
219
|
+
if (schedule == 3):
|
220
|
+
writeImplementors(instance, implementation, Designers + Ronny)
|
221
|
+
else:
|
222
|
+
writeImplementors(instance, implementation, Designers)
|
223
|
+
|
224
|
+
def architectureARM(instance, implementation):
|
225
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
226
|
+
f.write('arm\n')
|
227
|
+
f.write('armeabi\n')
|
228
|
+
|
229
|
+
def makeARMasm(instance):
|
230
|
+
implementation = 'armasm'
|
231
|
+
print(' Implementation', implementation)
|
232
|
+
makeDir(instance, implementation)
|
233
|
+
copySourceFiles(instance, implementation,
|
234
|
+
[ 'KeccakSponge.c',
|
235
|
+
'KeccakSponge.h',
|
236
|
+
'KeccakF-1600-interface.h',
|
237
|
+
'KeccakF-1600-armgcc.s',
|
238
|
+
'KeccakF-1600-arm.c' ])
|
239
|
+
writeAPIdotH(instance, implementation)
|
240
|
+
copyWrapperFiles(instance, implementation)
|
241
|
+
architectureARM(instance, implementation)
|
242
|
+
writeImplementors(instance, implementation, Ronny)
|
243
|
+
|
244
|
+
def makeSimple(instance):
|
245
|
+
implementation = 'simple'
|
246
|
+
print(' Implementation', implementation)
|
247
|
+
makeDir(instance, implementation)
|
248
|
+
copySourceFiles(instance, implementation,
|
249
|
+
[ 'Keccak-simple.c' ])
|
250
|
+
writeAPIdotH(instance, implementation)
|
251
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-simple-settings.h')
|
252
|
+
writeImplementors(instance, implementation, Ronny)
|
253
|
+
|
254
|
+
def makeSimple32BI(instance):
|
255
|
+
implementation = 'simple32bi'
|
256
|
+
print(' Implementation', implementation)
|
257
|
+
makeDir(instance, implementation)
|
258
|
+
copySourceFiles(instance, implementation,
|
259
|
+
[ 'Keccak-simple32BI.c' ])
|
260
|
+
writeAPIdotH(instance, implementation)
|
261
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-simple-settings.h')
|
262
|
+
writeImplementors(instance, implementation, Designers + Ronny)
|
263
|
+
|
264
|
+
def makeInplace(instance):
|
265
|
+
implementation = 'inplace'
|
266
|
+
print(' Implementation', implementation)
|
267
|
+
makeDir(instance, implementation)
|
268
|
+
copySourceFiles(instance, implementation,
|
269
|
+
[ 'Keccak-inplace.c' ])
|
270
|
+
writeAPIdotH(instance, implementation)
|
271
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-inplace-settings.h')
|
272
|
+
writeImplementors(instance, implementation, Designers + Ronny)
|
273
|
+
|
274
|
+
def makeInplace32BI(instance):
|
275
|
+
implementation = 'inplace32bi'
|
276
|
+
print(' Implementation', implementation)
|
277
|
+
makeDir(instance, implementation)
|
278
|
+
copySourceFiles(instance, implementation,
|
279
|
+
[ 'Keccak-inplace32BI.c' ])
|
280
|
+
writeAPIdotH(instance, implementation)
|
281
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-inplace-settings.h')
|
282
|
+
writeImplementors(instance, implementation, Designers + Ronny)
|
283
|
+
|
284
|
+
def processAssemblyCode(instance, implementation, source, destination):
|
285
|
+
with open(source, 'r') as f:
|
286
|
+
d = open(destination, 'w')
|
287
|
+
for line in f:
|
288
|
+
if (line.find('// populate.py, please set cKeccakR_SizeInBytes') >= 0):
|
289
|
+
d.write('.equ cKeccakR_SizeInBytes , {0}/8\n'.format(instance.r))
|
290
|
+
elif (line.find('// populate.py, please set crypto_hash_BYTES') >= 0):
|
291
|
+
if (instance.outputSizeIsRate()):
|
292
|
+
d.write('.equ crypto_hash_BYTES , cKeccakR_SizeInBytes\n')
|
293
|
+
else:
|
294
|
+
d.write('.equ crypto_hash_BYTES , {0}/8\n'.format(instance.outputSize()))
|
295
|
+
elif (line.find('// populate.py, please update crypto_hash') >= 0):
|
296
|
+
line = line[0:line.find('// populate.py, please update crypto_hash')]
|
297
|
+
crypto_hash = 'crypto_hash_'+instance.name+'_'+implementation.replace('-', '_')
|
298
|
+
line = line.replace('crypto_hash', crypto_hash)
|
299
|
+
d.write(line+'\n')
|
300
|
+
else:
|
301
|
+
d.write(line)
|
302
|
+
|
303
|
+
def makeInplace32BI_ARMv6M(instance):
|
304
|
+
implementation = 'inplace32bi-armv6m'
|
305
|
+
print(' Implementation', implementation)
|
306
|
+
makeDir(instance, implementation)
|
307
|
+
processAssemblyCode(instance, implementation, '../Sources/Keccak-inplace32BI-armgcc-ARMv6M.s', instance.name+'/'+implementation+'/Keccak-inplace32BI-armgcc-ARMv6M.s')
|
308
|
+
writeAPIdotH(instance, implementation)
|
309
|
+
architectureARM(instance, implementation)
|
310
|
+
writeImplementors(instance, implementation, Ronny)
|
311
|
+
|
312
|
+
def makeInplace32BI_ARMv7M(instance):
|
313
|
+
implementation = 'inplace32bi-armv7m'
|
314
|
+
print(' Implementation', implementation)
|
315
|
+
makeDir(instance, implementation)
|
316
|
+
processAssemblyCode(instance, implementation, '../Sources/Keccak-inplace32BI-armgcc-ARMv7M.s', instance.name+'/'+implementation+'/Keccak-inplace32BI-armgcc-ARMv7M.s')
|
317
|
+
writeAPIdotH(instance, implementation)
|
318
|
+
architectureARM(instance, implementation)
|
319
|
+
writeImplementors(instance, implementation, Ronny)
|
320
|
+
|
321
|
+
def makeInplace32BI_ARMv7A(instance):
|
322
|
+
implementation = 'inplace32bi-armv7a'
|
323
|
+
print(' Implementation', implementation)
|
324
|
+
makeDir(instance, implementation)
|
325
|
+
processAssemblyCode(instance, implementation, '../Sources/Keccak-inplace32BI-armgcc-ARMv7A.s', instance.name+'/'+implementation+'/Keccak-inplace32BI-armgcc-ARMv7A.s')
|
326
|
+
writeAPIdotH(instance, implementation)
|
327
|
+
architectureARM(instance, implementation)
|
328
|
+
writeImplementors(instance, implementation, Ronny)
|
329
|
+
|
330
|
+
def makeInplace_ARMv7A_NEON(instance):
|
331
|
+
implementation = 'inplace-armv7a-neon'
|
332
|
+
print(' Implementation', implementation)
|
333
|
+
makeDir(instance, implementation)
|
334
|
+
writeAPIdotH(instance, implementation)
|
335
|
+
fileName = instance.name.replace('keccak', 'Keccak')+'-crypto_hash-inplace-armgcc-ARMv7A-NEON.s'
|
336
|
+
processAssemblyCode(instance, implementation, '../Sources/'+fileName, instance.name+'/'+implementation+'/Keccak.s')
|
337
|
+
shutil.copyfile('../Sources/KeccakF-1600-inplace-armgcc-ARMv7A-NEON.s', instance.name+'/'+implementation+'/Keccak2.s')
|
338
|
+
writeImplementors(instance, implementation, Ronny)
|
339
|
+
|
340
|
+
def makeCompact(instance):
|
341
|
+
implementation = 'compact'
|
342
|
+
print(' Implementation', implementation)
|
343
|
+
makeDir(instance, implementation)
|
344
|
+
copySourceFiles(instance, implementation,
|
345
|
+
[ 'Keccak-compact.c',
|
346
|
+
'Keccak-compact.h' ])
|
347
|
+
writeAPIdotH(instance, implementation)
|
348
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-compact-settings.h')
|
349
|
+
writeImplementors(instance, implementation, Ronny)
|
350
|
+
|
351
|
+
def makeCompact8(instance):
|
352
|
+
implementation = 'compact8'
|
353
|
+
print(' Implementation', implementation)
|
354
|
+
makeDir(instance, implementation)
|
355
|
+
copySourceFiles(instance, implementation,
|
356
|
+
[ 'Keccak-compact8.c',
|
357
|
+
'Keccak-compact8.h' ])
|
358
|
+
writeAPIdotH(instance, implementation)
|
359
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-compact8-settings.h')
|
360
|
+
writeImplementors(instance, implementation, Designers + Ronny)
|
361
|
+
|
362
|
+
def makeAVR8(instance):
|
363
|
+
implementation = 'avr8'
|
364
|
+
print(' Implementation', implementation)
|
365
|
+
makeDir(instance, implementation)
|
366
|
+
copySourceFiles(instance, implementation,
|
367
|
+
[ 'AVR8-rotate64.h',
|
368
|
+
'AVR8-rotate64.s',
|
369
|
+
'Keccak-avr8.c',
|
370
|
+
'Keccak-avr8.h',
|
371
|
+
'Keccak-avr8-util.h',
|
372
|
+
'Keccak-avr8-util.s',
|
373
|
+
'KeccakF-1600-avr8.c' ])
|
374
|
+
writeAPIdotH(instance, implementation)
|
375
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-avr8-settings.h')
|
376
|
+
writeImplementors(instance, implementation, Ronny)
|
377
|
+
|
378
|
+
def makeAVR8asmCompact(instance):
|
379
|
+
implementation = 'avr8asmc'
|
380
|
+
print(' Implementation', implementation)
|
381
|
+
makeDir(instance, implementation)
|
382
|
+
copySourceFiles(instance, implementation,
|
383
|
+
[ 'Keccak-avr8.h' ])
|
384
|
+
processAssemblyCode(instance, implementation, '../Sources/KeccakF-1600-avr8asm-compact.s', instance.name+'/'+implementation+'/KeccakF-1600-avr8asm-compact.s')
|
385
|
+
writeAPIdotH(instance, implementation)
|
386
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-avr8-settings.h')
|
387
|
+
writeImplementors(instance, implementation, Ronny)
|
388
|
+
|
389
|
+
def makeAVR8asmFast(instance):
|
390
|
+
implementation = 'avr8asmf'
|
391
|
+
print(' Implementation', implementation)
|
392
|
+
makeDir(instance, implementation)
|
393
|
+
copySourceFiles(instance, implementation,
|
394
|
+
[ 'Keccak-avr8.h' ])
|
395
|
+
processAssemblyCode(instance, implementation, '../Sources/KeccakF-1600-avr8asm-fast.s', instance.name+'/'+implementation+'/KeccakF-1600-avr8asm-fast.s')
|
396
|
+
writeAPIdotH(instance, implementation)
|
397
|
+
shutil.copyfile('simple-'+instance.name+'.h', instance.name+'/'+implementation+'/Keccak-avr8-settings.h')
|
398
|
+
writeImplementors(instance, implementation, Ronny)
|
399
|
+
|
400
|
+
def eBASH_Keccak(r, c, n=0):
|
401
|
+
instance = KeccakInstance(r, c, n)
|
402
|
+
print('Instance', instance.name)
|
403
|
+
makeOpt_x86_64_asm(instance)
|
404
|
+
makeOpt_x86_64_shld(instance)
|
405
|
+
makeOpt64(instance, True, 24, True)
|
406
|
+
makeOpt64(instance, True, 24)
|
407
|
+
makeOpt64(instance, True, 6)
|
408
|
+
makeOpt64(instance, False, 6)
|
409
|
+
makeOpt32(instance, False, True, 2, 4)
|
410
|
+
makeOpt32(instance, True, True, 2, 4)
|
411
|
+
#makeOpt32(instance, False, False, 2, 4)
|
412
|
+
makeOpt32(instance, False, False, 3, 2)
|
413
|
+
#makeOpt32(instance, False, True, 1, 4)
|
414
|
+
makeSSE(instance, 2)
|
415
|
+
makeXOP(instance, 24)
|
416
|
+
makeMMX(instance, 1)
|
417
|
+
#makeARMasm(instance)
|
418
|
+
makeSimple(instance)
|
419
|
+
makeSimple32BI(instance)
|
420
|
+
makeInplace(instance)
|
421
|
+
if ((r+c == 1600) and (c in [512, 576, 1024])):
|
422
|
+
makeInplace_ARMv7A_NEON(instance)
|
423
|
+
makeInplace32BI(instance)
|
424
|
+
makeInplace32BI_ARMv6M(instance)
|
425
|
+
makeInplace32BI_ARMv7M(instance)
|
426
|
+
makeInplace32BI_ARMv7A(instance)
|
427
|
+
makeCompact(instance)
|
428
|
+
makeCompact8(instance)
|
429
|
+
makeAVR8(instance)
|
430
|
+
makeAVR8asmCompact(instance)
|
431
|
+
makeAVR8asmFast(instance)
|
432
|
+
shutil.copyfile('checksum-'+instance.name, instance.name+'/checksum')
|
433
|
+
|
434
|
+
class ShortLeafInterleavedKeccakTreeInstance:
|
435
|
+
def __init__(self, r, c, D, B, n=0):
|
436
|
+
self.r = r
|
437
|
+
self.c = c
|
438
|
+
self.D = D
|
439
|
+
self.B = B
|
440
|
+
self.n = n
|
441
|
+
self.name = 'keccak'
|
442
|
+
if (r+c != 1600):
|
443
|
+
self.name = self.name + 'r{0}'.format(r) + 'c{0}'.format(c)
|
444
|
+
elif (c != 576):
|
445
|
+
self.name = self.name + 'c{0}'.format(c)
|
446
|
+
self.name = self.name + 'treed{0}'.format(D)
|
447
|
+
if (B != 64):
|
448
|
+
self.name = self.name + 'b{0}'.format(B)
|
449
|
+
def outputSize(self):
|
450
|
+
if (self.n != 0):
|
451
|
+
return self.n
|
452
|
+
else:
|
453
|
+
return self.r
|
454
|
+
def outputSizeIsRate(self):
|
455
|
+
if (self.n != 0):
|
456
|
+
return False
|
457
|
+
else:
|
458
|
+
return True
|
459
|
+
|
460
|
+
def makeTree(instance, unrolling, implBaseName, useWhat):
|
461
|
+
implementation = implBaseName
|
462
|
+
implementation = implementation + 'u{0}'.format(unrolling)
|
463
|
+
print(' Implementation', implementation)
|
464
|
+
makeDir(instance, implementation)
|
465
|
+
if (instance.D != 2):
|
466
|
+
raise "D must be 2"
|
467
|
+
with open(instance.name+'/'+implementation+'/DoublePermutation-config.h', 'w') as f:
|
468
|
+
f.write('#define Unrolling {0}\n'.format(unrolling))
|
469
|
+
f.write('#define '+useWhat+'\n')
|
470
|
+
hashFileName = instance.name.replace('keccak', 'Keccak').replace('tree', 'Tree').replace('d', 'D')
|
471
|
+
copySourceFiles(instance, implementation,
|
472
|
+
[ 'DoublePermutation.c',
|
473
|
+
'DoublePermutation.h',
|
474
|
+
hashFileName+'.c',
|
475
|
+
hashFileName+'.h',
|
476
|
+
'KeccakF-1600-unrolling.macros' ],
|
477
|
+
'TreeHashing/Sources/')
|
478
|
+
writeAPIdotH(instance, implementation)
|
479
|
+
with open(instance.name+'/'+implementation+'/architectures', 'w') as f:
|
480
|
+
f.write('amd64\n')
|
481
|
+
f.write('x86\n')
|
482
|
+
writeImplementors(instance, implementation, Designers)
|
483
|
+
|
484
|
+
def makeTreeSSE(instance, unrolling):
|
485
|
+
makeTree(instance, unrolling, 'sse', 'UseSSE')
|
486
|
+
|
487
|
+
def makeTreeXOP(instance, unrolling):
|
488
|
+
makeTree(instance, unrolling, 'xop', 'UseXOP')
|
489
|
+
|
490
|
+
def eBASH_KeccakTree(r, c, D, B, n=0):
|
491
|
+
instance = ShortLeafInterleavedKeccakTreeInstance(r, c, D, B, n)
|
492
|
+
print('Instance', instance.name)
|
493
|
+
makeTreeSSE(instance, 4)
|
494
|
+
makeTreeSSE(instance, 24)
|
495
|
+
makeTreeXOP(instance, 24)
|
496
|
+
shutil.copyfile('checksum-'+instance.name, instance.name+'/checksum')
|
497
|
+
|
498
|
+
|
499
|
+
eBASH_Keccak(r=576, c=1024, n=512)
|
500
|
+
eBASH_Keccak(r=832, c=768, n=384)
|
501
|
+
eBASH_Keccak(r=1024, c=576)
|
502
|
+
eBASH_Keccak(r=1088, c=512, n=256)
|
503
|
+
eBASH_Keccak(r=1152, c=448, n=224)
|
504
|
+
eBASH_Keccak(r=1344, c=256)
|
505
|
+
eBASH_KeccakTree(r=1088, c=512, D=2, B=64)
|
506
|
+
eBASH_KeccakTree(r=1344, c=256, D=2, B=64)
|