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

#include <dsa.h>

Inheritance diagram for Botan::DSA_Verification_Operation:
Botan::PK_Ops::Verification

Public Member Functions

 DSA_Verification_Operation (const DSA_PublicKey &dsa)
 
size_t max_input_bits () const
 
size_t message_part_size () const
 
size_t message_parts () const
 
bool verify (const byte msg[], size_t msg_len, const byte sig[], size_t sig_len)
 
virtual SecureVector< byteverify_mr (const byte[], size_t)
 
bool with_recovery () const
 

Detailed Description

Object that can verify a DSA signature

Definition at line 84 of file dsa.h.

Constructor & Destructor Documentation

Botan::DSA_Verification_Operation::DSA_Verification_Operation ( const DSA_PublicKey dsa)

Definition at line 102 of file dsa.cpp.

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

102  :
103  q(dsa.group_q()), y(dsa.get_y())
104  {
105  powermod_g_p = Fixed_Base_Power_Mod(dsa.group_g(), dsa.group_p());
106  powermod_y_p = Fixed_Base_Power_Mod(y, dsa.group_p());
107  mod_p = Modular_Reducer(dsa.group_p());
108  mod_q = Modular_Reducer(dsa.group_q());
109  }

Member Function Documentation

size_t Botan::DSA_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 91 of file dsa.h.

91 { return q.bits(); }
size_t bits() const
Definition: bigint.cpp:253
size_t Botan::DSA_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 90 of file dsa.h.

90 { return q.bytes(); }
size_t bytes() const
Definition: bigint.cpp:245
size_t Botan::DSA_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 89 of file dsa.h.

89 { return 2; }
bool Botan::DSA_Verification_Operation::verify ( const byte  msg[],
size_t  msg_len,
const byte  sig[],
size_t  sig_len 
)
virtual

Reimplemented from Botan::PK_Ops::Verification.

Definition at line 111 of file dsa.cpp.

References Botan::BigInt::bytes(), Botan::Modular_Reducer::get_modulus(), Botan::inverse_mod(), Botan::Modular_Reducer::multiply(), r, Botan::Modular_Reducer::reduce(), and s.

113  {
114  const BigInt& q = mod_q.get_modulus();
115 
116  if(sig_len != 2*q.bytes() || msg_len > q.bytes())
117  return false;
118 
119  BigInt r(sig, q.bytes());
120  BigInt s(sig + q.bytes(), q.bytes());
121  BigInt i(msg, msg_len);
122 
123  if(r <= 0 || r >= q || s <= 0 || s >= q)
124  return false;
125 
126  s = inverse_mod(s, q);
127  s = mod_p.multiply(powermod_g_p(mod_q.multiply(s, i)),
128  powermod_y_p(mod_q.multiply(s, r)));
129 
130  return (mod_q.reduce(s) == r);
131  }
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:202
BigInt r
Definition: numthry.cpp:26
const BigInt & get_modulus() const
Definition: reducer.h:21
size_t s
Definition: numthry.cpp:27
virtual SecureVector<byte> Botan::PK_Ops::Verification::verify_mr ( const byte  [],
size_t   
)
inlinevirtualinherited

Reimplemented in Botan::RSA_Public_Operation, Botan::RW_Verification_Operation, and Botan::NR_Verification_Operation.

Definition at line 133 of file pk_ops.h.

135  {
136  throw Invalid_State("Message recovery not supported");
137  }
bool Botan::DSA_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 93 of file dsa.h.

93 { return false; }

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