Botan  1.11.10
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 secure_vector< 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 106 of file dsa.cpp.

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

106  :
107  q(dsa.group_q()), y(dsa.get_y())
108  {
109  powermod_g_p = Fixed_Base_Power_Mod(dsa.group_g(), dsa.group_p());
110  powermod_y_p = Fixed_Base_Power_Mod(y, dsa.group_p());
111  mod_p = Modular_Reducer(dsa.group_p());
112  mod_q = Modular_Reducer(dsa.group_q());
113  }

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:233
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:225
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 115 of file dsa.cpp.

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

117  {
118  if(sig_len != 2*q.bytes() || msg_len > q.bytes())
119  return false;
120 
121  BigInt r(sig, q.bytes());
122  BigInt s(sig + q.bytes(), q.bytes());
123  BigInt i(msg, msg_len);
124 
125  if(r <= 0 || r >= q || s <= 0 || s >= q)
126  return false;
127 
128  s = inverse_mod(s, q);
129 
130  auto future_s_i = std::async(std::launch::async,
131  [&]() { return powermod_g_p(mod_q.multiply(s, i)); });
132 
133  BigInt s_r = powermod_y_p(mod_q.multiply(s, r));
134  BigInt s_i = future_s_i.get();
135 
136  s = mod_p.multiply(s_i, s_r);
137 
138  return (mod_q.reduce(s) == r);
139  }
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:128
size_t bytes() const
Definition: bigint.cpp:225
virtual secure_vector<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: