Botan 2.19.5 Crypto and TLS for C&

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/pk_keys.h>
13
14 namespace Botan {
15
16/**
17* This class represents discrete logarithm (DL) public keys.
18*/
19 class BOTAN_PUBLIC_API(2,0) 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 DL domain parameters of this key.
36 * @return DL domain parameters of this key
37 */
38 const DL_Group& get_group() const { return m_group; }
39
40 /**
41 * Get the public value y with y = g^x mod p where x is the secret key.
42 */
43 const BigInt& get_y() const { return m_y; }
44
45 /**
46 * Get the prime p of the underlying DL group.
47 * @return prime p
48 */
49 const BigInt& group_p() const { return m_group.get_p(); }
50
51 /**
52 * Get the prime q of the underlying DL group.
53 * @return prime q
54 */
55 const BigInt& group_q() const { return m_group.get_q(); }
56
57 /**
58 * Get the generator g of the underlying DL group.
59 * @return generator g
60 */
61 const BigInt& group_g() const { return m_group.get_g(); }
62
63 /**
64 * Get the underlying groups encoding format.
65 * @return encoding format
66 */
67 virtual DL_Group::Format group_format() const = 0;
68
69 size_t key_length() const override;
70 size_t estimated_strength() const override;
71
72 DL_Scheme_PublicKey& operator=(const DL_Scheme_PublicKey& other) = default;
73
74 protected:
75 DL_Scheme_PublicKey() = default;
76
77 /**
78 * Create a public key.
79 * @param alg_id the X.509 algorithm identifier
80 * @param key_bits DER encoded public key bits
81 * @param group_format the underlying groups encoding format
82 */
83 DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id,
84 const std::vector<uint8_t>& key_bits,
85 DL_Group::Format group_format);
86
87 DL_Scheme_PublicKey(const DL_Group& group, const BigInt& y);
88
89 /**
90 * The DL public key
91 */
92 BigInt m_y;
93
94 /**
95 * The DL group
96 */
97 DL_Group m_group;
98 };
99
100/**
101* This class represents discrete logarithm (DL) private keys.
102*/
103 class BOTAN_PUBLIC_API(2,0) DL_Scheme_PrivateKey : public virtual DL_Scheme_PublicKey,
104 public virtual Private_Key
105 {
106 public:
107 bool check_key(RandomNumberGenerator& rng, bool) const override;
108
109 /**
110 * Get the secret key x.
111 * @return secret key
112 */
113 const BigInt& get_x() const { return m_x; }
114
115 secure_vector<uint8_t> private_key_bits() const override;
116
117 DL_Scheme_PrivateKey& operator=(const DL_Scheme_PrivateKey& other) = default;
118
119 protected:
120 /**
121 * Create a private key.
122 * @param alg_id the X.509 algorithm identifier
123 * @param key_bits DER encoded private key bits
124 * @param group_format the underlying groups encoding format
125 */
126 DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id,
127 const secure_vector<uint8_t>& key_bits,
128 DL_Group::Format group_format);
129
130 DL_Scheme_PrivateKey() = default;
131
132 /**
133 * The DL private key
134 */
135 BigInt m_x;
136 };
137
138}
139
140#endif
Botan::AlgorithmIdentifier
Definition: asn1_obj.h:430
Botan::BigInt
Definition: bigint.h:25
Botan::DL_Group
Definition: dl_group.h:30
Botan::DL_Group::Format
Format
Definition: dl_group.h:40
Botan::DL_Scheme_PrivateKey
Definition: dl_algo.h:105
Botan::DL_Scheme_PrivateKey::operator=
DL_Scheme_PrivateKey & operator=(const DL_Scheme_PrivateKey &other)=default
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:135
Botan::DL_Scheme_PrivateKey::get_x
const BigInt & get_x() const
Definition: dl_algo.h:113
Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey
DL_Scheme_PrivateKey()=default
Botan::DL_Scheme_PublicKey
Definition: dl_algo.h:20
Botan::DL_Scheme_PublicKey::group_p
const BigInt & group_p() const
Definition: dl_algo.h:49
Botan::DL_Scheme_PublicKey::m_y
BigInt m_y
Definition: dl_algo.h:92
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:97
Botan::DL_Scheme_PublicKey::get_group
const DL_Group & get_group() const
Definition: dl_algo.h:38
Botan::DL_Scheme_PublicKey::get_domain
const DL_Group & get_domain() const
Definition: dl_algo.h:32
Botan::DL_Scheme_PublicKey::group_q
const BigInt & group_q() const
Definition: dl_algo.h:55
Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey
DL_Scheme_PublicKey()=default
Botan::DL_Scheme_PublicKey::get_y
const BigInt & get_y() const
Definition: dl_algo.h:43
Botan::DL_Scheme_PublicKey::operator=
DL_Scheme_PublicKey & operator=(const DL_Scheme_PublicKey &other)=default
Botan::DL_Scheme_PublicKey::group_format
virtual DL_Group::Format group_format() const =0
Botan::DL_Scheme_PublicKey::group_g
const BigInt & group_g() const
Definition: dl_algo.h:61
Botan::Private_Key
Definition: pk_keys.h:181
Botan::Public_Key
Definition: pk_keys.h:29
Botan::RandomNumberGenerator
Definition: rng.h:26
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65