summaryrefslogtreecommitdiff
path: root/validat9.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-12-24 17:17:32 -0500
committerGitHub <noreply@github.com>2018-12-24 17:17:32 -0500
commitd62674b56145b6988cd0a9d8a658dff7cb6d8ec8 (patch)
treea30dc4f20697961ba0f347da15a112e38d88cfab /validat9.cpp
parent2ba3c1fc73ff490fa335ae649f3ab42e762369f8 (diff)
downloadcryptopp-git-d62674b56145b6988cd0a9d8a658dff7cb6d8ec8.tar.gz
Add ed25519 (GH #764, PR #767)
Add ed25519
Diffstat (limited to 'validat9.cpp')
-rw-r--r--validat9.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/validat9.cpp b/validat9.cpp
index 854aa82f..735afe51 100644
--- a/validat9.cpp
+++ b/validat9.cpp
@@ -32,6 +32,11 @@
#include "pubkey.h"
#include "eccrypto.h"
+// Curve25519
+#include "xed25519.h"
+#include "donna.h"
+#include "naclite.h"
+
#include <iostream>
#include <iomanip>
#include <sstream>
@@ -667,5 +672,33 @@ bool ValidateESIGN()
return pass;
}
+bool ValidateEd25519()
+{
+ std::cout << "\ned25519 validation suite running...\n\n";
+ bool pass = true, fail;
+
+ const char plain[] = "test";
+ const byte signature[] =
+ "\x91\x12\x44\x91\xA5\x99\xF8\x49\xBA\xB2\xC4\xF2\xBA\x0B\xAA\x99"
+ "\xC8\xC5\xF5\x19\xDC\x07\xD4\x4C\xF7\x31\xDE\x2F\x2B\x81\xB2\x81"
+ "\xF6\xA7\xDE\x33\x29\xCA\x45\xAC\x69\x2A\x80\xB7\xDB\x7F\x07\x37"
+ "\x77\xC4\xBF\xC5\x45\x79\x3A\xAC\xB5\x16\xAE\x4E\xD9\x16\x95\x0E";
+
+ FileSource keys(DataDir("TestData/ed25519.dat").c_str(), true, new HexDecoder);
+ ed25519::Signer signer(keys);
+ ed25519::Verifier verifier(signer);
+
+ fail = !SignatureValidate(signer, verifier);
+ pass = pass && !fail;
+
+ fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength());
+ pass = pass && !fail;
+
+ std::cout << (fail ? "FAILED " : "passed ");
+ std::cout << "verification check against test vector\n";
+
+ return pass;
+}
+
NAMESPACE_END // Test
NAMESPACE_END // CryptoPP