diff options
author | Jeffrey Walton <noloader@gmail.com> | 2019-08-24 18:00:03 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2019-08-24 18:00:03 -0400 |
commit | 72f2b72920eac8b8d8dcf8529f85d652624db7f7 (patch) | |
tree | 5ced319dd276ccc7e2ee4d18bb62d5b7303c3ed6 /validat8.cpp | |
parent | f78c3c00d20fa3cc994883e27788bb85f9211984 (diff) | |
download | cryptopp-git-72f2b72920eac8b8d8dcf8529f85d652624db7f7.tar.gz |
Add test data from bug report (GH #876)
Diffstat (limited to 'validat8.cpp')
-rw-r--r-- | validat8.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/validat8.cpp b/validat8.cpp index 179a6029..7396bc79 100644 --- a/validat8.cpp +++ b/validat8.cpp @@ -22,6 +22,9 @@ #include "xtrcrypt.h"
#include "eccrypto.h"
+#include "hex.h"
+#include "base64.h"
+
#include <iostream>
#include <iomanip>
#include <sstream>
@@ -303,6 +306,20 @@ bool ValidateElGamal() std::cout << "\nElGamal validation suite running...\n\n";
bool pass = true;
{
+ // Data from https://github.com/weidai11/cryptopp/issues/876.
+ // The interesting thing about this data is, the public key
+ // has 3 ASN.1 Integer types, and not 4 Integer types.
+ const std::string encodedPublicKey =
+ "MHYwTwYGKw4HAgEBMEUCIQDebUvQDd9UPMmD27BJ ovZSIgWfexL0SWkfJQPMLsJvMwIgDy/kEthwO6Q+"
+ "L8XHnzumnEKs+txH8QkQD+M/8u82ql0DIwACIAY6 rfW+BTcRZ9QAJovgoB8DgNLJ8ocqOeF4nEBB0DHH";
+ StringSource decodedPublicKey(encodedPublicKey, true, new Base64Decoder);
+
+ ElGamal::PublicKey publicKey;
+ publicKey.Load(decodedPublicKey);
+
+ pass = publicKey.Validate(GlobalRNG(), 3) && pass;
+ }
+ {
FileSource fc(DataDir("TestData/elgc1024.dat").c_str(), true, new HexDecoder);
ElGamalDecryptor privC(fc);
ElGamalEncryptor pubC(privC);
|