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 #include #include @@ -302,6 +305,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);