Botan 1.10.17
Botan::ECDSA_Verification_Operation Class Reference

#include <ecdsa.h>

Inheritance diagram for Botan::ECDSA_Verification_Operation:
Botan::PK_Ops::Verification

Public Member Functions

 ECDSA_Verification_Operation (const ECDSA_PublicKey &ecdsa)
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

ECDSA verification operation

Definition at line 117 of file ecdsa.h.

Constructor & Destructor Documentation

◆ ECDSA_Verification_Operation()

Botan::ECDSA_Verification_Operation::ECDSA_Verification_Operation ( const ECDSA_PublicKey & ecdsa)

Definition at line 65 of file ecdsa.cpp.

65 :
66 base_point(ecdsa.domain().get_base_point()),
67 public_point(ecdsa.public_point()),
68 order(ecdsa.domain().get_order())
69 {
70 }

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

Member Function Documentation

◆ max_input_bits()

size_t Botan::ECDSA_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 124 of file ecdsa.h.

124{ return order.bits(); }

◆ message_part_size()

size_t Botan::ECDSA_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 123 of file ecdsa.h.

123{ return order.bytes(); }

◆ message_parts()

size_t Botan::ECDSA_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 122 of file ecdsa.h.

122{ return 2; }

◆ verify()

bool Botan::ECDSA_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 72 of file ecdsa.cpp.

74 {
75 if(sig_len != order.bytes()*2)
76 return false;
77
78 BigInt e(msg, msg_len);
79
80 BigInt r(sig, sig_len / 2);
81 BigInt s(sig + sig_len / 2, sig_len / 2);
82
83 if(r <= 0 || r >= order || s <= 0 || s >= order)
84 return false;
85
86 BigInt w = inverse_mod(s, order);
87
88 PointGFp R = w * multi_exponentiate(base_point, e,
89 public_point, r);
90
91 if(R.is_zero())
92 return false;
93
94 return (R.get_affine_x() % order == r);
95 }
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition numthry.cpp:314
PointGFp multi_exponentiate(const PointGFp &p1, const BigInt &z1, const PointGFp &p2, const BigInt &z2)

References Botan::PointGFp::get_affine_x(), Botan::inverse_mod(), Botan::PointGFp::is_zero(), and Botan::multi_exponentiate().

◆ 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::ECDSA_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 126 of file ecdsa.h.

126{ return false; }

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