From 77923a291a5c993cca5c11c9b7dc00891d88bd8e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 11 Dec 2018 16:17:56 -0500 Subject: Add Langley's curve25519 (GH #761, PR# 762) --- validat0.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 16 deletions(-) (limited to 'validat0.cpp') diff --git a/validat0.cpp b/validat0.cpp index 1e2fc9b5..e4138bd5 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -21,6 +21,11 @@ #include "gzip.h" #include "zlib.h" +//curve25519 +#include "xed25519.h" +#include "donna.h" +#include "naclite.h" + #include #include #include @@ -41,12 +46,11 @@ NAMESPACE_BEGIN(Test) // Issue 64: "PolynomialMod2::operator<<=", http://github.com/weidai11/cryptopp/issues/64 bool TestPolynomialMod2() { - bool pass1 = true, pass2 = true, pass3 = true; - std::cout << "\nTesting PolynomialMod2 bit operations...\n\n"; + bool pass1 = true, pass2 = true, pass3 = true; - static const unsigned int start = 0; - static const unsigned int stop = 4 * WORD_BITS + 1; + const unsigned int start = 0; + const unsigned int stop = 4 * WORD_BITS + 1; for (unsigned int i = start; i < stop; i++) { @@ -424,10 +428,54 @@ bool TestCompressors() return !fail1 && !fail2 && !fail3; } +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