Botan 3.3.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::DL_PublicKey Class Referencefinal

#include <dl_scheme.h>

Public Member Functions

bool check_key (RandomNumberGenerator &rng, bool strong) const
 
std::vector< uint8_t > DER_encode () const
 
 DL_PublicKey (const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits, DL_Group_Format format)
 
 DL_PublicKey (const DL_Group &group, const BigInt &public_key)
 
size_t estimated_strength () const
 
const BigIntget_int_field (std::string_view algo_name, std::string_view field) const
 
const DL_Groupgroup () const
 
size_t p_bits () const
 
const BigIntpublic_key () const
 
std::vector< uint8_t > public_key_as_bytes () const
 

Detailed Description

Definition at line 21 of file dl_scheme.h.

Constructor & Destructor Documentation

◆ DL_PublicKey() [1/2]

Botan::DL_PublicKey::DL_PublicKey ( const DL_Group & group,
const BigInt & public_key )

Definition at line 38 of file dl_scheme.cpp.

38 :
39 m_group(group), m_public_key(public_key) {}
const BigInt & public_key() const
Definition dl_scheme.h:31
const DL_Group & group() const
Definition dl_scheme.h:29

◆ DL_PublicKey() [2/2]

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

Definition at line 41 of file dl_scheme.cpp.

43 :
44 m_group(alg_id.parameters(), format), m_public_key(decode_single_bigint(key_bits)) {}

Member Function Documentation

◆ check_key()

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

Definition at line 58 of file dl_scheme.cpp.

58 {
59 return m_group.verify_group(rng, strong) && m_group.verify_public_element(m_public_key);
60}
bool verify_public_element(const BigInt &y) const
Definition dl_group.cpp:324
bool verify_group(RandomNumberGenerator &rng, bool strong=true) const
Definition dl_group.cpp:373

References Botan::DL_Group::verify_group(), and Botan::DL_Group::verify_public_element().

◆ DER_encode()

std::vector< uint8_t > Botan::DL_PublicKey::DER_encode ( ) const

Definition at line 52 of file dl_scheme.cpp.

52 {
53 std::vector<uint8_t> output;
54 DER_Encoder(output).encode(m_public_key);
55 return output;
56}

References Botan::DER_Encoder::encode().

◆ estimated_strength()

size_t Botan::DL_PublicKey::estimated_strength ( ) const

Definition at line 62 of file dl_scheme.cpp.

62 {
63 return m_group.estimated_strength();
64}
size_t estimated_strength() const
Definition dl_group.cpp:470

References Botan::DL_Group::estimated_strength().

◆ get_int_field()

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

Definition at line 103 of file dl_scheme.cpp.

103 {
104 if(field == "p") {
105 return m_group.get_p();
106 } else if(field == "q") {
107 return m_group.get_q();
108 } else if(field == "g") {
109 return m_group.get_g();
110 } else if(field == "y") {
111 return m_public_key;
112 } else {
113 throw Unknown_PK_Field_Name(algo, field);
114 }
115}
const BigInt & get_p() const
Definition dl_group.cpp:426
const BigInt & get_g() const
Definition dl_group.cpp:433
const BigInt & get_q() const
Definition dl_group.cpp:440

References Botan::DL_Group::get_g(), Botan::DL_Group::get_p(), and Botan::DL_Group::get_q().

◆ group()

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

Definition at line 29 of file dl_scheme.h.

29{ return m_group; }

◆ p_bits()

size_t Botan::DL_PublicKey::p_bits ( ) const

Definition at line 66 of file dl_scheme.cpp.

66 {
67 return m_group.p_bits();
68}
size_t p_bits() const
Definition dl_group.cpp:452

References Botan::DL_Group::p_bits().

◆ public_key()

const BigInt & Botan::DL_PublicKey::public_key ( ) const
inline

Definition at line 31 of file dl_scheme.h.

31{ return m_public_key; }

◆ public_key_as_bytes()

std::vector< uint8_t > Botan::DL_PublicKey::public_key_as_bytes ( ) const

Definition at line 46 of file dl_scheme.cpp.

46 {
47 std::vector<uint8_t> bits(m_group.p_bytes());
48 BigInt::encode_1363(bits.data(), bits.size(), m_public_key);
49 return bits;
50}
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition big_code.cpp:105
size_t p_bytes() const
Definition dl_group.cpp:456

References Botan::BigInt::encode_1363(), and Botan::DL_Group::p_bytes().


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