diff options
author | Andres Erbsen <andreser@mit.edu> | 2017-07-02 19:04:11 -0400 |
---|---|---|
committer | Andres Erbsen <andreser@mit.edu> | 2017-07-02 19:04:11 -0400 |
commit | 6c558bd2f52e109b544c38f489fd7e1b9b2933ca (patch) | |
tree | 51c1af7a13a26ed536772dcebfa110a56f482e79 | |
parent | d7ad9528319596298b80e450e5a2eb87610d2fcf (diff) |
X25519 test (passed on first try)
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | src/Specific/NISTP256/AMD64/measurements.txt | 2 | ||||
-rw-r--r-- | src/Specific/X25519/C64/measurements.txt | 2 | ||||
-rw-r--r-- | src/Specific/X25519/x25519_test.c | 28 |
4 files changed, 38 insertions, 4 deletions
@@ -18,7 +18,7 @@ INSTALLDEFAULTROOT := Crypto specific-c specific-display display \ specific non-specific lite only-heavy printlite \ curves-proofs no-curves-proofs \ - bench c + test bench c SORT_COQPROJECT = sed 's,[^/]*/,~&,g' | env LC_COLLATE=C sort | sed 's,~,,g' | uniq @@ -150,6 +150,9 @@ $(DISPLAY_JAVA_VO:.vo=.log) : %JavaDisplay.log : %.vo %JavaDisplay.v src/Compile DISPLAY_X25519_C64_VO := $(filter src/Specific/X25519/C64/%,$(DISPLAY_NON_JAVA_VO)) +src/Specific/X25519/C64/test: src/Specific/X25519/C64/compiler.sh src/Specific/X25519/x25519_test.c $(DISPLAY_X25519_C64_VO:Display.vo=.c) $(DISPLAY_X25519_C64_VO:Display.vo=.h) src/Specific/X25519/C64/scalarmult.c + src/Specific/X25519/C64/compiler.sh -o src/Specific/X25519/C64/test -I liblow -I src/Specific/X25519/C64/ src/Specific/X25519/x25519_test.c $(DISPLAY_X25519_C64_VO:Display.vo=.c) src/Specific/X25519/C64/scalarmult.c + src/Specific/X25519/C64/measure: src/Specific/X25519/C64/compiler.sh measure.c $(DISPLAY_X25519_C64_VO:Display.vo=.c) $(DISPLAY_X25519_C64_VO:Display.vo=.h) src/Specific/X25519/C64/scalarmult.c src/Specific/X25519/C64/compiler.sh -o src/Specific/X25519/C64/measure -I liblow -I src/Specific/X25519/C64/ measure.c $(DISPLAY_X25519_C64_VO:Display.vo=.c) src/Specific/X25519/C64/scalarmult.c -D UUT=crypto_scalarmult_bench @@ -163,7 +166,7 @@ third_party/openssl-curve25519/measurements.txt: third_party/openssl-curve25519/ ./capture.sh third_party/openssl-curve25519 2047 third_party/openssl-nistz256/measure: third_party/openssl-nistz256/compiler.sh third_party/openssl-nistz256/bench_madd.c third_party/openssl-nistz256/cpu_intel.c third_party/openssl-nistz256/ecp_nistz256-x86_64.s third_party/openssl-nistz256/nistz256.h - third_party/openssl-nistz256/compiler.sh -o third_party/openssl-nistz256/measure measure.c third_party/openssl-nistz256/bench_madd.c third_party/openssl-nistz256/cpu_intel.c third_party/openssl-nistz256/ecp_nistz256-x86_64.s src/Specific/X25519/C64/scalarmult.c -I liblow -I third_party/openssl-nistz256 -D UUT=bench_madd + third_party/openssl-nistz256/compiler.sh -o third_party/openssl-nistz256/measure measure.c third_party/openssl-nistz256/bench_madd.c third_party/openssl-nistz256/cpu_intel.c third_party/openssl-nistz256/ecp_nistz256-x86_64.s -I liblow -I third_party/openssl-nistz256 -D UUT=bench_madd third_party/openssl-nistz256/measurements.txt: third_party/openssl-nistz256/measure ./capture.sh third_party/openssl-nistz256 65535 @@ -189,6 +192,9 @@ src/Specific/NISTP256/AMD64/icc/measurements.txt: src/Specific/NISTP256/AMD64/ic bench: src/Specific/X25519/C64/measurements.txt third_party/openssl-curve25519/measurements.txt src/Specific/NISTP256/AMD64/measurements.txt src/Specific/NISTP256/AMD64/icc/measurements.txt third_party/openssl-nistz256/measurements.txt third_party/openssl-nistp256c64/measurements.txt head -999999 $? +test: src/Specific/X25519/C64/test + src/Specific/X25519/C64/test + clean:: rm -f Makefile.coq diff --git a/src/Specific/NISTP256/AMD64/measurements.txt b/src/Specific/NISTP256/AMD64/measurements.txt index 1734b1b25..1ec583018 100644 --- a/src/Specific/NISTP256/AMD64/measurements.txt +++ b/src/Specific/NISTP256/AMD64/measurements.txt @@ -1,2 +1,2 @@ 1576 ashryn-noht-notb-noac-broadwell 2.60ghz 7.1.1 cac291e0 -1688 ashryn-noht-notb-ac-broadwell 2.50ghz 7.1.1 448af3b4 +1688 ashryn-noht-notb-ac-broadwell 2.50ghz 7.1.1 d7ad9528 diff --git a/src/Specific/X25519/C64/measurements.txt b/src/Specific/X25519/C64/measurements.txt index e9ef5a5a7..145c4f1fc 100644 --- a/src/Specific/X25519/C64/measurements.txt +++ b/src/Specific/X25519/C64/measurements.txt @@ -1,6 +1,6 @@ 136156 ashryn-ht-tb-ac-broadwell 3.10ghz 7.1.1 448af3b4 168279 JASONGROSS-X230-ht-tb-nops-ivybridge 2.90ghz 6.3.0 c003b54 -168380 ashryn-noht-notb-ac-broadwell 2.60ghz 7.1.1 5397ade1 168628 ashryn-noht-notb-noac-broadwell 2.60ghz 7.1.1 cac291e0 +174368 ashryn-noht-notb-ac-broadwell 2.50ghz 7.1.1 d7ad9528 187992 jgross-Leopard-WS-ht-tb-nops-haswell 3.70ghz 5.4.0 19a7001 217869 JASONGROSS-X230-ht-tb-nops-core-avx-i 2.90ghz 4.8 c003b54 diff --git a/src/Specific/X25519/x25519_test.c b/src/Specific/X25519/x25519_test.c new file mode 100644 index 000000000..1a4334932 --- /dev/null +++ b/src/Specific/X25519/x25519_test.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdint.h> + +void crypto_scalarmult(uint8_t *out, const uint8_t *secret, const uint8_t *basepoint); + +const uint8_t expected[32] = {0x89, 0x16, 0x1f, 0xde, 0x88, 0x7b, 0x2b, 0x53, 0xde, 0x54, 0x9a, 0xf4, 0x83, 0x94, 0x01, 0x06, 0xec, 0xc1, 0x14, 0xd6, 0x98, 0x2d, 0xaa, 0x98, 0x25, 0x6d, 0xe2, 0x3b, 0xdf, 0x77, 0x66, 0x1a}; +const uint8_t basepoint[32] = {9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +int main() { + uint8_t a[32] = {0}, b[32] = {0}; + uint8_t* in = a; + uint8_t* out = b; + a[0] = 1; + + for (int i = 0; i < 200; i++) { + crypto_scalarmult(out, in, basepoint); + uint8_t* t = out; + out = in; + in = t; + } + + for (int i = 0; i < 32; i++) { + if (in[i] != expected[i]) { + return (i+1); + } + } + return 0; +} |