summaryrefslogtreecommitdiff
path: root/elgamal.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-08-24 16:17:03 -0400
committerJeffrey Walton <noloader@gmail.com>2019-08-24 16:17:03 -0400
commita2c06c35b84f8d8a585cc9479cc6d0f840f4f53e (patch)
tree11391d8e540364c2a2e1485f3b20740187cd4787 /elgamal.h
parenta7e83e6bf4c31c1b5d6c7168692b689a3e02ed86 (diff)
downloadcryptopp-git-a2c06c35b84f8d8a585cc9479cc6d0f840f4f53e.tar.gz
Use ASN1::elGamal() in ElGamal keys (GH #876)
Diffstat (limited to 'elgamal.h')
-rw-r--r--elgamal.h24
1 files 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 <class BASE>
+struct DL_PublicKey_ElGamal : public BASE
+{
+ virtual ~DL_PublicKey_ElGamal() {}
+ virtual OID GetAlgorithmID() const {
+ return ASN1::elGamal();
+ }
+};
+
+template <class BASE>
+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<DL_CryptoKeys_GFP::PrivateKey> PrivateKey;
+ typedef DL_PublicKey_ElGamal<DL_CryptoKeys_GFP::PublicKey> PublicKey;
};
/// \brief ElGamal encryption scheme with non-standard padding