Botan 2.19.2
Crypto and TLS for C&
|
A random generator that only fetches random from the PKCS#11 RNG. More...
#include <p11_randomgenerator.h>
Public Member Functions | |
bool | accepts_input () const override |
void | add_entropy (const uint8_t in[], std::size_t length) override |
Calls C_SeedRandom to add entropy to the random generation function of the token/middleware. More... | |
virtual void | add_entropy (const uint8_t input[], size_t length)=0 |
template<typename T > | |
void | add_entropy_T (const T &t) |
virtual void | clear () final override |
bool | is_seeded () const override |
Always returns true. More... | |
Module & | module () const |
std::string | name () const override |
uint8_t | next_byte () |
uint8_t | next_nonzero_byte () |
PKCS11_RNG (Session &session) | |
Initialize the RNG with the PKCS#11 session that provides access to the cryptoki functions. More... | |
secure_vector< uint8_t > | random_vec (size_t bytes) |
template<typename Alloc > | |
void | random_vec (std::vector< uint8_t, Alloc > &v, size_t bytes) |
virtual void | randomize (uint8_t output[], size_t length)=0 |
void | randomize (uint8_t output[], std::size_t length) override |
Calls C_GenerateRandom to generate random data. More... | |
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) |
size_t | reseed (Entropy_Sources &, size_t, std::chrono::milliseconds) override |
No operation - always returns 0. More... | |
virtual void | reseed_from_rng (RandomNumberGenerator &rng, size_t poll_bits=BOTAN_RNG_RESEED_POLL_BITS) |
Static Public Member Functions | |
static RandomNumberGenerator * | make_rng () |
A random generator that only fetches random from the PKCS#11 RNG.
Definition at line 25 of file p11_randomgenerator.h.
|
explicit |
Initialize the RNG with the PKCS#11 session that provides access to the cryptoki functions.
Definition at line 15 of file p11_randomgenerator.cpp.
|
inlineoverridevirtual |
Returns false if it is known that this RNG object is not able to accept externally provided inputs (via add_entropy, randomize_with_input, etc). In this case, any such provided inputs are ignored.
If this function returns true, then inputs may or may not be accepted.
Implements Botan::RandomNumberGenerator.
Definition at line 61 of file p11_randomgenerator.h.
|
override |
Calls C_SeedRandom
to add entropy to the random generation function of the token/middleware.
Definition at line 24 of file p11_randomgenerator.cpp.
References Botan::PKCS11::LowLevel::C_SeedRandom(), and module().
|
pure virtualinherited |
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 |
Implemented in Botan::TPM_RNG, Botan::AutoSeeded_RNG, Botan::System_RNG, Botan::Stateful_RNG, Botan::Processor_RNG, Botan::RDRAND_RNG, and Botan::Null_RNG.
Referenced by Botan::System_RNG::add_entropy(), botan_rng_add_entropy(), Botan::Device_EntropySource::poll(), Botan::Getentropy::poll(), Botan::Intel_Rdseed::poll(), Botan::RandomNumberGenerator::randomize_with_input(), and Botan::RandomNumberGenerator::reseed_from_rng().
|
inlineinherited |
Incorporate some additional data into the RNG state.
Definition at line 69 of file rng.h.
References T.
Referenced by Botan::Win32_EntropySource::poll().
|
inlinefinaloverridevirtualinherited |
Clear all internally held values of this RNG
Implements Botan::RandomNumberGenerator.
Definition at line 199 of file rng.h.
|
inlineoverridevirtual |
Always returns true.
Implements Botan::RandomNumberGenerator.
Definition at line 37 of file p11_randomgenerator.h.
|
staticinherited |
Create a seeded and active RNG object for general application use Added in 1.8.0 Use AutoSeeded_RNG instead
Definition at line 69 of file rng.cpp.
|
inline |
Definition at line 49 of file p11_randomgenerator.h.
Referenced by add_entropy(), and randomize().
|
inlineoverridevirtual |
Implements Botan::RandomNumberGenerator.
Definition at line 31 of file p11_randomgenerator.h.
|
inlineinherited |
Return a random byte
Definition at line 161 of file rng.h.
Referenced by Botan::random_prime().
|
inlineinherited |
Definition at line 171 of file rng.h.
Referenced by Botan::EME_PKCS1v15::pad().
|
inlineinherited |
Return a random vector
bytes | number of bytes in the result |
Definition at line 143 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::Ed25519_PrivateKey::Ed25519_PrivateKey(), Botan::TLS::Session::encrypt(), Botan::KeyPair::encryption_consistency_check(), Botan::generate_bcrypt(), Botan::mceies_encrypt(), Botan::OctetString::OctetString(), Botan::BigInt::randomize(), and Botan::TLS::Session_Manager_In_Memory::remove_all().
|
inlineinherited |
|
pure virtualinherited |
Randomize a byte array.
output | the byte array to hold the random output. |
length | the length of the byte array output in bytes. |
Implemented in Botan::AutoSeeded_RNG, Botan::System_RNG, Botan::TPM_RNG, Botan::Processor_RNG, Botan::RDRAND_RNG, Botan::Stateful_RNG, and Botan::Null_RNG.
Referenced by Botan::TLS::Connection_Cipher_State::aead_nonce(), Botan::argon2_generate_pwhash(), botan_rng_get(), Botan::CryptoBox::encrypt(), Botan::generate_dsa_primes(), Botan::generate_passhash9(), Botan::TLS::make_hello_random(), Botan::newhope_keygen(), Botan::Roughtime::Nonce::Nonce(), Botan::EME_PKCS1v15::pad(), Botan::random_gf2m(), Botan::McEliece_PublicKey::random_plaintext_element(), Botan::random_prime(), Botan::Sodium::randombytes_buf(), Botan::System_RNG::randomize(), Botan::RandomNumberGenerator::randomize_with_input(), Botan::RandomNumberGenerator::randomize_with_ts_input(), Botan::Stateful_RNG::randomize_with_ts_input(), Botan::RandomNumberGenerator::reseed_from_rng(), Botan::KeyPair::signature_consistency_check(), Botan::RTSS_Share::split(), and Botan::UUID::UUID().
|
override |
Calls C_GenerateRandom
to generate random data.
Definition at line 19 of file p11_randomgenerator.cpp.
References Botan::PKCS11::LowLevel::C_GenerateRandom(), and module().
|
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::AutoSeeded_RNG, and Botan::Stateful_RNG.
Definition at line 38 of file rng.cpp.
References Botan::RandomNumberGenerator::add_entropy(), and Botan::RandomNumberGenerator::randomize().
Referenced by 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 18 of file rng.cpp.
References Botan::RandomNumberGenerator::accepts_input(), Botan::OS::get_high_resolution_clock(), Botan::OS::get_system_timestamp_ns(), Botan::RandomNumberGenerator::randomize(), Botan::RandomNumberGenerator::randomize_with_input(), and Botan::store_le().
|
inlineoverridevirtual |
No operation - always returns 0.
Reimplemented from Botan::RandomNumberGenerator.
Definition at line 43 of file p11_randomgenerator.h.
|
virtualinherited |
Reseed by reading specified bits from the RNG
Reimplemented in Botan::Stateful_RNG.
Definition at line 59 of file rng.cpp.
References Botan::RandomNumberGenerator::accepts_input(), Botan::RandomNumberGenerator::add_entropy(), and Botan::RandomNumberGenerator::randomize().
Referenced by botan_rng_reseed(), botan_rng_reseed_from_rng(), and Botan::Stateful_RNG::reseed_from_rng().