From a2c06c35b84f8d8a585cc9479cc6d0f840f4f53e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 24 Aug 2019 16:17:03 -0400 Subject: Use ASN1::elGamal() in ElGamal keys (GH #876) --- elgamal.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/elgamal.h b/elgamal.h index b5d7523e..a7a892c0 100644 --- a/elgamal.h +++ b/elgamal.h @@ -12,7 +12,9 @@ #include "gfpcrypt.h" #include "pubkey.h" #include "misc.h" +#include "oids.h" #include "dsa.h" +#include "asn.h" NAMESPACE_BEGIN(CryptoPP) @@ -114,6 +116,24 @@ protected: const DL_SymmetricEncryptionAlgorithm & GetSymmetricEncryptionAlgorithm() const {return *this;} }; +template +struct DL_PublicKey_ElGamal : public BASE +{ + virtual ~DL_PublicKey_ElGamal() {} + virtual OID GetAlgorithmID() const { + return ASN1::elGamal(); + } +}; + +template +struct DL_PrivateKey_ElGamal : public BASE +{ + virtual ~DL_PrivateKey_ElGamal() {} + virtual OID GetAlgorithmID() const { + return ASN1::elGamal(); + } +}; + /// \brief ElGamal key agreement and encryption schemes keys /// \details The ElGamalKeys class used DL_PrivateKey_GFP_OldFormat and DL_PublicKey_GFP_OldFormat /// for the PrivateKey and PublicKey typedef from about Crypto++ 1.0 through Crypto++ 5.6.5. @@ -122,8 +142,8 @@ protected: struct ElGamalKeys { typedef DL_CryptoKeys_GFP::GroupParameters GroupParameters; - typedef DL_CryptoKeys_GFP::PrivateKey PrivateKey; - typedef DL_CryptoKeys_GFP::PublicKey PublicKey; + typedef DL_PrivateKey_ElGamal PrivateKey; + typedef DL_PublicKey_ElGamal PublicKey; }; /// \brief ElGamal encryption scheme with non-standard padding -- cgit v1.2.1