Botan
1.11.15
|
#include <mceliece_key.h>
Public Member Functions | |
std::string | algo_name () const |
AlgorithmIdentifier | algorithm_identifier () const |
bool | check_key (RandomNumberGenerator &, bool) const |
size_t | estimated_strength () const |
u32bit | get_code_length () const |
u32bit | get_message_word_bit_length () const |
virtual OID | get_oid () const |
std::vector< byte > const & | get_public_matrix () const |
u32bit | get_t () const |
size_t | max_input_bits () const |
McEliece_PublicKey (const std::vector< byte > &key_bits) | |
McEliece_PublicKey (std::vector< byte > const &pub_matrix, u32bit the_t, u32bit the_code_length) | |
McEliece_PublicKey (const McEliece_PublicKey &other) | |
virtual size_t | message_part_size () const |
virtual size_t | message_parts () const |
bool | operator!= (const McEliece_PublicKey &other) const |
bool | operator== (const McEliece_PublicKey &other) const |
std::vector< byte > | x509_subject_public_key () const |
Protected Member Functions | |
virtual void | load_check (RandomNumberGenerator &rng) const |
McEliece_PublicKey () | |
Protected Attributes | |
u32bit | m_code_length |
std::vector< byte > | m_public_matrix |
u32bit | m_t |
Definition at line 21 of file mceliece_key.h.
Botan::McEliece_PublicKey::McEliece_PublicKey | ( | const std::vector< byte > & | key_bits | ) |
Definition at line 84 of file mceliece_key.cpp.
References Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), m_code_length, m_public_matrix, m_t, n, Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::BER_Decoder::start_cons().
{ BER_Decoder dec(key_bits); size_t n; size_t t; dec.start_cons(SEQUENCE) .start_cons(SEQUENCE) .decode(n) .decode(t) .end_cons() .decode(m_public_matrix, OCTET_STRING) .end_cons(); m_t = t; m_code_length = n; }
Botan::McEliece_PublicKey::McEliece_PublicKey | ( | std::vector< byte > const & | pub_matrix, |
u32bit | the_t, | ||
u32bit | the_code_length | ||
) | [inline] |
Definition at line 27 of file mceliece_key.h.
: m_public_matrix(pub_matrix), m_t(the_t), m_code_length(the_code_length) {}
Botan::McEliece_PublicKey::McEliece_PublicKey | ( | const McEliece_PublicKey & | other | ) |
Definition at line 70 of file mceliece_key.cpp.
: m_public_matrix(other.m_public_matrix), m_t(other.m_t), m_code_length(other.m_code_length) { }
Botan::McEliece_PublicKey::McEliece_PublicKey | ( | ) | [inline, protected] |
Definition at line 65 of file mceliece_key.h.
{}
std::string Botan::McEliece_PublicKey::algo_name | ( | ) | const [inline, virtual] |
Get the name of the underlying public key scheme.
Implements Botan::Public_Key.
Definition at line 35 of file mceliece_key.h.
{ return "McEliece"; }
AlgorithmIdentifier Botan::McEliece_PublicKey::algorithm_identifier | ( | ) | const [virtual] |
Implements Botan::Public_Key.
Definition at line 51 of file mceliece_key.cpp.
References Botan::Public_Key::get_oid().
{ return AlgorithmIdentifier(get_oid(), std::vector<byte>()); }
bool Botan::McEliece_PublicKey::check_key | ( | RandomNumberGenerator & | rng, |
bool | strong | ||
) | const [inline, 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::McEliece_PrivateKey.
Definition at line 53 of file mceliece_key.h.
{ return true; }
size_t Botan::McEliece_PublicKey::estimated_strength | ( | ) | const [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 77 of file mceliece_key.cpp.
References Botan::ceil_log2(), m_code_length, m_t, and Botan::mceliece_work_factor().
{ const u32bit ext_deg = ceil_log2(m_code_length); const size_t k = m_code_length - ext_deg * m_t; return mceliece_work_factor(m_code_length, k, m_t); }
u32bit Botan::McEliece_PublicKey::get_code_length | ( | ) | const [inline] |
Definition at line 57 of file mceliece_key.h.
Referenced by Botan::McEliece_PrivateKey::check_key(), Botan::McEliece_Private_Operation::decrypt(), Botan::McEliece_KEM_Encryptor::encrypt(), Botan::McEliece_Public_Operation::encrypt(), Botan::mceies_decrypt(), Botan::mceies_encrypt(), Botan::mceliece_decrypt(), Botan::McEliece_PrivateKey::pkcs8_private_key(), and x509_subject_public_key().
{ return m_code_length; }
unsigned Botan::McEliece_PublicKey::get_message_word_bit_length | ( | ) | const |
Definition at line 45 of file mceliece_key.cpp.
References Botan::ceil_log2(), m_code_length, and m_t.
Referenced by Botan::McEliece_PrivateKey::check_key(), Botan::McEliece_KEM_Encryptor::encrypt(), and Botan::mceliece_decrypt().
{ u32bit codimension = ceil_log2(m_code_length) * m_t; return m_code_length - codimension; }
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 algorithm_identifier().
{ try { return OIDS::lookup(algo_name()); } catch(Lookup_Error) { throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs"); } }
std::vector<byte> const& Botan::McEliece_PublicKey::get_public_matrix | ( | ) | const [inline] |
Definition at line 59 of file mceliece_key.h.
Referenced by Botan::McEliece_Public_Operation::encrypt().
{ return m_public_matrix; }
u32bit Botan::McEliece_PublicKey::get_t | ( | ) | const [inline] |
Definition at line 56 of file mceliece_key.h.
Referenced by Botan::McEliece_PrivateKey::check_key(), Botan::McEliece_KEM_Encryptor::encrypt(), Botan::McEliece_PrivateKey::pkcs8_private_key(), and x509_subject_public_key().
{ return m_t; }
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"); }
size_t Botan::McEliece_PublicKey::max_input_bits | ( | ) | const [inline, virtual] |
Get the maximum number of bits allowed to be fed to this key. This is the bitlength of the order of the base point.
Implements Botan::Public_Key.
Reimplemented in Botan::McEliece_PrivateKey.
Definition at line 42 of file mceliece_key.h.
{ return get_message_word_bit_length(); };
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; }
bool Botan::McEliece_PublicKey::operator!= | ( | const McEliece_PublicKey & | other | ) | const [inline] |
Definition at line 62 of file mceliece_key.h.
{ return !(*this == other); }
bool Botan::McEliece_PublicKey::operator== | ( | const McEliece_PublicKey & | other | ) | const |
Definition at line 267 of file mceliece_key.cpp.
References m_code_length, m_public_matrix, and m_t.
{ if(m_public_matrix != other.m_public_matrix) { return false; } if(m_t != other.m_t ) { return false; } if( m_code_length != other.m_code_length) { return false; } return true; }
std::vector< byte > Botan::McEliece_PublicKey::x509_subject_public_key | ( | ) | const [virtual] |
Implements Botan::Public_Key.
Definition at line 56 of file mceliece_key.cpp.
References Botan::PEM_Code::encode(), get_code_length(), get_t(), m_public_matrix, Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::unlock().
{ // encode the public key return unlock(DER_Encoder() .start_cons(SEQUENCE) .start_cons(SEQUENCE) .encode(static_cast<size_t>(get_code_length())) .encode(static_cast<size_t>(get_t())) .end_cons() .encode(m_public_matrix, OCTET_STRING) .end_cons() .get_contents()); }
u32bit Botan::McEliece_PublicKey::m_code_length [protected] |
Definition at line 69 of file mceliece_key.h.
Referenced by estimated_strength(), get_message_word_bit_length(), Botan::McEliece_PrivateKey::McEliece_PrivateKey(), McEliece_PublicKey(), and operator==().
std::vector<byte> Botan::McEliece_PublicKey::m_public_matrix [protected] |
Definition at line 67 of file mceliece_key.h.
Referenced by Botan::McEliece_PrivateKey::McEliece_PrivateKey(), McEliece_PublicKey(), operator==(), Botan::McEliece_PrivateKey::pkcs8_private_key(), and x509_subject_public_key().
u32bit Botan::McEliece_PublicKey::m_t [protected] |
Definition at line 68 of file mceliece_key.h.
Referenced by estimated_strength(), get_message_word_bit_length(), Botan::McEliece_PrivateKey::McEliece_PrivateKey(), McEliece_PublicKey(), and operator==().