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

◆ RW_Verification_Operation()

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

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

Member Function Documentation

◆ max_input_bits()

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

◆ message_part_size()

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

Definition at line 104 of file pk_ops.h.

104{ return 0; }

◆ message_parts()

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

Definition at line 98 of file pk_ops.h.

98{ return 1; }

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

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 }
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_negative().

◆ with_recovery()

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: