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

#include <gost_3410.h>

Inheritance diagram for Botan::GOST_3410_Signature_Operation:
Botan::PK_Ops::Signature

Public Member Functions

 GOST_3410_Signature_Operation (const GOST_3410_PrivateKey &gost_3410)
 
size_t max_input_bits () const
 
size_t message_part_size () const
 
size_t message_parts () const
 
SecureVector< bytesign (const byte msg[], size_t msg_len, RandomNumberGenerator &rng)
 

Detailed Description

GOST-34.10 signature operation

Definition at line 97 of file gost_3410.h.

Constructor & Destructor Documentation

Botan::GOST_3410_Signature_Operation::GOST_3410_Signature_Operation ( const GOST_3410_PrivateKey gost_3410)

Definition at line 96 of file gost_3410.cpp.

97  :
98 
99  base_point(gost_3410.domain().get_base_point()),
100  order(gost_3410.domain().get_order()),
101  x(gost_3410.private_value())
102  {
103  }

Member Function Documentation

size_t Botan::GOST_3410_Signature_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::Signature.

Definition at line 104 of file gost_3410.h.

104 { return order.bits(); }
size_t bits() const
Definition: bigint.cpp:253
size_t Botan::GOST_3410_Signature_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::Signature.

Definition at line 103 of file gost_3410.h.

103 { return order.bytes(); }
size_t bytes() const
Definition: bigint.cpp:245
size_t Botan::GOST_3410_Signature_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::Signature.

Definition at line 102 of file gost_3410.h.

102 { return 2; }
SecureVector< byte > Botan::GOST_3410_Signature_Operation::sign ( const byte  msg[],
size_t  msg_len,
RandomNumberGenerator rng 
)
virtual

Implements Botan::PK_Ops::Signature.

Definition at line 106 of file gost_3410.cpp.

References Botan::BigInt::binary_encode(), Botan::BigInt::bits(), BOTAN_ASSERT, Botan::BigInt::bytes(), Botan::PointGFp::get_affine_x(), Botan::PointGFp::on_the_curve(), r, Botan::BigInt::randomize(), and s.

108  {
109  BigInt k;
110  do
111  k.randomize(rng, order.bits()-1);
112  while(k >= order);
113 
114  BigInt e = decode_le(msg, msg_len);
115 
116  e %= order;
117  if(e == 0)
118  e = 1;
119 
120  PointGFp k_times_P = base_point * k;
121 
122  BOTAN_ASSERT(k_times_P.on_the_curve(),
123  "GOST 34.10 k*g not on the curve");
124 
125  BigInt r = k_times_P.get_affine_x() % order;
126 
127  BigInt s = (r*x + k*e) % order;
128 
129  if(r == 0 || s == 0)
130  throw Invalid_State("GOST 34.10: r == 0 || s == 0");
131 
132  SecureVector<byte> output(2*order.bytes());
133  s.binary_encode(&output[output.size() / 2 - s.bytes()]);
134  r.binary_encode(&output[output.size() - r.bytes()]);
135  return output;
136  }
#define BOTAN_ASSERT(expr, msg)
Definition: assert.h:19
size_t bits() const
Definition: bigint.cpp:253
RandomNumberGenerator * rng
Definition: global_rng.cpp:165
BigInt r
Definition: numthry.cpp:26
size_t s
Definition: numthry.cpp:27
size_t bytes() const
Definition: bigint.cpp:245

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