aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@mit.edu>2017-07-02 19:04:11 -0400
committerGravatar Andres Erbsen <andreser@mit.edu>2017-07-02 19:04:11 -0400
commit6c558bd2f52e109b544c38f489fd7e1b9b2933ca (patch)
tree51c1af7a13a26ed536772dcebfa110a56f482e79 /src
parentd7ad9528319596298b80e450e5a2eb87610d2fcf (diff)
X25519 test (passed on first try)
Diffstat (limited to 'src')
-rw-r--r--src/Specific/NISTP256/AMD64/measurements.txt2
-rw-r--r--src/Specific/X25519/C64/measurements.txt2
-rw-r--r--src/Specific/X25519/x25519_test.c28
3 files changed, 30 insertions, 2 deletions
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;
+}