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

#include <rw.h>

Inheritance diagram for Botan::RW_Verification_Operation:
Botan::PK_Ops::Verification

Public Member Functions

size_t max_input_bits () const
 
virtual size_t message_part_size () const
 
virtual size_t message_parts () const
 
 RW_Verification_Operation (const RW_PublicKey &rw)
 
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

Rabin-Williams Verification Operation

Definition at line 88 of file rw.h.

Constructor & Destructor Documentation

Botan::RW_Verification_Operation::RW_Verification_Operation ( const RW_PublicKey rw)
inline

Definition at line 91 of file rw.h.

91  :
92  n(rw.get_n()), powermod_e_n(rw.get_e(), rw.get_n())
93  {}

Member Function Documentation

size_t Botan::RW_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 95 of file rw.h.

95 { return (n.bits() - 1); }
size_t bits() const
Definition: bigint.cpp:233
virtual size_t Botan::PK_Ops::Verification::message_part_size ( ) const
inlinevirtualinherited

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

Returns
size of the message parts

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

Definition at line 104 of file pk_ops.h.

104 { return 0; }
virtual size_t Botan::PK_Ops::Verification::message_parts ( ) const
inlinevirtualinherited

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

Returns
number of message parts

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

Definition at line 98 of file pk_ops.h.

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

Reimplemented in Botan::ECDSA_Verification_Operation, Botan::GOST_3410_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::RW_Verification_Operation::verify_mr ( const byte  msg[],
size_t  msg_len 
)
virtual

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 108 of file rw.cpp.

References Botan::BigInt::encode_locked(), and Botan::BigInt::is_negative().

109  {
110  BigInt m(msg, msg_len);
111 
112  if((m > (n >> 1)) || m.is_negative())
113  throw Invalid_Argument("RW signature verification: m > n / 2 || m < 0");
114 
115  BigInt r = powermod_e_n(m);
116  if(r % 16 == 12)
117  return BigInt::encode_locked(r);
118  if(r % 8 == 6)
119  return BigInt::encode_locked(2*r);
120 
121  r = n - r;
122  if(r % 16 == 12)
123  return BigInt::encode_locked(r);
124  if(r % 8 == 6)
125  return BigInt::encode_locked(2*r);
126 
127  throw Invalid_Argument("RW signature verification: Invalid signature");
128  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
static secure_vector< byte > encode_locked(const BigInt &n, Base base=Binary)
Definition: big_code.cpp:68
bool Botan::RW_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 96 of file rw.h.

96 { return true; }

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