Botan  1.11.10
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)
 
secure_vector< 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 113 of file nr.cpp.

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

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

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:233
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:225
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  }
secure_vector< byte > Botan::NR_Verification_Operation::verify_mr ( const byte  msg[],
size_t  msg_len 
)
virtual

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 123 of file nr.cpp.

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

124  {
125  const BigInt& q = mod_q.get_modulus();
126 
127  if(msg_len != 2*q.bytes())
128  throw Invalid_Argument("NR verification: Invalid signature");
129 
130  BigInt c(msg, q.bytes());
131  BigInt d(msg + q.bytes(), q.bytes());
132 
133  if(c.is_zero() || c >= q || d >= q)
134  throw Invalid_Argument("NR verification: Invalid signature");
135 
136  auto future_y_c = std::async(std::launch::async, powermod_y_p, c);
137  BigInt g_d = powermod_g_p(d);
138 
139  BigInt i = mod_p.multiply(g_d, future_y_c.get());
140  return BigInt::encode_locked(mod_q.reduce(c - i));
141  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
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
static secure_vector< byte > encode_locked(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:68
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: