Botan: Botan::DSA_Signature_Operation Class Reference

Botan 1.10.17

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

`#include <dsa.h>`

Inheritance diagram for Botan::DSA_Signature_Operation:

## Public Member Functions
| DSA_Signature_Operation (const DSA_PrivateKey &dsa)
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

Object that can create a DSA signature

Definition at line 63 of file dsa.h.

## Constructor & Destructor Documentation

## ◆ DSA_Signature_Operation()

Botan::DSA_Signature_Operation::DSA_Signature_Operation | ( | const DSA_PrivateKey & | dsa | ) |

Definition at line 68 of file dsa.cpp.

68 :
69 q(dsa.group_q()),
70 x(dsa.get_x()),
71 powermod_g_p(dsa.group_g(), dsa.group_p()),
72 mod_q(dsa.group_q())
73 {
74 }

## Member Function Documentation

## ◆ max_input_bits()

size_t Botan::DSA_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 70 of file dsa.h.

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

## ◆ message_part_size()

size_t Botan::DSA_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 69 of file dsa.h.

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

## ◆ message_parts()

size_t Botan::DSA_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 68 of file dsa.h.

68 { return 2; }

## ◆ sign()

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

Implements Botan::PK_Ops::Signature.

Definition at line 77 of file dsa.cpp.

79 {
80 rng.add_entropy(msg, msg_len);
81
82 BigInt i(msg, msg_len);
83 BigInt r = 0, s = 0;
84
85 while(r == 0 || s == 0)
86 {
87 BigInt k;
88 do
89 k.randomize(rng, q.bits());
90 while(k >= q);
91
92 r = mod_q.reduce(powermod_g_p(k));
93 s = mod_q.multiply(inverse_mod(k, q), mul_add(x, r, i));
94 }
95
96 SecureVector<byte> output(2*q.bytes());
97 r.binary_encode(&output[output.size() / 2 - r.bytes()]);
98 s.binary_encode(&output[output.size() - s.bytes()]);
99 return output;
100 }
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/dsa/dsa.h
- src/pubkey/dsa/dsa.cpp