Botan
1.11.15
|
#include <nr.h>
Public Member Functions | |
std::string | algo_name () const |
AlgorithmIdentifier | algorithm_identifier () const |
bool | check_key (RandomNumberGenerator &rng, bool strong) const |
size_t | estimated_strength () const override |
const DL_Group & | get_domain () const |
virtual OID | get_oid () const |
const BigInt & | get_x () const |
const BigInt & | get_y () const |
DL_Group::Format | group_format () const |
const BigInt & | group_g () const |
const BigInt & | group_p () const |
const BigInt & | group_q () const |
size_t | max_input_bits () const |
size_t | message_part_size () const |
size_t | message_parts () const |
NR_PrivateKey (const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits, RandomNumberGenerator &rng) | |
NR_PrivateKey (RandomNumberGenerator &rng, const DL_Group &group, const BigInt &x=0) | |
virtual AlgorithmIdentifier | pkcs8_algorithm_identifier () const |
secure_vector< byte > | pkcs8_private_key () const |
std::vector< byte > | x509_subject_public_key () const |
Protected Member Functions | |
void | gen_check (RandomNumberGenerator &rng) const |
virtual void | load_check (RandomNumberGenerator &rng) const |
void | load_check (RandomNumberGenerator &rng) const |
Protected Attributes | |
DL_Group | group |
BigInt | x |
BigInt | y |
Botan::NR_PrivateKey::NR_PrivateKey | ( | const AlgorithmIdentifier & | alg_id, |
const secure_vector< byte > & | key_bits, | ||
RandomNumberGenerator & | rng | ||
) |
Definition at line 52 of file nr.cpp.
References Botan::DL_Scheme_PublicKey::group_g(), Botan::DL_Scheme_PublicKey::group_p(), Botan::Private_Key::load_check(), Botan::power_mod(), Botan::DL_Scheme_PrivateKey::x, and Botan::DL_Scheme_PublicKey::y.
: DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_57) { y = power_mod(group_g(), x, group_p()); load_check(rng); }
Botan::NR_PrivateKey::NR_PrivateKey | ( | RandomNumberGenerator & | rng, |
const DL_Group & | group, | ||
const BigInt & | x = 0 |
||
) |
Definition at line 34 of file nr.cpp.
References Botan::Private_Key::gen_check(), Botan::DL_Scheme_PublicKey::group, Botan::DL_Scheme_PublicKey::group_g(), Botan::DL_Scheme_PublicKey::group_p(), Botan::DL_Scheme_PublicKey::group_q(), Botan::Private_Key::load_check(), Botan::power_mod(), Botan::BigInt::random_integer(), Botan::DL_Scheme_PrivateKey::x, and Botan::DL_Scheme_PublicKey::y.
std::string Botan::NR_PublicKey::algo_name | ( | ) | const [inline, virtual, inherited] |
Get the name of the underlying public key scheme.
Implements Botan::Public_Key.
Definition at line 21 of file nr.h.
{ return "NR"; }
AlgorithmIdentifier Botan::DL_Scheme_PublicKey::algorithm_identifier | ( | ) | const [virtual, inherited] |
Implements Botan::Public_Key.
Definition at line 21 of file dl_algo.cpp.
References Botan::DL_Group::DER_encode(), Botan::Public_Key::get_oid(), Botan::DL_Scheme_PublicKey::group, and Botan::DL_Scheme_PublicKey::group_format().
{ return AlgorithmIdentifier(get_oid(), group.DER_encode(group_format())); }
bool Botan::NR_PrivateKey::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 |
Reimplemented from Botan::DL_Scheme_PrivateKey.
Definition at line 65 of file nr.cpp.
References Botan::DL_Scheme_PrivateKey::check_key(), Botan::DL_Scheme_PublicKey::group_q(), Botan::KeyPair::signature_consistency_check(), and Botan::DL_Scheme_PrivateKey::x.
{ if(!DL_Scheme_PrivateKey::check_key(rng, strong) || x >= group_q()) return false; if(!strong) return true; return KeyPair::signature_consistency_check(rng, *this, "EMSA1(SHA-1)"); }
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.
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 Botan::DL_Scheme_PublicKey::group.
{ return dl_work_factor(group.get_p().bits()); }
void Botan::Private_Key::gen_check | ( | RandomNumberGenerator & | rng | ) | const [protected, inherited] |
Self-test after generating a key
rng | a random number generator |
Definition at line 49 of file pk_keys.cpp.
References Botan::Public_Key::algo_name(), and Botan::Public_Key::check_key().
Referenced by Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), NR_PrivateKey(), Botan::RSA_PrivateKey::RSA_PrivateKey(), and Botan::RW_PrivateKey::RW_PrivateKey().
const DL_Group& Botan::DL_Scheme_PublicKey::get_domain | ( | ) | const [inline, inherited] |
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 Botan::DL_Scheme_PublicKey::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_PrivateKey::get_x | ( | ) | const [inline, inherited] |
const BigInt& Botan::DL_Scheme_PublicKey::get_y | ( | ) | const [inline, inherited] |
DL_Group::Format Botan::NR_PublicKey::group_format | ( | ) | const [inline, virtual, inherited] |
Get the underlying groups encoding format.
Implements Botan::DL_Scheme_PublicKey.
Definition at line 23 of file nr.h.
References Botan::DL_Group::ANSI_X9_57.
{ return DL_Group::ANSI_X9_57; }
const BigInt& Botan::DL_Scheme_PublicKey::group_g | ( | ) | const [inline, inherited] |
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 NR_PrivateKey().
const BigInt& Botan::DL_Scheme_PublicKey::group_p | ( | ) | const [inline, inherited] |
Get the prime p of the underlying DL group.
Definition at line 44 of file dl_algo.h.
Referenced by Botan::DL_Scheme_PublicKey::check_key(), Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), NR_PrivateKey(), and Botan::DH_PublicKey::public_value().
const BigInt& Botan::DL_Scheme_PublicKey::group_q | ( | ) | const [inline, inherited] |
Get the prime q of the underlying DL group.
Definition at line 50 of file dl_algo.h.
Referenced by check_key(), Botan::DSA_PrivateKey::check_key(), Botan::DSA_PrivateKey::DSA_PrivateKey(), and 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"); }
void Botan::Private_Key::load_check | ( | RandomNumberGenerator & | rng | ) | const [protected, virtual, inherited] |
Self-test after loading a key
rng | a random number generator |
Reimplemented from Botan::Public_Key.
Definition at line 40 of file pk_keys.cpp.
References Botan::Public_Key::algo_name(), and Botan::Public_Key::check_key().
Referenced by Botan::Curve25519_PrivateKey::Curve25519_PrivateKey(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), Botan::IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(), and NR_PrivateKey().
{ if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD)) throw Invalid_Argument(algo_name() + ": Invalid private key"); }
size_t Botan::NR_PublicKey::max_input_bits | ( | ) | const [inline, virtual, inherited] |
Get the maximum message size in bits supported by this public key.
Implements Botan::Public_Key.
Definition at line 27 of file nr.h.
{ return (group_q().bits() - 1); }
size_t Botan::NR_PublicKey::message_part_size | ( | ) | const [inline, virtual, inherited] |
Find out the message part size supported by this scheme/key.
Reimplemented from Botan::Public_Key.
size_t Botan::NR_PublicKey::message_parts | ( | ) | const [inline, virtual, inherited] |
Find out the number of message parts supported by this scheme.
Reimplemented from Botan::Public_Key.
Definition at line 25 of file nr.h.
{ return 2; }
virtual AlgorithmIdentifier Botan::Private_Key::pkcs8_algorithm_identifier | ( | ) | const [inline, virtual, inherited] |
Reimplemented in Botan::GOST_3410_PrivateKey.
Definition at line 109 of file pk_keys.h.
Referenced by Botan::PKCS8::BER_encode().
{ return algorithm_identifier(); }
secure_vector< byte > Botan::DL_Scheme_PrivateKey::pkcs8_private_key | ( | ) | const [virtual, inherited] |
Implements Botan::Private_Key.
Definition at line 41 of file dl_algo.cpp.
References Botan::DER_Encoder::encode(), Botan::DER_Encoder::get_contents(), and Botan::DL_Scheme_PrivateKey::x.
{ return DER_Encoder().encode(x).get_contents(); }
std::vector< byte > Botan::DL_Scheme_PublicKey::x509_subject_public_key | ( | ) | const [virtual, inherited] |
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 Botan::DL_Scheme_PublicKey::y.
{ return DER_Encoder().encode(y).get_contents_unlocked(); }
DL_Group Botan::DL_Scheme_PublicKey::group [protected, inherited] |
The DL group
Definition at line 81 of file dl_algo.h.
Referenced by Botan::DL_Scheme_PublicKey::algorithm_identifier(), Botan::DL_Scheme_PublicKey::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(), 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::estimated_strength(), NR_PrivateKey(), and Botan::NR_PublicKey::NR_PublicKey().
BigInt Botan::DL_Scheme_PrivateKey::x [protected, inherited] |
The DL private key
Definition at line 111 of file dl_algo.h.
Referenced by check_key(), Botan::DSA_PrivateKey::check_key(), Botan::DL_Scheme_PrivateKey::check_key(), Botan::DH_PrivateKey::DH_PrivateKey(), Botan::DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(), Botan::DSA_PrivateKey::DSA_PrivateKey(), Botan::ElGamal_PrivateKey::ElGamal_PrivateKey(), NR_PrivateKey(), and Botan::DL_Scheme_PrivateKey::pkcs8_private_key().
BigInt Botan::DL_Scheme_PublicKey::y [protected, inherited] |
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(), 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(), NR_PrivateKey(), Botan::NR_PublicKey::NR_PublicKey(), Botan::DH_PublicKey::public_value(), and Botan::DL_Scheme_PublicKey::x509_subject_public_key().