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

#include <curve25519.h>

Inheritance diagram for Botan::Curve25519_PrivateKey:
Botan::Curve25519_PublicKey Botan::Private_Key Botan::PK_Key_Agreement_Key Botan::Public_Key Botan::Public_Key Botan::Private_Key Botan::Public_Key

List of all members.

Public Member Functions

secure_vector< byteagree (const byte w[], size_t w_len) const
std::string algo_name () const override
AlgorithmIdentifier algorithm_identifier () const override
bool check_key (RandomNumberGenerator &rng, bool strong) const override
 Curve25519_PrivateKey (const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits, RandomNumberGenerator &rng)
 Curve25519_PrivateKey (RandomNumberGenerator &rng)
 Curve25519_PrivateKey (const secure_vector< byte > &secret_key)
size_t estimated_strength () const override
virtual OID get_oid () const
const secure_vector< byte > & get_x () const
size_t max_input_bits () const
virtual size_t message_part_size () const
virtual size_t message_parts () const
virtual AlgorithmIdentifier pkcs8_algorithm_identifier () const
secure_vector< bytepkcs8_private_key () const override
std::vector< bytepublic_value () const override
std::vector< bytex509_subject_public_key () const override

Protected Member Functions

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

Protected Attributes

secure_vector< bytem_public

Detailed Description

Definition at line 41 of file curve25519.h.


Constructor & Destructor Documentation

Botan::Curve25519_PrivateKey::Curve25519_PrivateKey ( const AlgorithmIdentifier alg_id,
const secure_vector< byte > &  key_bits,
RandomNumberGenerator rng 
)

Definition at line 77 of file curve25519.cpp.

References Botan::BER_Decoder::decode(), Botan::BER_Decoder::end_cons(), Botan::Private_Key::load_check(), Botan::Curve25519_PublicKey::m_public, Botan::OCTET_STRING, Botan::SEQUENCE, Botan::BER_Decoder::start_cons(), and Botan::BER_Decoder::verify_end().

   {
   BER_Decoder(key_bits)
      .start_cons(SEQUENCE)
      .decode(m_public, OCTET_STRING)
      .decode(m_private, OCTET_STRING)
      .verify_end()
   .end_cons();

   size_check(m_public.size(), "public key");
   size_check(m_private.size(), "private key");

   load_check(rng);
   }

Definition at line 71 of file curve25519.cpp.

References Botan::Curve25519_PublicKey::m_public, and Botan::RandomNumberGenerator::random_vec().

   {
   m_private = rng.random_vec(32);
   m_public = curve25519_basepoint(m_private);
   }
Botan::Curve25519_PrivateKey::Curve25519_PrivateKey ( const secure_vector< byte > &  secret_key)

Member Function Documentation

secure_vector< byte > Botan::Curve25519_PrivateKey::agree ( const byte  w[],
size_t  w_len 
) const

Definition at line 109 of file curve25519.cpp.

   {
   size_check(w_len, "public value");
   return curve25519(m_private, w);
   }
std::string Botan::Curve25519_PublicKey::algo_name ( ) const [inline, override, virtual, inherited]

Get the name of the underlying public key scheme.

Returns:
name of the public key scheme

Implements Botan::Public_Key.

Definition at line 18 of file curve25519.h.

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

Implements Botan::Public_Key.

Definition at line 40 of file curve25519.cpp.

References Botan::Public_Key::get_oid(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.

   {
   return AlgorithmIdentifier(get_oid(), AlgorithmIdentifier::USE_NULL_PARAM);
   }
bool Botan::Curve25519_PrivateKey::check_key ( RandomNumberGenerator rng,
bool  strong 
) const [override, 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

Reimplemented from Botan::Curve25519_PublicKey.

Definition at line 104 of file curve25519.cpp.

References Botan::Curve25519_PublicKey::m_public.

   {
   return curve25519_basepoint(m_private) == m_public;
   }
size_t Botan::Curve25519_PublicKey::estimated_strength ( ) const [inline, 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.

Returns:
estimated strength in bits

Implements Botan::Public_Key.

Definition at line 20 of file curve25519.h.

{ return 128; }
void Botan::Private_Key::gen_check ( RandomNumberGenerator rng) const [protected, inherited]

Self-test after generating a key

Parameters:
rnga 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(), Botan::NR_PrivateKey::NR_PrivateKey(), Botan::RSA_PrivateKey::RSA_PrivateKey(), and Botan::RW_PrivateKey::RW_PrivateKey().

   {
   if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE))
      throw Self_Test_Failure(algo_name() + " private key generation failed");
   }
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 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 secure_vector<byte>& Botan::Curve25519_PrivateKey::get_x ( ) const [inline]

Definition at line 58 of file curve25519.h.

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

Self-test after loading a key

Parameters:
rnga 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 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 Botan::NR_PrivateKey::NR_PrivateKey().

   {
   if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD))
      throw Invalid_Argument(algo_name() + ": Invalid private key");
   }
size_t Botan::Curve25519_PublicKey::max_input_bits ( ) const [inline, virtual, inherited]

Get the maximum message size in bits supported by this public key.

Returns:
maximum message size in bits

Implements Botan::Public_Key.

Definition at line 22 of file curve25519.h.

{ return 256; }
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; }
virtual AlgorithmIdentifier Botan::Private_Key::pkcs8_algorithm_identifier ( ) const [inline, virtual, inherited]
Returns:
PKCS #8 AlgorithmIdentifier for this key Might be different from the X.509 identifier, but normally is not

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::Curve25519_PrivateKey::pkcs8_private_key ( ) const [override, virtual]
Returns:
PKCS #8 private key encoding for this key object

Implements Botan::Private_Key.

Definition at line 94 of file curve25519.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents(), Botan::Curve25519_PublicKey::m_public, Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

   {
   return DER_Encoder()
      .start_cons(SEQUENCE)
        .encode(m_public, OCTET_STRING)
        .encode(m_private, OCTET_STRING)
      .end_cons()
      .get_contents();
   }
std::vector<byte> Botan::Curve25519_PrivateKey::public_value ( ) const [inline, override]

Reimplemented from Botan::Curve25519_PublicKey.

Definition at line 54 of file curve25519.h.

References Botan::Curve25519_PublicKey::public_value().

std::vector< byte > Botan::Curve25519_PublicKey::x509_subject_public_key ( ) const [override, virtual, inherited]
Returns:
X.509 subject key encoding for this key object

Implements Botan::Public_Key.

Definition at line 62 of file curve25519.cpp.

References Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::DER_Encoder::get_contents_unlocked(), Botan::Curve25519_PublicKey::m_public, Botan::OCTET_STRING, Botan::SEQUENCE, and Botan::DER_Encoder::start_cons().

   {
   return DER_Encoder()
      .start_cons(SEQUENCE)
        .encode(m_public, OCTET_STRING)
      .end_cons()
      .get_contents_unlocked();
   }

Member Data Documentation

secure_vector<byte> Botan::Curve25519_PublicKey::m_public [protected, inherited]

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