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

#include <nr.h>

Inheritance diagram for Botan::NR_PublicKey:
Botan::DL_Scheme_PublicKey Botan::Public_Key Botan::NR_PrivateKey

List of all members.

Public Member Functions

std::string algo_name () const
AlgorithmIdentifier algorithm_identifier () const
bool check_key (RandomNumberGenerator &rng, bool) const
size_t estimated_strength () const override
const DL_Groupget_domain () const
virtual OID get_oid () const
const BigIntget_y () const
DL_Group::Format group_format () const
const BigIntgroup_g () const
const BigIntgroup_p () const
const BigIntgroup_q () const
size_t max_input_bits () const
size_t message_part_size () const
size_t message_parts () const
 NR_PublicKey (const AlgorithmIdentifier &alg_id, const secure_vector< byte > &key_bits)
 NR_PublicKey (const DL_Group &group, const BigInt &pub_key)
std::vector< bytex509_subject_public_key () const

Protected Member Functions

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

Protected Attributes

DL_Group group
BigInt y

Detailed Description

Nyberg-Rueppel Public Key

Definition at line 18 of file nr.h.


Constructor & Destructor Documentation

Botan::NR_PublicKey::NR_PublicKey ( const AlgorithmIdentifier alg_id,
const secure_vector< byte > &  key_bits 
)

Definition at line 16 of file nr.cpp.

                                                                :
   DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
   {
   }
Botan::NR_PublicKey::NR_PublicKey ( const DL_Group group,
const BigInt pub_key 
)

Definition at line 25 of file nr.cpp.

References Botan::DL_Scheme_PublicKey::group, and Botan::DL_Scheme_PublicKey::y.

   {
   group = grp;
   y = y1;
   }
Botan::NR_PublicKey::NR_PublicKey ( ) [inline, protected]

Definition at line 34 of file nr.h.

{}

Member Function Documentation

std::string Botan::NR_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 21 of file nr.h.

{ return "NR"; }
bool Botan::DL_Scheme_PublicKey::check_key ( RandomNumberGenerator rng,
bool  strong 
) const [virtual, inherited]

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::DL_Scheme_PrivateKey, Botan::DSA_PrivateKey, Botan::NR_PrivateKey, and Botan::ElGamal_PrivateKey.

Definition at line 58 of file dl_algo.cpp.

References Botan::DL_Scheme_PublicKey::group, Botan::DL_Scheme_PublicKey::group_p(), and Botan::DL_Group::verify_group().

   {
   if(y < 2 || y >= group_p())
      return false;
   if(!group.verify_group(rng, strong))
      return false;
   return true;
   }
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.

Returns:
estimated strength in bits

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());
   }
const DL_Group& Botan::DL_Scheme_PublicKey::get_domain ( ) const [inline, inherited]

Get the DL domain parameters of this key.

Returns:
DL domain parameters of this key

Definition at line 33 of file dl_algo.h.

{ return group; }
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 BigInt& Botan::DL_Scheme_PublicKey::get_y ( ) const [inline, inherited]

Get the public value y with y = g^x mod p where x is the secret key.

Definition at line 38 of file dl_algo.h.

References y.

{ return y; }

Get the underlying groups encoding format.

Returns:
encoding format

Implements Botan::DL_Scheme_PublicKey.

Definition at line 23 of file nr.h.

References Botan::DL_Group::ANSI_X9_57.

const BigInt& Botan::DL_Scheme_PublicKey::group_g ( ) const [inline, inherited]
const BigInt& Botan::DL_Scheme_PublicKey::group_p ( ) const [inline, inherited]
const BigInt& Botan::DL_Scheme_PublicKey::group_q ( ) const [inline, inherited]

Get the prime q of the underlying DL group.

Returns:
prime q

Definition at line 50 of file dl_algo.h.

Referenced by Botan::NR_PrivateKey::check_key(), Botan::DSA_PrivateKey::check_key(), Botan::DSA_PrivateKey::DSA_PrivateKey(), and Botan::NR_PrivateKey::NR_PrivateKey().

{ return group.get_q(); }
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::NR_PublicKey::max_input_bits ( ) const [inline, virtual]

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 27 of file nr.h.

{ return (group_q().bits() - 1); }
size_t Botan::NR_PublicKey::message_part_size ( ) const [inline, virtual]

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

Returns:
size of the message parts in bits

Reimplemented from Botan::Public_Key.

Definition at line 26 of file nr.h.

{ return group_q().bytes(); }
size_t Botan::NR_PublicKey::message_parts ( ) const [inline, virtual]

Find out the number of message parts supported by this scheme.

Returns:
number of message parts

Reimplemented from Botan::Public_Key.

Definition at line 25 of file nr.h.

{ return 2; }
std::vector< byte > Botan::DL_Scheme_PublicKey::x509_subject_public_key ( ) const [virtual, inherited]
Returns:
X.509 subject key encoding for this key object

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

Member Data Documentation

BigInt Botan::DL_Scheme_PublicKey::y [protected, inherited]

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