Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::DL_Scheme_PrivateKey Class Referenceabstract

`#include <dl_algo.h>`

Inheritance diagram for Botan::DL_Scheme_PrivateKey:

## Public Member Functions
virtual std::string | algo_name () const =0
AlgorithmIdentifier | algorithm_identifier () const override
bool | check_key (RandomNumberGenerator &rng, bool) const override
virtual std::unique_ptr< PK_Ops::Decryption > | create_decryption_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::Encryption > | create_encryption_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::KEM_Decryption > | create_kem_decryption_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::KEM_Encryption > | create_kem_encryption_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::Key_Agreement > | create_key_agreement_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::Signature > | create_signature_op (RandomNumberGenerator &rng, const std::string &params, const std::string &provider) const
virtual std::unique_ptr< PK_Ops::Verification > | create_verification_op (const std::string &params, const std::string &provider) const
| DL_Scheme_PrivateKey (const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits, DL_Group::Format group_format)
size_t | estimated_strength () const override
std::string | fingerprint (const std::string &alg="SHA") const
const DL_Group & | get_domain () const
virtual OID | get_oid () const
const BigInt & | get_x () const
const BigInt & | get_y () const
virtual DL_Group::Format | group_format () const =0
const BigInt & | group_g () const
const BigInt & | group_p () const
const BigInt & | group_q () const
size_t | key_length () const override
virtual size_t | message_part_size () const
virtual size_t | message_parts () const
DL_Scheme_PrivateKey & | operator= (const DL_Scheme_PrivateKey &other)=default
virtual AlgorithmIdentifier | pkcs8_algorithm_identifier () const
secure_vector< uint8_t > | private_key_bits () const override
secure_vector< uint8_t > | private_key_info () const
std::vector< uint8_t > | public_key_bits () const override
std::vector< uint8_t > | subject_public_key () const

## Protected Member Functions
| DL_Scheme_PrivateKey ()=default

## Protected Attributes
DL_Group | m_group
BigInt | m_x
BigInt | m_y

## Detailed Description

This class represents discrete logarithm (DL) private keys.

Definition at line 95 of file dl_algo.h.

## Constructor & Destructor Documentation

Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey | ( | const AlgorithmIdentifier & | alg_id,
|  | const secure_vector< uint8_t > & | key_bits,
|  | DL_Group::Format | group_format
| ) |  |

Create a private key.

Parameters

  alg_id | the X.509 algorithm identifier
  key_bits | DER encoded private key bits
  group_format | the underlying groups encoding format

Definition at line 51 of file dl_algo.cpp.

References Botan::DL_Group::BER_decode(), Botan::BER_Decoder::decode(), Botan::DL_Scheme_PublicKey::m_group, m_x, and Botan::AlgorithmIdentifier::parameters.

54 {
55 m_group.BER_decode(alg_id.parameters, format);
56
57 BER_Decoder(key_bits).decode(m_x);
58 }
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:127
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89
Botan::DL_Group::BER_decode
void BER_decode(const std::vector< uint8_t > &ber, Format format)
Definition: dl_group.cpp:285

Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey | ( |  | ) |
| protected default

## Member Function Documentation

virtual std::string Botan::Public_Key::algo_name | ( |  | ) | const
| pure virtual inherited

Get the name of the underlying public key scheme.

Returns
  name of the public key scheme

Implemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::TPM_PrivateKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::ECDSA_PublicKey, Botan::ECDH_PublicKey, Botan::GOST_3410_PublicKey, Botan::ECGDSA_PublicKey, Botan::ECKCDSA_PublicKey, Botan::RSA_PublicKey, Botan::McEliece_PublicKey, Botan::DH_PublicKey, Botan::DSA_PublicKey, Botan::ElGamal_PublicKey, and Botan::Curve25519_PublicKey.

Referenced by Botan::PKCS8::BER_encode(), Botan::TLS::Policy::check_peer_key_acceptable(), Botan::X509_Object::check_signature(), Botan::TLS::Handshake_State::choose_sig_format(), Botan::choose_sig_format(), Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::Private_Key::create_decryption_op(), Botan::Public_Key::create_encryption_op(), Botan::Private_Key::create_kem_decryption_op(), Botan::Public_Key::create_kem_encryption_op(), Botan::Private_Key::create_key_agreement_op(), Botan::Private_Key::create_signature_op(), Botan::Public_Key::create_verification_op(), Botan::Public_Key::get_oid(), Botan::TLS::Handshake_State::parse_sig_format(), Botan::PK_Decryptor_EME::PK_Decryptor_EME(), Botan::PK_Encryptor_EME::PK_Encryptor_EME(), Botan::PK_KEM_Decryptor::PK_KEM_Decryptor(), Botan::PK_KEM_Encryptor::PK_KEM_Encryptor(), Botan::PK_Key_Agreement::PK_Key_Agreement(), Botan::PK_Signer::PK_Signer(), Botan::PK_Verifier::PK_Verifier(), and Botan::verify_cert_constraints_valid_for_key_type().

AlgorithmIdentifier Botan::DL_Scheme_PublicKey::algorithm_identifier | ( |  | ) | const
| override virtual inherited

Returns
  X.509 AlgorithmIdentifier for this key

Implements Botan::Public_Key.

Definition at line 26 of file dl_algo.cpp.

References Botan::DL_Group::DER_encode(), Botan::Public_Key::get_oid(), Botan::DL_Scheme_PublicKey::group_format(), and Botan::DL_Scheme_PublicKey::m_group.

27 {
28 return AlgorithmIdentifier(get_oid(),
29 m_group.DER_encode(group_format()));
30 }
Botan::DL_Group::DER_encode
std::vector< uint8_t > DER_encode(Format format) const
Definition: dl_group.cpp:225
Botan::Public_Key::get_oid
virtual OID get_oid() const
Definition: pk_keys.cpp:30
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89
Botan::DL_Scheme_PublicKey::group_format
virtual DL_Group::Format group_format() const =0

bool Botan::DL_Scheme_PrivateKey::check_key | ( | RandomNumberGenerator & | rng,
|  | bool | strong
| ) |  | const
| override virtual

Test the key values for consistency.

Parameters

  rng | rng to use
  strong | whether to perform strong and lengthy version of the test

Returns
  true if the test is passed

Reimplemented from Botan::DL_Scheme_PublicKey.

Reimplemented in Botan::DSA_PrivateKey, and Botan::ElGamal_PrivateKey.

Definition at line 90 of file dl_algo.cpp.

References Botan::DL_Scheme_PublicKey::group_g(), Botan::DL_Scheme_PublicKey::group_p(), Botan::DL_Scheme_PublicKey::m_group, m_x, Botan::DL_Scheme_PublicKey::m_y, Botan::power_mod(), and Botan::DL_Group::verify_group().

Referenced by Botan::ElGamal_PrivateKey::check_key(), and Botan::DSA_PrivateKey::check_key().

92 {
93 const BigInt& p = group_p();
94 const BigInt& g = group_g();
95
96 if(m_y < 2 || m_y >= p || m_x < 2 || m_x >= p)
97 return false;
98 if(!m_group.verify_group(rng, strong))
99 return false;
100
101 if(!strong)
102 return true;
103
104 if(m_y != power_mod(g, m_x, p))
105 return false;
106
107 return true;
108 }
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:127
Botan::DL_Scheme_PublicKey::group_p
const BigInt & group_p() const
Definition: dl_algo.h:43
Botan::DL_Group::verify_group
bool verify_group(RandomNumberGenerator &rng, bool strong) const
Definition: dl_group.cpp:161
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89
Botan::DL_Scheme_PublicKey::m_y
BigInt m_y
Definition: dl_algo.h:84
Botan::power_mod
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
Definition: numthry.cpp:373
Botan::DL_Scheme_PublicKey::group_g
const BigInt & group_g() const
Definition: dl_algo.h:55

std::unique_ptr< PK_Ops::Decryption > Botan::Private_Key::create_decryption_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return an decryption operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::RSA_PrivateKey, and Botan::ElGamal_PrivateKey.

Definition at line 102 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_Decryptor_EME::PK_Decryptor_EME().

105 {
106 throw Lookup_Error(algo_name() + " does not support decryption");
107 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::Encryption > Botan::Public_Key::create_encryption_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return an encryption operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::RSA_PublicKey, and Botan::ElGamal_PublicKey.

Definition at line 79 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_Encryptor_EME::PK_Encryptor_EME().

82 {
83 throw Lookup_Error(algo_name() + " does not support encryption");
84 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::KEM_Decryption > Botan::Private_Key::create_kem_decryption_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return a KEM decryption operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::RSA_PrivateKey, and Botan::McEliece_PrivateKey.

Definition at line 110 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_KEM_Decryptor::PK_KEM_Decryptor().

113 {
114 throw Lookup_Error(algo_name() + " does not support KEM decryption");
115 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::KEM_Encryption > Botan::Public_Key::create_kem_encryption_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return a KEM encryption operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::RSA_PublicKey, and Botan::McEliece_PublicKey.

Definition at line 87 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_KEM_Encryptor::PK_KEM_Encryptor().

90 {
91 throw Lookup_Error(algo_name() + " does not support KEM encryption");
92 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::Key_Agreement > Botan::Private_Key::create_key_agreement_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return a key agreement operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::ECDH_PrivateKey, Botan::Curve25519_PrivateKey, and Botan::DH_PrivateKey.

Definition at line 126 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_Key_Agreement::PK_Key_Agreement().

129 {
130 throw Lookup_Error(algo_name() + " does not support key agreement");
131 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::Signature > Botan::Private_Key::create_signature_op | ( | RandomNumberGenerator & | rng,
|  | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return a signature operation for this key/params or throw

Parameters

  rng | a random number generator. The PK_Op may maintain a reference to the RNG and use it many times. The rng must outlive any operations which reference it.
  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::XMSS_WOTS_PrivateKey, Botan::XMSS_PrivateKey, Botan::TPM_PrivateKey, Botan::RSA_PrivateKey, Botan::GOST_3410_PrivateKey, Botan::ECDSA_PrivateKey, Botan::ECGDSA_PrivateKey, Botan::ECKCDSA_PrivateKey, and Botan::DSA_PrivateKey.

Definition at line 118 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_Signer::PK_Signer().

121 {
122 throw Lookup_Error(algo_name() + " does not support signatures");
123 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

std::unique_ptr< PK_Ops::Verification > Botan::Public_Key::create_verification_op | ( | const std::string & | params,
|  | const std::string & | provider
| ) |  | const
| virtual inherited

This is an internal library function exposed on key types. In almost all cases applications should use wrappers in pubkey.h

Return a verification operation for this key/params or throw

Parameters

  params | additional parameters
  provider | the provider to use

Reimplemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::RSA_PublicKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::GOST_3410_PublicKey, Botan::ECDSA_PublicKey, Botan::ECGDSA_PublicKey, Botan::ECKCDSA_PublicKey, and Botan::DSA_PublicKey.

Definition at line 95 of file pk_keys.cpp.

References Botan::Public_Key::algo_name().

Referenced by Botan::PK_Verifier::PK_Verifier().

97 {
98 throw Lookup_Error(algo_name() + " does not support verification");
99 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0

size_t Botan::DL_Scheme_PublicKey::estimated_strength | ( |  | ) | const
| override virtual inherited

Return the estimated strength of the underlying key against the best currently known attack. Note that this ignores anything but pure attacks against the key itself and do not take into account padding schemes, usage mistakes, etc which might reduce the strength. However it does suffice to provide an upper bound.

Returns
  estimated strength in bits

Implements Botan::Public_Key.

Definition at line 21 of file dl_algo.cpp.

References Botan::dl_work_factor(), and Botan::DL_Scheme_PublicKey::key_length().

22 {
23 return dl_work_factor(key_length());
24 }
Botan::DL_Scheme_PublicKey::key_length
size_t key_length() const override
Definition: dl_algo.cpp:16
Botan::dl_work_factor
size_t dl_work_factor(size_t bits)
Definition: workfactor.cpp:34

std::string Botan::Private_Key::fingerprint | ( | const std::string & | alg = `"SHA"` | ) | const
| inherited

Returns
  Hash of the PKCS #8 encoding for this key object

Definition at line 57 of file pk_keys.cpp.

References Botan::HashFunction::create(), hash, Botan::hex_encode(), and Botan::Private_Key::private_key_bits().

Referenced by Botan::Certificate_Store_In_SQL::find_certs_for_key(), Botan::Certificate_Store_In_SQL::insert_key(), and Botan::Certificate_Store_In_SQL::remove_key().

58 {
59 secure_vector<uint8_t> buf = private_key_bits();
60 std::unique_ptr<HashFunction> hash(HashFunction::create(alg));
61 hash->update(buf);
62 const auto hex_print = hex_encode(hash->final());
63
64 std::string formatted_print;
65
66 for(size_t i = 0; i != hex_print.size(); i += 2)
67 {
68 formatted_print.push_back(hex_print[i]);
69 formatted_print.push_back(hex_print[i+1]);
70
71 if(i != hex_print.size() - 2)
72 formatted_print.push_back(':');
73 }
74
75 return formatted_print;
76 }
Botan::Private_Key::private_key_bits
virtual secure_vector< uint8_t > private_key_bits() const =0
Botan::HashFunction::create
static std::unique_ptr< HashFunction > create(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:93
Botan::hex_encode
void hex_encode(char output[], const uint8_t input[], size_t input_length, bool uppercase)
Definition: hex.cpp:14
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

const DL_Group& Botan::DL_Scheme_PublicKey::get_domain | ( |  | ) | const
| inline inherited

Get the DL domain parameters of this key.

Returns
  DL domain parameters of this key

Definition at line 32 of file dl_algo.h.

32 { return m_group; }
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89

OID Botan::Public_Key::get_oid | ( |  | ) | const
| virtual inherited

Get the OID of the underlying public key scheme.

Returns
  OID of the public key scheme

Reimplemented in Botan::XMSS_WOTS_Addressed_PublicKey.

Definition at line 30 of file pk_keys.cpp.

References Botan::Public_Key::algo_name(), and Botan::OIDS::lookup().

Referenced by Botan::DL_Scheme_PublicKey::algorithm_identifier(), Botan::Curve25519_PublicKey::algorithm_identifier(), Botan::McEliece_PublicKey::algorithm_identifier(), Botan::RSA_PublicKey::algorithm_identifier(), Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::EC_PublicKey::algorithm_identifier(), Botan::TPM_PrivateKey::algorithm_identifier(), and Botan::XMSS_WOTS_Addressed_PublicKey::get_oid().

31 {
32 try {
33 return OIDS::lookup(algo_name());
34 }
35 catch(Lookup_Error&)
36 {
37 throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs");
38 }
39 }
Botan::Public_Key::algo_name
virtual std::string algo_name() const =0
Botan::OIDS::lookup
std::string lookup(const OID &oid)
Definition: oids.cpp:18

const BigInt& Botan::DL_Scheme_PrivateKey::get_x | ( |  | ) | const
| inline

Get the secret key x.

Returns
  secret key

Definition at line 105 of file dl_algo.h.

References m_x.

105 { return m_x; }
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:127

const BigInt& Botan::DL_Scheme_PublicKey::get_y | ( |  | ) | const
| inline inherited

Get the public value y with y = g^x mod p where x is the secret key.

Definition at line 37 of file dl_algo.h.

References m_y.

37 { return m_y; }
Botan::DL_Scheme_PublicKey::m_y
BigInt m_y
Definition: dl_algo.h:84

virtual DL_Group::Format Botan::DL_Scheme_PublicKey::group_format | ( |  | ) | const
| pure virtual inherited

Get the underlying groups encoding format.

Returns
  encoding format

Implemented in Botan::DH_PublicKey, Botan::DSA_PublicKey, and Botan::ElGamal_PublicKey.

Referenced by Botan::DL_Scheme_PublicKey::algorithm_identifier().

const BigInt& Botan::DL_Scheme_PublicKey::group_g | ( |  | ) | const
| inline inherited

Get the generator g of the underlying DL group.

Returns
  generator g

Definition at line 55 of file dl_algo.h.

Referenced by check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), and Botan::ElGamal_PrivateKey::ElGamal_PrivateKey().

55 { return m_group.get_g(); }
Botan::DL_Group::get_g
const BigInt & get_g() const
Definition: dl_group.cpp:205
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89

const BigInt& Botan::DL_Scheme_PublicKey::group_p | ( |  | ) | const
| inline inherited

Get the prime p of the underlying DL group.

Returns
  prime p

Definition at line 43 of file dl_algo.h.

Referenced by Botan::DL_Scheme_PublicKey::check_key(), check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), and Botan::DH_PublicKey::public_value().

43 { return m_group.get_p(); }
Botan::DL_Group::get_p
const BigInt & get_p() const
Definition: dl_group.cpp:196
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89

const BigInt& Botan::DL_Scheme_PublicKey::group_q | ( |  | ) | const
| inline inherited

Get the prime q of the underlying DL group.

Returns
  prime q

Definition at line 49 of file dl_algo.h.

Referenced by Botan::DL_Scheme_PublicKey::check_key(), Botan::DSA_PrivateKey::check_key(), and Botan::DSA_PrivateKey::DSA_PrivateKey().

49 { return m_group.get_q(); }
Botan::DL_Group::get_q
const BigInt & get_q() const
Definition: dl_group.cpp:214
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89

size_t Botan::DL_Scheme_PublicKey::key_length | ( |  | ) | const
| override virtual inherited

Return an integer value best approximating the length of the primary security parameter. For example for RSA this will be the size of the modulus, for ECDSA the size of the ECC group, and for McEliece the size of the code will be returned.

Implements Botan::Public_Key.

Definition at line 16 of file dl_algo.cpp.

References Botan::BigInt::bits(), Botan::DL_Group::get_p(), and Botan::DL_Scheme_PublicKey::m_group.

Referenced by Botan::DL_Scheme_PublicKey::estimated_strength().

17 {
18 return m_group.get_p().bits();
19 }
Botan::DL_Group::get_p
const BigInt & get_p() const
Definition: dl_group.cpp:196
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:184
Botan::DL_Scheme_PublicKey::m_group
DL_Group m_group
Definition: dl_algo.h:89

virtual size_t Botan::Public_Key::message_part_size | ( |  | ) | const
| inline virtual inherited

Returns how large each of the message parts refered to by message_parts() is

This function is public but applications should have few reasons to ever call this.

Returns
  size of the message parts in bits

Reimplemented in Botan::GOST_3410_PublicKey, Botan::ECDSA_PublicKey, Botan::ECGDSA_PublicKey, Botan::ECKCDSA_PublicKey, and Botan::DSA_PublicKey.

Definition at line 114 of file pk_keys.h.

Referenced by Botan::PK_Signer::PK_Signer(), and Botan::PK_Verifier::PK_Verifier().

114 { return 0; }

virtual size_t Botan::Public_Key::message_parts | ( |  | ) | const
| inline virtual inherited

Returns more than 1 if the output of this algorithm (ciphertext, signature) should be treated as more than one value. This is used for algorithms like DSA and ECDSA, where the (r,s) output pair can be encoded as either a plain binary list or a TLV tagged DER encoding depending on the protocol.

This function is public but applications should have few reasons to ever call this.

Returns
  number of message parts

Reimplemented in Botan::GOST_3410_PublicKey, Botan::ECDSA_PublicKey, Botan::ECGDSA_PublicKey, Botan::ECKCDSA_PublicKey, and Botan::DSA_PublicKey.

Definition at line 103 of file pk_keys.h.

Referenced by Botan::X509_Object::check_signature(), Botan::choose_sig_format(), Botan::PK_Signer::PK_Signer(), and Botan::PK_Verifier::PK_Verifier().

103 { return 1; }

DL_Scheme_PrivateKey& Botan::DL_Scheme_PrivateKey::operator= | ( | const DL_Scheme_PrivateKey & | other | ) |
| default

virtual AlgorithmIdentifier Botan::Private_Key::pkcs8_algorithm_identifier | ( |  | ) | const
| inline virtual inherited

Returns
  PKCS #8 AlgorithmIdentifier for this key Might be different from the X.509 identifier, but normally is not

Reimplemented in Botan::XMSS_WOTS_PrivateKey, Botan::GOST_3410_PrivateKey, and Botan::XMSS_WOTS_Addressed_PrivateKey.

Definition at line 188 of file pk_keys.h.

Referenced by Botan::Private_Key::private_key_info().

189 { return algorithm_identifier(); }
Botan::Public_Key::algorithm_identifier
virtual AlgorithmIdentifier algorithm_identifier() const =0

secure_vector< uint8_t > Botan::DL_Scheme_PrivateKey::private_key_bits | ( |  | ) | const
| override virtual

Returns
  BER encoded private key bits

Implements Botan::Private_Key.

Definition at line 46 of file dl_algo.cpp.

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

47 {
48 return DER_Encoder().encode(m_x).get_contents();
49 }
Botan::DL_Scheme_PrivateKey::m_x
BigInt m_x
Definition: dl_algo.h:127

secure_vector< uint8_t > Botan::Private_Key::private_key_info | ( |  | ) | const
| inherited

Returns
  PKCS #8 private key encoding for this key object

Definition at line 41 of file pk_keys.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), Botan::OCTET_STRING, Botan::Private_Key::pkcs8_algorithm_identifier(), Botan::Private_Key::private_key_bits(), Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

Referenced by Botan::PKCS8::BER_encode(), Botan::PKCS8::BER_encode_encrypted_pbkdf_iter(), and Botan::PKCS8::BER_encode_encrypted_pbkdf_msec().

42 {
43 const size_t PKCS8_VERSION = 0;
44
45 return DER_Encoder()
46 .start_cons(SEQUENCE)
47 .encode(PKCS8_VERSION)
48 .encode(pkcs8_algorithm_identifier())
49 .encode(private_key_bits(), OCTET_STRING)
50 .end_cons()
51 .get_contents();
52 }
Botan::Private_Key::private_key_bits
virtual secure_vector< uint8_t > private_key_bits() const =0
Botan::OCTET_STRING
Definition: asn1_obj.h:35
Botan::Private_Key::pkcs8_algorithm_identifier
virtual AlgorithmIdentifier pkcs8_algorithm_identifier() const
Definition: pk_keys.h:188
Botan::SEQUENCE
Definition: asn1_obj.h:39

std::vector< uint8_t > Botan::DL_Scheme_PublicKey::public_key_bits | ( |  | ) | const
| override virtual inherited

Returns
  BER encoded public key bits

Implements Botan::Public_Key.

Definition at line 32 of file dl_algo.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents_unlocked(), and Botan::DL_Scheme_PublicKey::m_y.

33 {
34 return DER_Encoder().encode(m_y).get_contents_unlocked();
35 }
Botan::DL_Scheme_PublicKey::m_y
BigInt m_y
Definition: dl_algo.h:84

std::vector< uint8_t > Botan::Public_Key::subject_public_key | ( |  | ) | const
| inherited

Returns
  X.509 subject key encoding for this key object

Definition at line 17 of file pk_keys.cpp.

References Botan::Public_Key::algorithm_identifier(), Botan::BIT_STRING, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::Public_Key::public_key_bits(), Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

Referenced by Botan::X509::BER_encode(), and Botan::X509::PEM_encode().

18 {
19 return DER_Encoder()
20 .start_cons(SEQUENCE)
21 .encode(algorithm_identifier())
22 .encode(public_key_bits(), BIT_STRING)
23 .end_cons()
24 .get_contents_unlocked();
25 }
Botan::Public_Key::public_key_bits
virtual std::vector< uint8_t > public_key_bits() const =0
Botan::Public_Key::algorithm_identifier
virtual AlgorithmIdentifier algorithm_identifier() const =0
Botan::SEQUENCE
Definition: asn1_obj.h:39
Botan::BIT_STRING
Definition: asn1_obj.h:34

## Member Data Documentation

DL_Group Botan::DL_Scheme_PublicKey::m_group
| protected inherited

The DL group

Definition at line 89 of file dl_algo.h.

Referenced by Botan::DL_Scheme_PublicKey::algorithm_identifier(), Botan::DL_Scheme_PublicKey::check_key(), check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DH_PublicKey::DH_PublicKey(), DL_Scheme_PrivateKey(), Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::DSA_PublicKey::DSA_PublicKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), Botan::ElGamal_PublicKey::ElGamal_PublicKey(), and Botan::DL_Scheme_PublicKey::key_length().

BigInt Botan::DL_Scheme_PrivateKey::m_x
| protected

The DL private key

Definition at line 127 of file dl_algo.h.

Referenced by Botan::DSA_PrivateKey::check_key(), check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), DL_Scheme_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), and private_key_bits().

BigInt Botan::DL_Scheme_PublicKey::m_y
| protected inherited

The DL public key

Definition at line 84 of file dl_algo.h.

Referenced by Botan::DL_Scheme_PublicKey::check_key(), check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DH_PublicKey::DH_PublicKey(), Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::DSA_PublicKey::DSA_PublicKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), Botan::ElGamal_PublicKey::ElGamal_PublicKey(), Botan::DL_Scheme_PublicKey::public_key_bits(), and Botan::DH_PublicKey::public_value().

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

- src/lib/pubkey/dl_algo/dl_algo.h
- src/lib/pubkey/dl_algo/dl_algo.cpp