Botan  1.11.30
Public Member Functions | Static Public Member Functions | List of all members
Botan::Null_RNG Class Reference

#include <rng.h>

Inheritance diagram for Botan::Null_RNG:

Public Member Functions

void add_entropy (const byte[], size_t) override
void clear () override
template<typename T >
get_random ()
bool is_seeded () const override
std::string name () const override
byte next_byte ()
byte next_nonzero_byte ()
virtual secure_vector< byterandom_vec (size_t bytes)
void randomize (byte[], size_t) override
size_t reseed (size_t bits_to_collect)
size_t reseed_with_sources (Entropy_Sources &, size_t, std::chrono::milliseconds) override
size_t reseed_with_timeout (size_t bits_to_collect, std::chrono::milliseconds poll_timeout)

Static Public Member Functions

static RandomNumberGeneratormake_rng ()

Detailed Description

Null/stub RNG - fails if you try to use it for anything

Definition at line 140 of file rng.h.

Member Function Documentation

void Botan::Null_RNG::add_entropy ( const byte  in[],
size_t  length 

Add entropy to this RNG.

ina byte array containg the entropy to be added
lengththe length of the byte array in

Implements Botan::RandomNumberGenerator.

Definition at line 156 of file rng.h.

156 {}
void Botan::Null_RNG::clear ( )

Clear all internally held values of this RNG.

Implements Botan::RandomNumberGenerator.

Definition at line 145 of file rng.h.

145 {}
template<typename T >
T Botan::RandomNumberGenerator::get_random ( )

Only usable with POD types, only useful with integers get_random<u64bit>()

Definition at line 56 of file rng.h.

57  {
58  T r;
59  this->randomize(reinterpret_cast<byte*>(&r), sizeof(r));
60  return r;
61  }
virtual void randomize(byte output[], size_t length)=0
bool Botan::Null_RNG::is_seeded ( ) const

Check whether this RNG is seeded.

true if this RNG was already seeded, false otherwise.

Implements Botan::RandomNumberGenerator.

Definition at line 155 of file rng.h.

155 { return false; }
RandomNumberGenerator * Botan::RandomNumberGenerator::make_rng ( )

Create a seeded and active RNG object for general application use Added in 1.8.0

Definition at line 28 of file rng.cpp.

References Botan::MessageAuthenticationCode::create().

29  {
30  std::unique_ptr<MessageAuthenticationCode> h1(MessageAuthenticationCode::create("HMAC(SHA-512)"));
31  std::unique_ptr<MessageAuthenticationCode> h2(MessageAuthenticationCode::create("HMAC(SHA-512)"));
33  if(!h1 || !h2)
34  throw Algorithm_Not_Found("HMAC_RNG HMACs");
35  std::unique_ptr<RandomNumberGenerator> rng(new HMAC_RNG(h1.release(), h2.release()));
37  rng->reseed(256);
39  return rng.release();
40  }
static std::unique_ptr< MessageAuthenticationCode > create(const std::string &algo_spec, const std::string &provider="")
Definition: mac.cpp:38
std::string Botan::Null_RNG::name ( ) const

Return the name of this object

Implements Botan::RandomNumberGenerator.

Definition at line 147 of file rng.h.

147 { return "Null_RNG"; }
byte Botan::RandomNumberGenerator::next_byte ( )

Return a random byte

random byte

Definition at line 67 of file rng.h.

Referenced by Botan::Blinded_Point_Multiply::blinded_multiply(), and Botan::random_prime().

67 { return get_random<byte>(); }
byte Botan::RandomNumberGenerator::next_nonzero_byte ( )

Definition at line 69 of file rng.h.

70  {
71  byte b = next_byte();
72  while(b == 0)
73  b = next_byte();
74  return b;
75  }
std::uint8_t byte
Definition: types.h:31
virtual secure_vector<byte> Botan::RandomNumberGenerator::random_vec ( size_t  bytes)
void Botan::Null_RNG::randomize ( byte  output[],
size_t  length 

Randomize a byte array.

outputthe byte array to hold the random output.
lengththe length of the byte array output.

Implements Botan::RandomNumberGenerator.

Definition at line 143 of file rng.h.

143 { throw PRNG_Unseeded("Null_RNG"); }
size_t Botan::RandomNumberGenerator::reseed ( size_t  bits_to_collect)

Seed this RNG using the global entropy sources and default timeout

bits_to_collectis the number of bits of entropy to attempt to gather from the entropy sources

Definition at line 14 of file rng.cpp.

References Botan::RandomNumberGenerator::reseed_with_timeout().

Referenced by botan_rng_reseed(), Botan::ANSI_X931_RNG::randomize(), Botan::HMAC_DRBG::randomize(), and Botan::HMAC_RNG::randomize().

15  {
16  return this->reseed_with_timeout(bits_to_collect,
18  }
size_t reseed_with_timeout(size_t bits_to_collect, std::chrono::milliseconds poll_timeout)
Definition: rng.cpp:20
size_t Botan::Null_RNG::reseed_with_sources ( Entropy_Sources srcs,
size_t  poll_bits,
std::chrono::milliseconds  poll_timeout 

Poll provided sources for up to poll_bits bits of entropy or until the timeout expires. Returns estimate of the number of bits collected.

Implements Botan::RandomNumberGenerator.

Definition at line 149 of file rng.h.

151  {
152  return 0;
153  }
size_t Botan::RandomNumberGenerator::reseed_with_timeout ( size_t  bits_to_collect,
std::chrono::milliseconds  poll_timeout 

Seed this RNG using the global entropy sources

bits_to_collectis the number of bits of entropy to attempt to gather from the entropy sources
poll_timeouttry not to run longer than this, no matter what

Definition at line 20 of file rng.cpp.

References Botan::Entropy_Sources::global_sources(), and Botan::RandomNumberGenerator::reseed_with_sources().

Referenced by Botan::RandomNumberGenerator::reseed().

22  {
24  bits_to_collect,
25  timeout);
26  }
virtual size_t reseed_with_sources(Entropy_Sources &srcs, size_t poll_bits, std::chrono::milliseconds poll_timeout)=0
static Entropy_Sources & global_sources()

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