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

◆ DSA_Verification_Operation()

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

Definition at line 102 of file dsa.cpp.

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 }

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

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

Member Function Documentation

◆ max_input_bits()

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

◆ message_part_size()

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

◆ message_parts()

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

◆ verify()

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.

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 inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314

References Botan::inverse_mod().

◆ verify_mr()

virtual SecureVector< byte > Botan::PK_Ops::Verification::verify_mr ( const byte [],
size_t  )
inlinevirtualinherited

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

Definition at line 133 of file pk_ops.h.

135 {
136 throw Invalid_State("Message recovery not supported");
137 }
Invalid_State(const std::string &err)
Definition exceptn.h:27

◆ with_recovery()

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: