From 235c615a10b418974354c38218bc29beda2ae7e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 14 Dec 2018 12:15:58 -0500 Subject: Make TestCurve25519 available in Release builds --- validat7.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'validat7.cpp') diff --git a/validat7.cpp b/validat7.cpp index 91741651..b429d89d 100644 --- a/validat7.cpp +++ b/validat7.cpp @@ -22,10 +22,14 @@ #include "xtr.h" #include "hmqv.h" #include "pubkey.h" -#include "xed25519.h" #include "xtrcrypt.h" #include "eccrypto.h" +// Curve25519 +#include "xed25519.h" +#include "donna.h" +#include "naclite.h" + #include #include #include @@ -352,5 +356,55 @@ bool ValidateEC2N_Agreement() return pass; } +// TestCurve25519 is slighty more comprehensive than ValidateX25519 +// because it cross-validates against Bernstein's NaCL library. +// TestCurve25519 called in Debug builds. +bool TestCurve25519() +{ + std::cout << "\nTesting curve25519 Key Agreements...\n\n"; + const unsigned int AGREE_COUNT = 64; + bool pass = true; + + SecByteBlock priv1(32), priv2(32), pub1(32), pub2(32), share1(32), share2(32); + for (unsigned int i=0; i