Botan  1.10.9
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)
 
SecureVector< 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.

References n.

95 { return (n.bits() - 1); }
size_t bits() const
Definition: bigint.cpp:253
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::GOST_3410_Verification_Operation, Botan::ECDSA_Verification_Operation, Botan::DSA_Verification_Operation, and Botan::NR_Verification_Operation.

Definition at line 104 of file pk_ops.h.

Referenced by Botan::PK_Verifier::check_signature().

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::GOST_3410_Verification_Operation, Botan::ECDSA_Verification_Operation, Botan::DSA_Verification_Operation, and Botan::NR_Verification_Operation.

Definition at line 98 of file pk_ops.h.

Referenced by Botan::PK_Verifier::check_signature(), and Botan::PK_Verifier::set_input_format().

98 { return 1; }
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::RW_Verification_Operation::verify_mr ( const byte  msg[],
size_t  msg_len 
)
virtual

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 105 of file rw.cpp.

References Botan::BigInt::encode(), Botan::BigInt::is_negative(), and r.

106  {
107  BigInt m(msg, msg_len);
108 
109  if((m > (n >> 1)) || m.is_negative())
110  throw Invalid_Argument("RW signature verification: m > n / 2 || m < 0");
111 
112  BigInt r = powermod_e_n(m);
113  if(r % 16 == 12)
114  return BigInt::encode(r);
115  if(r % 8 == 6)
116  return BigInt::encode(2*r);
117 
118  r = n - r;
119  if(r % 16 == 12)
120  return BigInt::encode(r);
121  if(r % 8 == 6)
122  return BigInt::encode(2*r);
123 
124  throw Invalid_Argument("RW signature verification: Invalid signature");
125  }
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 r
Definition: numthry.cpp:26
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: