Botan  1.11.15
Public Member Functions | Protected Member Functions | Protected Attributes
Botan::McEliece_PublicKey Class Reference

#include <mceliece_key.h>

Inheritance diagram for Botan::McEliece_PublicKey:
Botan::Public_Key Botan::McEliece_PrivateKey

List of all members.

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< bytex509_subject_public_key () const

Protected Member Functions

virtual void load_check (RandomNumberGenerator &rng) const
 McEliece_PublicKey ()

Protected Attributes

u32bit m_code_length
std::vector< bytem_public_matrix
u32bit m_t

Detailed Description

Definition at line 21 of file mceliece_key.h.


Constructor & Destructor Documentation

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)
            {}

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)
   {
   }

Definition at line 65 of file mceliece_key.h.

{}

Member Function Documentation

std::string Botan::McEliece_PublicKey::algo_name ( ) const [inline, virtual]

Get the name of the underlying public key scheme.

Returns:
name of the public key scheme

Implements Botan::Public_Key.

Definition at line 35 of file mceliece_key.h.

{ return "McEliece"; }
Returns:
X.509 AlgorithmIdentifier for this key

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.

Parameters:
rngrng to use
strongwhether to perform strong and lengthy version of the test
Returns:
true if the test is passed

Implements Botan::Public_Key.

Reimplemented in Botan::McEliece_PrivateKey.

Definition at line 53 of file mceliece_key.h.

         { return true; }

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 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);
   }
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

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; }
void Botan::Public_Key::load_check ( RandomNumberGenerator rng) const [protected, virtual, inherited]

Self-test after loading a key

Parameters:
rnga 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.

Returns:
the maximum number of input bits

Implements Botan::Public_Key.

Reimplemented in Botan::McEliece_PrivateKey.

Definition at line 42 of file mceliece_key.h.

virtual size_t Botan::Public_Key::message_part_size ( ) const [inline, virtual, inherited]

Find out the message part size supported by this scheme/key.

Returns:
size of the message parts in bits

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.

Returns:
number of message parts

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]
Returns:
X.509 subject key encoding for this key object

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());
   }

Member Data Documentation


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