Add test data from bug report (GH #876)

master
Jeffrey Walton 2019-08-24 18:00:03 -04:00
parent f78c3c00d2
commit 72f2b72920
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,9 @@
#include "xtrcrypt.h" #include "xtrcrypt.h"
#include "eccrypto.h" #include "eccrypto.h"
#include "hex.h"
#include "base64.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -302,6 +305,20 @@ bool ValidateElGamal()
{ {
std::cout << "\nElGamal validation suite running...\n\n"; std::cout << "\nElGamal validation suite running...\n\n";
bool pass = true; 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); FileSource fc(DataDir("TestData/elgc1024.dat").c_str(), true, new HexDecoder);
ElGamalDecryptor privC(fc); ElGamalDecryptor privC(fc);