Botan 1.10.17

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

`#include <ecdsa.h>`

Inheritance diagram for Botan::ECDSA_Signature_Operation:

## Public Member Functions
| ECDSA_Signature_Operation (const ECDSA_PrivateKey &ecdsa)
size_t | max_input_bits () const
size_t | message_part_size () const
size_t | message_parts () const
SecureVector< byte > | sign (const byte msg[], size_t msg_len, RandomNumberGenerator &rng)

## Detailed Description

ECDSA signature operation

Definition at line 95 of file ecdsa.h.

## Constructor & Destructor Documentation

## ◆ ECDSA_Signature_Operation()

Botan::ECDSA_Signature_Operation::ECDSA_Signature_Operation | ( | const ECDSA_PrivateKey & | ecdsa | ) |

Definition at line 27 of file ecdsa.cpp.

27 :
28 base_point(ecdsa.domain().get_base_point()),
29 order(ecdsa.domain().get_order()),
30 x(ecdsa.private_value()),
31 mod_order(order)
32 {
33 }

## Member Function Documentation

## ◆ max_input_bits()

size_t Botan::ECDSA_Signature_Operation::max_input_bits | ( |  | ) | const
| inline virtual

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 105 of file ecdsa.h.

105 { return order.bits(); }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254

## ◆ message_part_size()

size_t Botan::ECDSA_Signature_Operation::message_part_size | ( |  | ) | const
| inline virtual

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 104 of file ecdsa.h.

104 { return order.bytes(); }
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:246

## ◆ message_parts()

size_t Botan::ECDSA_Signature_Operation::message_parts | ( |  | ) | const
| inline virtual

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 103 of file ecdsa.h.

103 { return 2; }

## ◆ sign()

SecureVector< byte > Botan::ECDSA_Signature_Operation::sign | ( | const byte | msg[],
|  | size_t | msg_len,
|  | RandomNumberGenerator & | rng
| ) |  |
| virtual

Implements Botan::PK_Ops::Signature.

Definition at line 36 of file ecdsa.cpp.

38 {
39 rng.add_entropy(msg, msg_len);
40
41 BigInt m(msg, msg_len);
42
43 BigInt r = 0, s = 0;
44
45 while(r == 0 || s == 0)
46 {
47 // This contortion is necessary for the tests
48 BigInt k;
49 k.randomize(rng, order.bits());
50
51 while(k >= order)
52 k.randomize(rng, order.bits() - 1);
53
54 PointGFp k_times_P = base_point * k;
55 r = mod_order.reduce(k_times_P.get_affine_x());
56 s = mod_order.multiply(inverse_mod(k, order), mul_add(x, r, m));
57 }
58
59 SecureVector<byte> output(2*order.bytes());
60 r.binary_encode(&output[output.size() / 2 - r.bytes()]);
61 s.binary_encode(&output[output.size() - s.bytes()]);
62 return output;
63 }
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:254
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:246
Botan::inverse_mod
BigInt inverse_mod(const BigInt &n, const BigInt &mod)
Definition: numthry.cpp:314
Botan::Modular_Reducer::reduce
BigInt reduce(const BigInt &x) const
Definition: reducer.cpp:32
Botan::Modular_Reducer::multiply
BigInt multiply(const BigInt &x, const BigInt &y) const
Definition: reducer.h:31
Botan::mul_add
BigInt mul_add(const BigInt &a, const BigInt &b, const BigInt &c)
Definition: mp_numth.cpp:33

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

- src/pubkey/ecdsa/ecdsa.h
- src/pubkey/ecdsa/ecdsa.cpp