Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

dl_algo.h
Go to the documentation of this file.
1 /*
2 * DL Scheme
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_DL_ALGO_H__
9 #define BOTAN_DL_ALGO_H__
10
11 #include <botan/dl_group.h>
12 #include <botan/x509_key.h>
13
14 namespace Botan {
15
16 /**
17 * This class represents discrete logarithm (DL) public keys.
18 */
19 class BOTAN_DLL DL_Scheme_PublicKey : public virtual Public_Key
20 {
21 public:
22 bool check_key(RandomNumberGenerator& rng, bool) const override;
23
24 AlgorithmIdentifier algorithm_identifier() const override;
25
26 std::vector<uint8_t> public_key_bits() const override;
27
28 /**
29 * Get the DL domain parameters of this key.
30 * @return DL domain parameters of this key
31 */
32 const DL_Group& get_domain() const { return m_group; }
33
34 /**
35 * Get the public value y with y = g^x mod p where x is the secret key.
36 */
37 const BigInt& get_y() const { return m_y; }
38
39 /**
40 * Get the prime p of the underlying DL group.
41 * @return prime p
42 */
43 const BigInt& group_p() const { return m_group.get_p(); }
44
45 /**
46 * Get the prime q of the underlying DL group.
47 * @return prime q
48 */
49 const BigInt& group_q() const { return m_group.get_q(); }
50
51 /**
52 * Get the generator g of the underlying DL group.
53 * @return generator g
54 */
55 const BigInt& group_g() const { return m_group.get_g(); }
56
57 /**
58 * Get the underlying groups encoding format.
59 * @return encoding format
60 */
61 virtual DL_Group::Format group_format() const = 0;
62
63 size_t key_length() const override;
64 size_t estimated_strength() const override;
65
66 /**
67 * Create a public key.
68 * @param alg_id the X.509 algorithm identifier
69 * @param key_bits DER encoded public key bits
70 * @param group_format the underlying groups encoding format
71 */
72 DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
73 const std::vector<uint8_t>& key_bits,
74 DL_Group::Format group_format);
75
76 DL_Scheme_PublicKey& operator=(const DL_Scheme_PublicKey& other) = default;
77
78 protected:
79 DL_Scheme_PublicKey() = default;
80
81 /**
82 * The DL public key
83 */
84 BigInt m_y;
85
86 /**
87 * The DL group
88 */
89 DL_Group m_group;
90 };
91
92 /**
93 * This class represents discrete logarithm (DL) private keys.
94 */
95 class BOTAN_DLL DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
96 public virtual Private_Key
97 {
98 public:
99 bool check_key(RandomNumberGenerator& rng, bool) const override;
100
101 /**
102 * Get the secret key x.
103 * @return secret key
104 */
105 const BigInt& get_x() const { return m_x; }
106
107 secure_vector<uint8_t> private_key_bits() const override;
108
109 /**
110 * Create a private key.
111 * @param alg_id the X.509 algorithm identifier
112 * @param key_bits DER encoded private key bits
113 * @param group_format the underlying groups encoding format
114 */
115 DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
116 const secure_vector<uint8_t>& key_bits,
117 DL_Group::Format group_format);
118
119 DL_Scheme_PrivateKey& operator=(const DL_Scheme_PrivateKey& other) = default;
120
121 protected:
122 DL_Scheme_PrivateKey() = default;
123
124 /**
125 * The DL private key
126 */
127 BigInt m_x;
128 };
129
130 }
131
132 #endif
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:95
Botan::DL_Scheme_PrivateKey::get_x
const BigInt & get_x() const
Definition: dl_algo.h:105
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:127
Botan::BigInt
Definition: bigint.h:23
m_x
const BigInt & m_x
Definition: dsa.cpp:97
Botan::RandomNumberGenerator
Definition: rng.h:25
Botan::Private_Key
Definition: pk_keys.h:166
Botan::DL_Scheme_PublicKey::group_q
const BigInt & group_q() const
Definition: dl_algo.h:49
Botan::DL_Scheme_PublicKey::group_p
const BigInt & group_p() const
Definition: dl_algo.h:43
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:19
m_y
const BigInt & m_y
Definition: dsa.cpp:161
Botan::DL_Scheme_PublicKey::get_y
const BigInt & get_y() const
Definition: dl_algo.h:37
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::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89
Botan::DL_Scheme_PublicKey::get_domain
const DL_Group & get_domain() const
Definition: dl_algo.h:32
Botan::DL_Scheme_PublicKey::m_y
BigInt m_y
Definition: dl_algo.h:84
Botan
Definition: alg_id.cpp:13
Botan::Public_Key
Definition: pk_keys.h:24
Botan::AlgorithmIdentifier
Definition: alg_id.h:20
Botan::DL_Scheme_PublicKey::group_g
const BigInt & group_g() const
Definition: dl_algo.h:55