Botan
2.1.0
Crypto and TLS for C++11
|
#include <rdrand_rng.h>
Public Member Functions | |
void | add_entropy (const uint8_t[], size_t) override |
template<typename T > | |
void | add_entropy_T (const T &t) |
void | clear () override |
bool | is_seeded () const override |
std::string | name () const override |
uint8_t | next_byte () |
uint8_t | next_nonzero_byte () |
secure_vector< uint8_t > | random_vec (size_t bytes) |
void | randomize (uint8_t out[], size_t out_len) override |
virtual void | randomize_with_input (uint8_t output[], size_t output_len, const uint8_t input[], size_t input_len) |
virtual void | randomize_with_ts_input (uint8_t output[], size_t output_len) |
RDRAND_RNG () | |
size_t | reseed (Entropy_Sources &, size_t, std::chrono::milliseconds) override |
virtual void | reseed_from_rng (RandomNumberGenerator &rng, size_t poll_bits=BOTAN_RNG_RESEED_POLL_BITS) |
Static Public Member Functions | |
static RandomNumberGenerator * | make_rng () |
static uint32_t | rdrand () |
static uint32_t | rdrand_status (bool &ok) |
Definition at line 15 of file rdrand_rng.h.
Botan::RDRAND_RNG::RDRAND_RNG | ( | ) |
Constructor will throw if CPU does not have RDRAND bit set
Definition at line 18 of file rdrand_rng.cpp.
|
inlineoverridevirtual |
Incorporate some additional data into the RNG state. For example adding nonces or timestamps from a peer's protocol message can help hedge against VM state rollback attacks. A few RNG types do not accept any externally provided input, in which case this function is a no-op.
input | a byte array containg the entropy to be added |
length | the length of the byte array in |
Implements Botan::RandomNumberGenerator.
Definition at line 45 of file rdrand_rng.h.
|
inlineinherited |
Incorporate some additional data into the RNG state.
Definition at line 60 of file rng.h.
Referenced by Botan::Win32_EntropySource::poll().
|
inlineoverridevirtual |
Clear all internally held values of this RNG
Implements Botan::RandomNumberGenerator.
Definition at line 58 of file rdrand_rng.h.
|
inlineoverridevirtual |
Check whether this RNG is seeded.
Implements Botan::RandomNumberGenerator.
Definition at line 56 of file rdrand_rng.h.
|
staticinherited |
Create a seeded and active RNG object for general application use Added in 1.8.0 Use AutoSeeded_RNG instead
|
inlineoverridevirtual |
Implements Botan::RandomNumberGenerator.
Definition at line 54 of file rdrand_rng.h.
|
inlineinherited |
Return a random byte
Definition at line 144 of file rng.h.
Referenced by Botan::Blinded_Point_Multiply::blinded_multiply(), and Botan::random_prime().
|
inlineinherited |
|
inlineinherited |
Return a random vector
bytes | number of bytes in the result |
Definition at line 133 of file rng.h.
Referenced by Botan::CECPQ1_accept(), Botan::CECPQ1_offer(), Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::Curve25519_PrivateKey::Curve25519_PrivateKey(), Botan::PK_Decryptor::decrypt_or_random(), Botan::TLS::Session::encrypt(), Botan::KeyPair::encryption_consistency_check(), Botan::generate_bcrypt(), Botan::mceies_encrypt(), Botan::OctetString::OctetString(), Botan::BigInt::randomize(), Botan::TLS::Session_Manager_In_Memory::remove_all(), and Botan::TLS::Session_Manager_SQL::Session_Manager_SQL().
|
overridevirtual |
Uses RDRAND to produce output
Implements Botan::RandomNumberGenerator.
Definition at line 66 of file rdrand_rng.cpp.
References Botan::get_byte(), rdrand(), and Botan::store_le().
Referenced by Botan::Intel_Rdrand::poll().
|
virtualinherited |
Incorporate entropy into the RNG state then produce output. Some RNG types implement this using a single operation, default calls add_entropy + randomize in sequence.
Use this to further bind the outputs to your current process/protocol state. For instance if generating a new key for use in a session, include a session ID or other such value. See NIST SP 800-90 A, B, C series for more ideas.
output | buffer to hold the random output |
output_len | size of the output buffer in bytes |
input | entropy buffer to incorporate |
input_len | size of the input buffer in bytes |
Reimplemented in Botan::HMAC_DRBG, and Botan::AutoSeeded_RNG.
Definition at line 30 of file rng.cpp.
References Botan::RandomNumberGenerator::add_entropy(), and Botan::RandomNumberGenerator::randomize().
Referenced by Botan::Stateful_RNG::randomize_with_ts_input(), and Botan::RandomNumberGenerator::randomize_with_ts_input().
|
virtualinherited |
This calls randomize_with_input
using some timestamps as extra input.
For a stateful RNG using non-random but potentially unique data the extra input can help protect against problems with fork, VM state rollback, or other cases where somehow an RNG state is duplicated. If both of the duplicated RNG states later incorporate a timestamp (and the timestamps don't themselves repeat), their outputs will diverge.
Reimplemented in Botan::Stateful_RNG.
Definition at line 17 of file rng.cpp.
References Botan::OS::get_high_resolution_clock(), Botan::OS::get_system_timestamp_ns(), Botan::RandomNumberGenerator::randomize_with_input(), and Botan::store_le().
Referenced by Botan::AutoSeeded_RNG::randomize().
|
static |
Definition at line 25 of file rdrand_rng.cpp.
References rdrand_status().
Referenced by randomize().
|
static |
On correctly working hardware, RDRAND is always supposed to succeed within a set number of retries. If after that many retries RDRAND has still not suceeded, sets ok = false and returns 0.
Definition at line 40 of file rdrand_rng.cpp.
Referenced by rdrand().
|
inlineoverridevirtual |
Poll provided sources for up to poll_bits bits of entropy or until the timeout expires. Returns estimate of the number of bits collected.
Reimplemented from Botan::RandomNumberGenerator.
Definition at line 51 of file rdrand_rng.h.
|
virtualinherited |
Reseed by reading specified bits from the RNG
Reimplemented in Botan::Stateful_RNG.
Definition at line 44 of file rng.cpp.
References Botan::RandomNumberGenerator::add_entropy(), and Botan::RandomNumberGenerator::randomize().
Referenced by botan_rng_reseed(), and Botan::Stateful_RNG::reseed_from_rng().