Botan
2.1.0
Crypto and TLS for C++11
|
#include <rsa.h>
Public Member Functions | |
virtual std::string | algo_name () const =0 |
std::string | algo_name () const override |
AlgorithmIdentifier | algorithm_identifier () const override |
virtual AlgorithmIdentifier | algorithm_identifier () const =0 |
bool | check_key (RandomNumberGenerator &rng, bool) const override |
std::unique_ptr< PK_Ops::Decryption > | create_decryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override |
std::unique_ptr< PK_Ops::Encryption > | create_encryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override |
virtual std::unique_ptr< PK_Ops::Encryption > | create_encryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const |
std::unique_ptr< PK_Ops::KEM_Decryption > | create_kem_decryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override |
std::unique_ptr< PK_Ops::KEM_Encryption > | create_kem_encryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override |
virtual std::unique_ptr< PK_Ops::KEM_Encryption > | create_kem_encryption_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const |
virtual std::unique_ptr< PK_Ops::Key_Agreement > | create_key_agreement_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const |
std::unique_ptr< PK_Ops::Signature > | create_signature_op (RandomNumberGenerator &rng, const std::string ¶ms, const std::string &provider) const override |
std::unique_ptr< PK_Ops::Verification > | create_verification_op (const std::string ¶ms, const std::string &provider) const override |
virtual std::unique_ptr< PK_Ops::Verification > | create_verification_op (const std::string ¶ms, const std::string &provider) const |
virtual size_t | estimated_strength () const =0 |
size_t | estimated_strength () const override |
std::string | fingerprint (const std::string &alg="SHA") const |
const BigInt & | get_c () const |
const BigInt & | get_d () const |
const BigInt & | get_d1 () const |
const BigInt & | get_d2 () const |
const BigInt & | get_e () const |
const BigInt & | get_n () const |
virtual OID | get_oid () const |
const BigInt & | get_p () const |
const BigInt & | get_q () const |
virtual size_t | key_length () const =0 |
size_t | key_length () const override |
virtual size_t | message_part_size () const |
virtual size_t | message_parts () const |
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 |
virtual std::vector< uint8_t > | public_key_bits () const =0 |
RSA_PrivateKey (const AlgorithmIdentifier &alg_id, const secure_vector< uint8_t > &key_bits) | |
RSA_PrivateKey (const BigInt &p, const BigInt &q, const BigInt &e, const BigInt &d=0, const BigInt &n=0) | |
RSA_PrivateKey (RandomNumberGenerator &rng, size_t bits, size_t exp=65537) | |
std::vector< uint8_t > | subject_public_key () const |
Protected Attributes | |
BigInt | m_e |
BigInt | m_n |
Botan::RSA_PrivateKey::RSA_PrivateKey | ( | const AlgorithmIdentifier & | alg_id, |
const secure_vector< uint8_t > & | key_bits | ||
) |
Load a private key.
alg_id | the X.509 algorithm identifier |
key_bits | PKCS#1 RSAPrivateKey bits |
Definition at line 91 of file rsa.cpp.
References Botan::PEM_Code::decode(), Botan::BER_Decoder::decode_and_check(), Botan::RSA_PublicKey::m_e, Botan::RSA_PublicKey::m_n, Botan::SEQUENCE, and Botan::BER_Decoder::start_cons().
Botan::RSA_PrivateKey::RSA_PrivateKey | ( | const BigInt & | p, |
const BigInt & | q, | ||
const BigInt & | e, | ||
const BigInt & | d = 0 , |
||
const BigInt & | n = 0 |
||
) |
Construct a private key from the specified parameters.
p | the first prime |
q | the second prime |
e | the exponent |
d | if specified, this has to be d with exp * d = 1 mod (p - 1, q - 1). Leave it as 0 if you wish to the constructor to calculate it. |
n | if specified, this must be n = p * q. Leave it as 0 if you wish to the constructor to calculate it. |
Definition at line 108 of file rsa.cpp.
Botan::RSA_PrivateKey::RSA_PrivateKey | ( | RandomNumberGenerator & | rng, |
size_t | bits, | ||
size_t | exp = 65537 |
||
) |
Create a new private key with the specified bit length
rng | the random number generator to use |
bits | the desired bit length of the private key |
exp | the public exponent to be used |
Definition at line 134 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name(), Botan::BigInt::bits(), Botan::inverse_mod(), Botan::lcm(), Botan::RSA_PublicKey::m_e, Botan::RSA_PublicKey::m_n, Botan::random_prime(), and Botan::ASN1::to_string().
|
pure virtualinherited |
Get the name of the underlying 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().
|
inlineoverridevirtualinherited |
Get the name of the underlying public key scheme.
Implements Botan::Public_Key.
Definition at line 38 of file rsa.h.
Referenced by create_decryption_op(), Botan::RSA_PublicKey::create_encryption_op(), create_kem_decryption_op(), Botan::RSA_PublicKey::create_kem_encryption_op(), create_signature_op(), Botan::RSA_PublicKey::create_verification_op(), and RSA_PrivateKey().
|
overridevirtualinherited |
Implements Botan::Public_Key.
Definition at line 38 of file rsa.cpp.
References Botan::Public_Key::get_oid(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.
|
pure virtualinherited |
Implemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::TPM_PrivateKey, Botan::EC_PublicKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::GOST_3410_PublicKey, Botan::RSA_PublicKey, Botan::McEliece_PublicKey, Botan::Curve25519_PublicKey, and Botan::DL_Scheme_PublicKey.
Referenced by Botan::choose_sig_format(), and Botan::Public_Key::subject_public_key().
|
overridevirtual |
Test the key values for consistency.
rng | rng to use |
strong | whether to perform strong and lengthy version of the test |
Reimplemented from Botan::RSA_PublicKey.
Definition at line 161 of file rsa.cpp.
References Botan::inverse_mod(), Botan::BigInt::is_even(), Botan::is_prime(), Botan::lcm(), Botan::RSA_PublicKey::m_e, Botan::RSA_PublicKey::m_n, and Botan::KeyPair::signature_consistency_check().
|
overridevirtual |
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
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 from Botan::Private_Key.
Definition at line 466 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name(), and Botan::Exception::what().
|
overridevirtualinherited |
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
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 from Botan::Public_Key.
Definition at line 407 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name(), and Botan::Exception::what().
|
virtualinherited |
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
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().
|
overridevirtual |
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
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 from Botan::Private_Key.
Definition at line 492 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name().
|
overridevirtualinherited |
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
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 from Botan::Public_Key.
Definition at line 437 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name().
|
virtualinherited |
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
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().
|
virtualinherited |
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
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().
|
overridevirtual |
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
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 from Botan::Private_Key.
Definition at line 503 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name().
|
overridevirtualinherited |
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
params | additional parameters |
provider | the provider to use |
Reimplemented from Botan::Public_Key.
Definition at line 447 of file rsa.cpp.
References Botan::RSA_PublicKey::algo_name().
|
virtualinherited |
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
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().
|
pure virtualinherited |
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.
Implemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::TPM_PrivateKey, Botan::EC_PublicKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::DL_Scheme_PublicKey, Botan::RSA_PublicKey, Botan::McEliece_PublicKey, and Botan::Curve25519_PublicKey.
Referenced by botan_pubkey_estimated_strength().
|
overridevirtualinherited |
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 33 of file rsa.cpp.
References Botan::if_work_factor(), and Botan::RSA_PublicKey::key_length().
|
inherited |
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().
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
virtualinherited |
Get the OID of the underlying 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().
|
inline |
|
inline |
|
pure virtualinherited |
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.
Implemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::TPM_PrivateKey, Botan::EC_PublicKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::DL_Scheme_PublicKey, Botan::RSA_PublicKey, Botan::McEliece_PublicKey, and Botan::Curve25519_PublicKey.
Referenced by Botan::TLS::Policy::check_peer_key_acceptable().
|
overridevirtualinherited |
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 28 of file rsa.cpp.
References Botan::BigInt::bits(), and Botan::RSA_PublicKey::m_n.
Referenced by Botan::RSA_PublicKey::estimated_strength().
|
inlinevirtualinherited |
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.
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().
|
inlinevirtualinherited |
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.
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().
|
inlinevirtualinherited |
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().
|
overridevirtual |
Implements Botan::Private_Key.
Definition at line 74 of file rsa.cpp.
References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), Botan::RSA_PublicKey::m_e, Botan::RSA_PublicKey::m_n, Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().
|
inherited |
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().
|
overridevirtualinherited |
Implements Botan::Public_Key.
Definition at line 44 of file rsa.cpp.
References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::RSA_PublicKey::m_e, Botan::RSA_PublicKey::m_n, Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().
|
pure virtualinherited |
Implemented in Botan::XMSS_WOTS_PublicKey, Botan::XMSS_PublicKey, Botan::TPM_PrivateKey, Botan::XMSS_WOTS_Addressed_PublicKey, Botan::EC_PublicKey, Botan::GOST_3410_PublicKey, Botan::McEliece_PublicKey, Botan::RSA_PublicKey, Botan::Curve25519_PublicKey, and Botan::DL_Scheme_PublicKey.
Referenced by Botan::Public_Key::subject_public_key().
|
inherited |
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().
|
protectedinherited |
Definition at line 76 of file rsa.h.
Referenced by Botan::RSA_PublicKey::check_key(), check_key(), private_key_bits(), Botan::RSA_PublicKey::public_key_bits(), RSA_PrivateKey(), and Botan::RSA_PublicKey::RSA_PublicKey().
|
protectedinherited |
Definition at line 76 of file rsa.h.
Referenced by Botan::RSA_PublicKey::check_key(), check_key(), Botan::RSA_PublicKey::key_length(), private_key_bits(), Botan::RSA_PublicKey::public_key_bits(), RSA_PrivateKey(), and Botan::RSA_PublicKey::RSA_PublicKey().