Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

elgamal.h
Go to the documentation of this file.
1 /*
2 * ElGamal
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_ELGAMAL_H__
9 #define BOTAN_ELGAMAL_H__
10
11 #include <botan/dl_algo.h>
12
13 namespace Botan {
14
15 /**
16 * ElGamal Public Key
17 */
18 class BOTAN_DLL ElGamal_PublicKey : public virtual DL_Scheme_PublicKey
19 {
20 public:
21 std::string algo_name() const override { return "ElGamal"; }
22 DL_Group::Format group_format() const override { return DL_Group::ANSI_X9_42; }
23
24 /**
25 * Load a public key.
26 * @param alg_id the X.509 algorithm identifier
27 * @param key_bits DER encoded public key bits
28 */
29 ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
30 const std::vector<uint8_t>& key_bits) :
31 DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
32 {}
33
34 /**
35 * Create a public key.
36 * @param group the underlying DL group
37 * @param y the public value y = g^x mod p
38 */
39 ElGamal_PublicKey(const DL_Group& group, const BigInt& y);
40
41 std::unique_ptr<PK_Ops::Encryption>
42 create_encryption_op(RandomNumberGenerator& rng,
43 const std::string& params,
44 const std::string& provider) const override;
45
46 protected:
47 ElGamal_PublicKey() = default;
48 };
49
50 /**
51 * ElGamal Private Key
52 */
53 class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
54 public virtual DL_Scheme_PrivateKey
55 {
56 public:
57 bool check_key(RandomNumberGenerator& rng, bool) const override;
58
59 /**
60 * Load a private key.
61 * @param alg_id the X.509 algorithm identifier
62 * @param key_bits DER encoded key bits in ANSI X9.42 format
63 */
64 ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
65 const secure_vector<uint8_t>& key_bits);
66
67 /**
68 * Create a private key.
69 * @param rng random number generator to use
70 * @param group the group to be used in the key
71 * @param priv_key the key's secret value (or if zero, generate a new key)
72 */
73 ElGamal_PrivateKey(RandomNumberGenerator& rng,
74 const DL_Group& group,
75 const BigInt& priv_key = 0);
76
77 std::unique_ptr<PK_Ops::Decryption>
78 create_decryption_op(RandomNumberGenerator& rng,
79 const std::string& params,
80 const std::string& provider) const override;
81 };
82
83 }
84
85 #endif
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:95
Botan::BigInt
Definition: bigint.h:23
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::ElGamal_PublicKey::group_format
DL_Group::Format group_format() const override
Definition: elgamal.h:22
Botan::ElGamal_PublicKey
Definition: elgamal.h:18
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:19
Botan::ElGamal_PrivateKey
Definition: elgamal.h:53
Botan::DL_Group
Definition: dl_group.h:20
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::DL_Group::Format
Format
Definition: dl_group.h:45
Botan::ElGamal_PublicKey::ElGamal_PublicKey
ElGamal_PublicKey(const AlgorithmIdentifier &alg_id, const std::vector< uint8_t > &key_bits)
Definition: elgamal.h:29
Botan
Definition: alg_id.cpp:13
Botan::DL_Group::ANSI_X9_42
Definition: dl_group.h:46
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::ElGamal_PublicKey::algo_name
std::string algo_name() const override
Definition: elgamal.h:21