Botan 3.0.0-alpha0
Crypto and TLS for C&
|
#include <tpm.h>
Public Member Functions | |
bool | accepts_input () const override |
void | add_entropy (const uint8_t in[], size_t in_len) override |
template<typename T > | |
void | add_entropy_T (const T &t) |
virtual void | clear () final 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) |
template<typename Alloc > | |
void | random_vec (std::vector< uint8_t, Alloc > &v, 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) |
virtual size_t | reseed (Entropy_Sources &srcs, size_t poll_bits=BOTAN_RNG_RESEED_POLL_BITS, std::chrono::milliseconds poll_timeout=BOTAN_RNG_RESEED_DEFAULT_TIMEOUT) |
virtual void | reseed_from_rng (RandomNumberGenerator &rng, size_t poll_bits=BOTAN_RNG_RESEED_POLL_BITS) |
TPM_RNG (TPM_Context &ctx) | |
|
inline |
|
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 83 of file tpm.h.
|
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 |
Exception | may throw if the RNG accepts input, but adding the entropy failed. |
Implements Botan::RandomNumberGenerator.
Definition at line 85 of file tpm.h.
|
inlineinherited |
Incorporate some additional data into the RNG state.
Definition at line 76 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 219 of file rng.h.
|
inlineoverridevirtual |
Check whether this RNG is seeded.
Implements Botan::RandomNumberGenerator.
Definition at line 97 of file tpm.h.
|
inlineoverridevirtual |
Implements Botan::RandomNumberGenerator.
Definition at line 95 of file tpm.h.
|
inlineinherited |
Return a random byte
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Definition at line 187 of file rng.h.
References b.
Referenced by Botan::random_prime().
|
inlineinherited |
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Definition at line 199 of file rng.h.
References b.
Referenced by Botan::EME_PKCS1v15::pad().
|
inlineinherited |
Return a random vector
bytes | number of bytes in the result |
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Definition at line 167 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::Kyber_PrivateKey::Kyber_PrivateKey(), Botan::OctetString::OctetString(), Botan::BigInt::randomize(), and Botan::TLS::Session_Manager_In_Memory::remove_all().
|
inlineinherited |
|
inlineoverridevirtual |
Randomize a byte array.
May block shortly if e.g. the RNG is not yet initialized or a retry because of insufficient entropy is needed.
output | the byte array to hold the random output. |
length | the length of the byte array output in bytes. |
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Implements Botan::RandomNumberGenerator.
|
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 |
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Exception | may throw if the RNG accepts input, but adding the entropy failed. |
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.
output | buffer to hold the random output |
output_len | size of the output buffer in bytes |
PRNG_Unseeded | if the RNG fails because it has not enough entropy |
Exception | if the RNG fails |
Exception | may throw if the RNG accepts input, but adding the entropy failed. |
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().
|
virtualinherited |
Poll provided sources for up to poll_bits bits of entropy or until the timeout expires. Returns estimate of the number of bits collected.
Sets the seeded state to true if enough entropy was added.
Reimplemented in Botan::PKCS11::PKCS11_RNG, Botan::Processor_RNG, Botan::AutoSeeded_RNG, and Botan::Stateful_RNG.
Definition at line 45 of file rng.cpp.
References Botan::RandomNumberGenerator::accepts_input(), and Botan::Entropy_Sources::poll().
Referenced by Botan::Stateful_RNG::reseed().
|
virtualinherited |
Reseed by reading specified bits from the RNG
Sets the seeded state to true if enough entropy was added.
Exception | if RNG accepts input but reseeding failed. |
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().