Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <rfc6979.h>`

## Public Member Functions
const BigInt & | nonce_for (const BigInt &m)
| RFC6979_Nonce_Generator (const std::string &hash, const BigInt &order, const BigInt &x)
| ~RFC6979_Nonce_Generator ()

## Detailed Description

Definition at line 19 of file rfc6979.h.

## Constructor & Destructor Documentation

Botan::RFC6979_Nonce_Generator::RFC6979_Nonce_Generator | ( | const std::string & | hash,
|  | const BigInt & | order,
|  | const BigInt & | x
| ) |  |

Note: keeps persistent reference to order

Definition at line 14 of file rfc6979.cpp.

References Botan::MessageAuthenticationCode::create(), and Botan::BigInt::encode_1363().

16 :
17 m_order(order),
18 m_qlen(m_order.bits()),
19 m_rlen(m_qlen / 8 + (m_qlen % 8 ? 1 : 0)),
20 m_rng_in(m_rlen * 2),
21 m_rng_out(m_rlen)
22 {
23 m_hmac_drbg.reset(new HMAC_DRBG(MessageAuthenticationCode::create("HMAC(" + hash + ")")));
24 BigInt::encode_1363(m_rng_in.data(), m_rlen, x);
25 }
Botan::MessageAuthenticationCode::create
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:43
Botan::BigInt::bits
size_t bits() const
Definition: bigint.cpp:184
Botan::BigInt::encode_1363
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:82
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

Botan::RFC6979_Nonce_Generator::~RFC6979_Nonce_Generator | ( |  | ) |

Definition at line 27 of file rfc6979.cpp.

28 {
29 // for ~unique_ptr
30 }

## Member Function Documentation

const BigInt & Botan::RFC6979_Nonce_Generator::nonce_for | ( | const BigInt & | m | ) |

Definition at line 32 of file rfc6979.cpp.

References Botan::BigInt::binary_decode(), and Botan::BigInt::encode_1363().

Referenced by Botan::generate_rfc6979_nonce().

33 {
34 BigInt::encode_1363(&m_rng_in[m_rlen], m_rlen, m);
35 m_hmac_drbg->clear();
36 m_hmac_drbg->initialize_with(m_rng_in.data(), m_rng_in.size());
37
38 do
39 {
40 m_hmac_drbg->randomize(m_rng_out.data(), m_rng_out.size());
41 m_k.binary_decode(m_rng_out.data(), m_rng_out.size());
42 m_k >>= (8*m_rlen - m_qlen);
43 }
44 while(m_k == 0 || m_k >= m_order);
45
46 return m_k;
47 }
Botan::BigInt::binary_decode
void binary_decode(const uint8_t buf[], size_t length)
Definition: bigint.cpp:280
Botan::BigInt::encode_1363
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:82

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

- src/lib/pubkey/rfc6979/rfc6979.h
- src/lib/pubkey/rfc6979/rfc6979.cpp