Botan 1.10.17
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

◆ NR_Verification_Operation()

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

Definition at line 112 of file nr.cpp.

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 }

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

Referenced by Botan::Core_Engine::get_verify_op().

Member Function Documentation

◆ max_input_bits()

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

◆ message_part_size()

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

◆ message_parts()

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

◆ verify()

virtual bool Botan::PK_Ops::Verification::verify ( const byte [],
size_t ,
const byte [],
size_t  )
inlinevirtualinherited

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

Definition at line 120 of file pk_ops.h.

122 {
123 throw Invalid_State("Message recovery required");
124 }
Invalid_State(const std::string &err)
Definition exceptn.h:27

◆ verify_mr()

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.

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 }
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition big_code.cpp:64
std::invalid_argument Invalid_Argument
Definition exceptn.h:20

References Botan::BigInt::encode(), and Botan::BigInt::is_zero().

◆ with_recovery()

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: