Botan
1.11.15
|
#include <dl_algo.h>
Public Member Functions | |
virtual std::string | algo_name () const =0 |
AlgorithmIdentifier | algorithm_identifier () const |
bool | check_key (RandomNumberGenerator &rng, bool) const |
DL_Scheme_PublicKey (const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits, DL_Group::Format group_format) | |
size_t | estimated_strength () const override |
const DL_Group & | get_domain () const |
virtual OID | get_oid () 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 |
virtual size_t | max_input_bits () const =0 |
virtual size_t | message_part_size () const |
virtual size_t | message_parts () const |
std::vector< byte > | x509_subject_public_key () const |
Protected Member Functions | |
DL_Scheme_PublicKey () | |
virtual void | load_check (RandomNumberGenerator &rng) const |
Protected Attributes | |
DL_Group | group |
BigInt | y |
Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey | ( | const AlgorithmIdentifier & | alg_id, |
const secure_vector< byte > & | key_bits, | ||
DL_Group::Format | group_format | ||
) |
Definition at line 32 of file dl_algo.cpp.
References Botan::DL_Group::BER_decode(), Botan::BER_Decoder::decode(), group, Botan::AlgorithmIdentifier::parameters, and y.
{ group.BER_decode(alg_id.parameters, format); BER_Decoder(key_bits).decode(y); }
Botan::DL_Scheme_PublicKey::DL_Scheme_PublicKey | ( | ) | [inline, protected] |
virtual std::string Botan::Public_Key::algo_name | ( | ) | const [pure virtual, inherited] |
Get the name of the underlying public key scheme.
Implemented in Botan::GOST_3410_PublicKey, Botan::ECDH_PublicKey, Botan::ECDSA_PublicKey, Botan::McEliece_PublicKey, Botan::RSA_PublicKey, Botan::DH_PublicKey, Botan::DSA_PublicKey, Botan::ElGamal_PublicKey, Botan::NR_PublicKey, Botan::RW_PublicKey, and Botan::Curve25519_PublicKey.
Referenced by Botan::PKCS8::BER_encode(), Botan::EAC_Signed_Object::check_signature(), 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::find_constraints(), Botan::Private_Key::gen_check(), Botan::Public_Key::get_oid(), Botan::Public_Key::load_check(), Botan::Private_Key::load_check(), Botan::PK_Encryptor_EME::PK_Encryptor_EME(), Botan::PK_Key_Agreement::PK_Key_Agreement(), Botan::PK_Signer::PK_Signer(), Botan::PK_Verifier::PK_Verifier(), and Botan::TLS::Handshake_State::understand_sig_format().
AlgorithmIdentifier Botan::DL_Scheme_PublicKey::algorithm_identifier | ( | ) | const [virtual] |
Implements Botan::Public_Key.
Definition at line 21 of file dl_algo.cpp.
References Botan::DL_Group::DER_encode(), Botan::Public_Key::get_oid(), group, and group_format().
{ return AlgorithmIdentifier(get_oid(), group.DER_encode(group_format())); }
bool Botan::DL_Scheme_PublicKey::check_key | ( | RandomNumberGenerator & | rng, |
bool | strong | ||
) | const [virtual] |
Test the key values for consistency.
rng | rng to use |
strong | whether to perform strong and lengthy version of the test |
Implements Botan::Public_Key.
Reimplemented in Botan::DL_Scheme_PrivateKey, Botan::DSA_PrivateKey, Botan::NR_PrivateKey, and Botan::ElGamal_PrivateKey.
Definition at line 58 of file dl_algo.cpp.
References group, group_p(), and Botan::DL_Group::verify_group().
{ if(y < 2 || y >= group_p()) return false; if(!group.verify_group(rng, strong)) return false; return true; }
size_t Botan::DL_Scheme_PublicKey::estimated_strength | ( | ) | const [override, virtual] |
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.
Implements Botan::Public_Key.
Definition at line 16 of file dl_algo.cpp.
References Botan::BigInt::bits(), Botan::dl_work_factor(), Botan::DL_Group::get_p(), and group.
{ return dl_work_factor(group.get_p().bits()); }
const DL_Group& Botan::DL_Scheme_PublicKey::get_domain | ( | ) | const [inline] |
OID Botan::Public_Key::get_oid | ( | ) | const [virtual, inherited] |
Get the OID of the underlying public key scheme.
Definition at line 17 of file pk_keys.cpp.
References Botan::Public_Key::algo_name(), and Botan::OIDS::lookup().
Referenced by algorithm_identifier(), Botan::Curve25519_PublicKey::algorithm_identifier(), Botan::IF_Scheme_PublicKey::algorithm_identifier(), Botan::GOST_3410_PublicKey::algorithm_identifier(), Botan::EC_PublicKey::algorithm_identifier(), and Botan::McEliece_PublicKey::algorithm_identifier().
{ try { return OIDS::lookup(algo_name()); } catch(Lookup_Error) { throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs"); } }
const BigInt& Botan::DL_Scheme_PublicKey::get_y | ( | ) | const [inline] |
virtual DL_Group::Format Botan::DL_Scheme_PublicKey::group_format | ( | ) | const [pure virtual] |
Get the underlying groups encoding format.
Implemented in Botan::DH_PublicKey, Botan::DSA_PublicKey, Botan::NR_PublicKey, and Botan::ElGamal_PublicKey.
Referenced by algorithm_identifier().
const BigInt& Botan::DL_Scheme_PublicKey::group_g | ( | ) | const [inline] |
Get the generator g of the underlying DL group.
Definition at line 56 of file dl_algo.h.
Referenced by Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), and Botan::NR_PrivateKey::NR_PrivateKey().
const BigInt& Botan::DL_Scheme_PublicKey::group_p | ( | ) | const [inline] |
Get the prime p of the underlying DL group.
Definition at line 44 of file dl_algo.h.
Referenced by check_key(), Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), Botan::NR_PrivateKey::NR_PrivateKey(), and Botan::DH_PublicKey::public_value().
const BigInt& Botan::DL_Scheme_PublicKey::group_q | ( | ) | const [inline] |
Get the prime q of the underlying DL group.
Definition at line 50 of file dl_algo.h.
Referenced by Botan::NR_PrivateKey::check_key(), Botan::DSA_PrivateKey::check_key(), Botan::DSA_PrivateKey::DSA_PrivateKey(), and Botan::NR_PrivateKey::NR_PrivateKey().
void Botan::Public_Key::load_check | ( | RandomNumberGenerator & | rng | ) | const [protected, virtual, inherited] |
Self-test after loading a key
rng | a random number generator |
Reimplemented in Botan::Private_Key.
Definition at line 31 of file pk_keys.cpp.
References Botan::Public_Key::algo_name(), and Botan::Public_Key::check_key().
{ if(!check_key(rng, BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD)) throw Invalid_Argument(algo_name() + ": Invalid public key"); }
virtual size_t Botan::Public_Key::max_input_bits | ( | ) | const [pure virtual, inherited] |
Get the maximum message size in bits supported by this public key.
Implemented in Botan::McEliece_PrivateKey, Botan::GOST_3410_PublicKey, Botan::ECDH_PublicKey, Botan::ECDSA_PublicKey, Botan::IF_Scheme_PublicKey, Botan::McEliece_PublicKey, Botan::NR_PublicKey, Botan::DSA_PublicKey, Botan::DH_PublicKey, Botan::ElGamal_PublicKey, and Botan::Curve25519_PublicKey.
Referenced by Botan::choose_sig_format().
virtual size_t Botan::Public_Key::message_part_size | ( | ) | const [inline, virtual, inherited] |
Find out the message part size supported by this scheme/key.
Reimplemented in Botan::GOST_3410_PublicKey, Botan::ECDSA_PublicKey, Botan::NR_PublicKey, and Botan::DSA_PublicKey.
Definition at line 67 of file pk_keys.h.
{ return 0; }
virtual size_t Botan::Public_Key::message_parts | ( | ) | const [inline, virtual, inherited] |
Find out the number of message parts supported by this scheme.
Reimplemented in Botan::GOST_3410_PublicKey, Botan::ECDSA_PublicKey, Botan::NR_PublicKey, and Botan::DSA_PublicKey.
Definition at line 61 of file pk_keys.h.
Referenced by Botan::EAC_Signed_Object::check_signature(), Botan::X509_Object::check_signature(), and Botan::choose_sig_format().
{ return 1; }
std::vector< byte > Botan::DL_Scheme_PublicKey::x509_subject_public_key | ( | ) | const [virtual] |
Implements Botan::Public_Key.
Definition at line 27 of file dl_algo.cpp.
References Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents_unlocked(), and y.
{ return DER_Encoder().encode(y).get_contents_unlocked(); }
DL_Group Botan::DL_Scheme_PublicKey::group [protected] |
The DL group
Definition at line 81 of file dl_algo.h.
Referenced by algorithm_identifier(), check_key(), Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DH_PublicKey::DH_PublicKey(), Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(), DL_Scheme_PublicKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::DSA_PublicKey::DSA_PublicKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), Botan::ElGamal_PublicKey::ElGamal_PublicKey(), estimated_strength(), Botan::NR_PrivateKey::NR_PrivateKey(), and Botan::NR_PublicKey::NR_PublicKey().
BigInt Botan::DL_Scheme_PublicKey::y [protected] |
The DL public key
Definition at line 76 of file dl_algo.h.
Referenced by Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DH_PublicKey::DH_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::NR_PrivateKey::NR_PrivateKey(), Botan::NR_PublicKey::NR_PublicKey(), Botan::DH_PublicKey::public_value(), and x509_subject_public_key().