Botan  1.10.9
Public Member Functions | List of all members
Botan::NR_Verification_Operation Class Reference

#include <nr.h>

Inheritance diagram for Botan::NR_Verification_Operation:
Botan::PK_Ops::Verification

Public Member Functions

size_t max_input_bits () const
 
size_t message_part_size () const
 
size_t message_parts () const
 
 NR_Verification_Operation (const NR_PublicKey &nr)
 
virtual bool verify (const byte[], size_t, const byte[], size_t)
 
SecureVector< byteverify_mr (const byte msg[], size_t msg_len)
 
bool with_recovery () const
 

Detailed Description

Nyberg-Rueppel verification operation

Definition at line 82 of file nr.h.

Constructor & Destructor Documentation

Botan::NR_Verification_Operation::NR_Verification_Operation ( const NR_PublicKey nr)

Definition at line 112 of file nr.cpp.

References Botan::DL_Scheme_PublicKey::group_g(), Botan::DL_Scheme_PublicKey::group_p(), and Botan::DL_Scheme_PublicKey::group_q().

112  :
113  q(nr.group_q()), y(nr.get_y())
114  {
115  powermod_g_p = Fixed_Base_Power_Mod(nr.group_g(), nr.group_p());
116  powermod_y_p = Fixed_Base_Power_Mod(y, nr.group_p());
117  mod_p = Modular_Reducer(nr.group_p());
118  mod_q = Modular_Reducer(nr.group_q());
119  }

Member Function Documentation

size_t Botan::NR_Verification_Operation::max_input_bits ( ) const
inlinevirtual

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

Returns
maximum message in bits

Implements Botan::PK_Ops::Verification.

Definition at line 89 of file nr.h.

89 { return (q.bits() - 1); }
size_t bits() const
Definition: bigint.cpp:253
size_t Botan::NR_Verification_Operation::message_part_size ( ) const
inlinevirtual

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

Returns
size of the message parts

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 88 of file nr.h.

88 { return q.bytes(); }
size_t bytes() const
Definition: bigint.cpp:245
size_t Botan::NR_Verification_Operation::message_parts ( ) const
inlinevirtual

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

Returns
number of message parts

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 87 of file nr.h.

87 { return 2; }
virtual bool Botan::PK_Ops::Verification::verify ( const byte  [],
size_t  ,
const byte  [],
size_t   
)
inlinevirtualinherited

Reimplemented in Botan::GOST_3410_Verification_Operation, Botan::ECDSA_Verification_Operation, and Botan::DSA_Verification_Operation.

Definition at line 120 of file pk_ops.h.

122  {
123  throw Invalid_State("Message recovery required");
124  }
SecureVector< byte > Botan::NR_Verification_Operation::verify_mr ( const byte  msg[],
size_t  msg_len 
)
virtual

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 122 of file nr.cpp.

References Botan::BigInt::bytes(), Botan::BigInt::encode(), Botan::Modular_Reducer::get_modulus(), Botan::Modular_Reducer::multiply(), and Botan::Modular_Reducer::reduce().

123  {
124  const BigInt& q = mod_q.get_modulus();
125 
126  if(msg_len != 2*q.bytes())
127  throw Invalid_Argument("NR verification: Invalid signature");
128 
129  BigInt c(msg, q.bytes());
130  BigInt d(msg + q.bytes(), q.bytes());
131 
132  if(c.is_zero() || c >= q || d >= q)
133  throw Invalid_Argument("NR verification: Invalid signature");
134 
135  BigInt i = mod_p.multiply(powermod_g_p(d), powermod_y_p(c));
136  return BigInt::encode(mod_q.reduce(c - i));
137  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
const BigInt & get_modulus() const
Definition: reducer.h:21
bool Botan::NR_Verification_Operation::with_recovery ( ) const
inlinevirtual
Returns
boolean specifying if this key type supports message recovery and thus if you need to call verify() or verify_mr()

Implements Botan::PK_Ops::Verification.

Definition at line 91 of file nr.h.

91 { return true; }

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