Botan  1.11.11
Public Member Functions | List of all members
Botan::GOST_3410_Verification_Operation Class Reference

#include <gost_3410.h>

Inheritance diagram for Botan::GOST_3410_Verification_Operation:
Botan::PK_Ops::Verification

Public Member Functions

 GOST_3410_Verification_Operation (const GOST_3410_PublicKey &gost)
 
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

GOST-34.10 verification operation

Definition at line 118 of file gost_3410.h.

Constructor & Destructor Documentation

Botan::GOST_3410_Verification_Operation::GOST_3410_Verification_Operation ( const GOST_3410_PublicKey gost)

Definition at line 137 of file gost_3410.cpp.

137  :
138  base_point(gost.domain().get_base_point()),
139  public_point(gost.public_point()),
140  order(gost.domain().get_order())
141  {
142  }

Member Function Documentation

size_t Botan::GOST_3410_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 125 of file gost_3410.h.

125 { return order.bits(); }
size_t bits() const
Definition: bigint.cpp:233
size_t Botan::GOST_3410_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 124 of file gost_3410.h.

124 { return order.bytes(); }
size_t bytes() const
Definition: bigint.cpp:225
size_t Botan::GOST_3410_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 123 of file gost_3410.h.

123 { return 2; }
bool Botan::GOST_3410_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 144 of file gost_3410.cpp.

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

146  {
147  if(sig_len != order.bytes()*2)
148  return false;
149 
150  BigInt e = decode_le(msg, msg_len);
151 
152  BigInt s(sig, sig_len / 2);
153  BigInt r(sig + sig_len / 2, sig_len / 2);
154 
155  if(r <= 0 || r >= order || s <= 0 || s >= order)
156  return false;
157 
158  e %= order;
159  if(e == 0)
160  e = 1;
161 
162  BigInt v = inverse_mod(e, order);
163 
164  BigInt z1 = (s*v) % order;
165  BigInt z2 = (-r*v) % order;
166 
167  PointGFp R = multi_exponentiate(base_point, z1,
168  public_point, z2);
169 
170  if(R.is_zero())
171  return false;
172 
173  return (R.get_affine_x() == r);
174  }
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:128
PointGFp multi_exponentiate(const PointGFp &p1, const BigInt &z1, const PointGFp &p2, const BigInt &z2)
Definition: point_gfp.cpp:211
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::GOST_3410_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 127 of file gost_3410.h.

127 { return false; }

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