Botan 3.14.1
Crypto and TLS for C&
Botan::DL_PrivateKey Class Referencefinal

#include <dl_scheme.h>

Public Member Functions

bool check_key (RandomNumberGenerator &rng, bool strong) const
secure_vector< uint8_t > DER_encode () const
 DL_PrivateKey (const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits, DL_Group_Format format)
 DL_PrivateKey (const DL_Group &group, const BigInt &private_key)
 DL_PrivateKey (const DL_Group &group, RandomNumberGenerator &rng)
const BigInt & get_int_field (std::string_view algo_name, std::string_view field) const
const DL_Group & group () const
size_t max_private_key_bits () const
const BigInt & private_key () const
std::shared_ptr< DL_PublicKey > public_key () const
secure_vector< uint8_t > raw_private_key_bits () const

Detailed Description

Definition at line 49 of file dl_scheme.h.

Constructor & Destructor Documentation

◆ DL_PrivateKey() [1/3]

Botan::DL_PrivateKey::DL_PrivateKey ( const DL_Group & group,
const BigInt & private_key )

Definition at line 100 of file dl_scheme.cpp.

100 :
101 m_group(group),
102 m_private_key(check_dl_private_key_input(private_key, m_group)),
103 m_max_private_key_bits(dl_private_key_max_bits(m_private_key, m_group)),
104 m_public_key(m_group.power_g_p(m_private_key, m_max_private_key_bits)) {
105 CT::unpoison_all(m_private_key, m_public_key);
106}
const BigInt & private_key() const
Definition dl_scheme.h:72
const DL_Group & group() const
Definition dl_scheme.h:67
constexpr void unpoison_all(const Ts &... ts)
Definition ct_utils.h:207

References group(), private_key(), and Botan::CT::unpoison_all().

◆ DL_PrivateKey() [2/3]

Botan::DL_PrivateKey::DL_PrivateKey ( const DL_Group & group,
RandomNumberGenerator & rng )

Definition at line 108 of file dl_scheme.cpp.

108 :
109 m_group(group),
110 m_private_key(generate_private_dl_key(group, rng)),
111 m_max_private_key_bits(dl_private_key_max_bits(m_private_key, m_group)),
112 m_public_key(m_group.power_g_p(m_private_key, m_max_private_key_bits)) {
113 CT::unpoison_all(m_private_key, m_public_key);
114}

References group(), and Botan::CT::unpoison_all().

◆ DL_PrivateKey() [3/3]

Botan::DL_PrivateKey::DL_PrivateKey ( const AlgorithmIdentifier & alg_id,
std::span< const uint8_t > key_bits,
DL_Group_Format format )

Definition at line 116 of file dl_scheme.cpp.

118 :
119 m_group(alg_id.parameters(), format),
120 m_private_key(check_dl_private_key_input(decode_single_bigint(key_bits), m_group)),
121 m_max_private_key_bits(dl_private_key_max_bits(m_private_key, m_group)),
122 m_public_key(m_group.power_g_p(m_private_key, m_max_private_key_bits)) {
123 CT::unpoison_all(m_private_key, m_public_key);
124}

References Botan::CT::unpoison_all().

Member Function Documentation

◆ check_key()

bool Botan::DL_PrivateKey::check_key ( RandomNumberGenerator & rng,
bool strong ) const

Definition at line 134 of file dl_scheme.cpp.

134 {
135 return m_group.verify_group(rng, strong) && m_group.verify_private_element(m_private_key);
136}

◆ DER_encode()

secure_vector< uint8_t > Botan::DL_PrivateKey::DER_encode ( ) const

DER encode the private key

Definition at line 126 of file dl_scheme.cpp.

126 {
127 return DER_Encoder().encode(m_private_key).get_contents();
128}

References Botan::DER_Encoder::encode(), and Botan::DER_Encoder::get_contents().

◆ get_int_field()

const BigInt & Botan::DL_PrivateKey::get_int_field ( std::string_view algo_name,
std::string_view field ) const

Definition at line 156 of file dl_scheme.cpp.

156 {
157 if(field == "p") {
158 return m_group.get_p();
159 } else if(field == "q") {
160 return m_group.get_q();
161 } else if(field == "g") {
162 return m_group.get_g();
163 } else if(field == "x") {
164 return m_private_key;
165 } else if(field == "y") {
166 return m_public_key;
167 } else {
168 throw Unknown_PK_Field_Name(algo, field);
169 }
170}

◆ group()

const DL_Group & Botan::DL_PrivateKey::group ( ) const
inline

Return the group this key operates in

Definition at line 67 of file dl_scheme.h.

67{ return m_group; }

Referenced by DL_PrivateKey(), and DL_PrivateKey().

◆ max_private_key_bits()

size_t Botan::DL_PrivateKey::max_private_key_bits ( ) const
inline

Return a public upper bound on the bit length of the private key, for use as the exponent length when exponentiating by it

Definition at line 78 of file dl_scheme.h.

78{ return m_max_private_key_bits; }

◆ private_key()

const BigInt & Botan::DL_PrivateKey::private_key ( ) const
inline

Return the integer value of the private key

Definition at line 72 of file dl_scheme.h.

72{ return m_private_key; }

Referenced by DL_PrivateKey().

◆ public_key()

std::shared_ptr< DL_PublicKey > Botan::DL_PrivateKey::public_key ( ) const

Return a new shared_ptr of the associated public key

Definition at line 138 of file dl_scheme.cpp.

138 {
139 return std::make_shared<DL_PublicKey>(m_group, m_public_key);
140}

◆ raw_private_key_bits()

secure_vector< uint8_t > Botan::DL_PrivateKey::raw_private_key_bits ( ) const

Return the raw serialization of the private key

Definition at line 130 of file dl_scheme.cpp.

130 {
131 return m_private_key.serialize<secure_vector<uint8_t>>();
132}
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

The documentation for this class was generated from the following files: