Botan 1.10.17

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

`#include <nr.h>`

Inheritance diagram for Botan::NR_Verification_Operation:

## 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< byte > | verify_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.

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

## ◆ max_input_bits()

size_t Botan::NR_Verification_Operation::max_input_bits | ( |  | ) | const
| inline virtual

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); }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254

## ◆ message_part_size()

size_t Botan::NR_Verification_Operation::message_part_size | ( |  | ) | const
| inline virtual

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(); }
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:246

## ◆ message_parts()

size_t Botan::NR_Verification_Operation::message_parts | ( |  | ) | const
| inline virtual

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 |
| ) |  |
| inline virtual inherited

Reimplemented in 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 }

## ◆ 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.

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 }
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::BigInt::encode
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:64
Botan::Modular_Reducer::get_modulus
const BigInt & get_modulus() const
Definition: reducer.h:21
Botan::Modular_Reducer::reduce
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
Botan::Modular_Reducer::multiply
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31

## ◆ with_recovery()

bool Botan::NR_Verification_Operation::with_recovery | ( |  | ) | const
| inline virtual

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:

- src/pubkey/nr/nr.h
- src/pubkey/nr/nr.cpp