Botan 1.10.17
Botan::Null_RNG Class Reference

#include <rng.h>

Inheritance diagram for Botan::Null_RNG:
Botan::RandomNumberGenerator

Public Member Functions

void add_entropy (const byte[], size_t)
void add_entropy_source (EntropySource *es)
void clear ()
bool is_seeded () const
std::string name () const
byte next_byte ()
SecureVector< byterandom_vec (size_t bytes)
void randomize (byte[], size_t)
void reseed (size_t)

Static Public Member Functions

static RandomNumberGeneratormake_rng ()

Detailed Description

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

Definition at line 100 of file rng.h.

Member Function Documentation

◆ add_entropy()

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

Add entropy to this RNG.

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

Implements Botan::RandomNumberGenerator.

Definition at line 109 of file rng.h.

109{}

◆ add_entropy_source()

void Botan::Null_RNG::add_entropy_source ( EntropySource * source)
inlinevirtual

Add this entropy source to the RNG object

Parameters
sourcethe entropy source which will be retained and used by RNG

Implements Botan::RandomNumberGenerator.

Definition at line 110 of file rng.h.

110{ delete es; }

◆ clear()

void Botan::Null_RNG::clear ( )
inlinevirtual

Clear all internally held values of this RNG.

Implements Botan::RandomNumberGenerator.

Definition at line 104 of file rng.h.

104{}

◆ is_seeded()

bool Botan::Null_RNG::is_seeded ( ) const
inlinevirtual

Check whether this RNG is seeded.

Returns
true if this RNG was already seeded, false otherwise.

Reimplemented from Botan::RandomNumberGenerator.

Definition at line 108 of file rng.h.

108{ return false; }

◆ make_rng()

RandomNumberGenerator * Botan::RandomNumberGenerator::make_rng ( )
staticinherited

Create a seeded and active RNG object for general application use

Definition at line 29 of file rng.cpp.

30 {
31#if defined(BOTAN_HAS_AUTO_SEEDING_RNG)
32 return new AutoSeeded_RNG;
33#endif
34
35 throw Algorithm_Not_Found("RandomNumberGenerator::make_rng - no RNG found");
36 }
Algorithm_Not_Found(const std::string &name)
Definition exceptn.h:111

References Botan::Algorithm_Not_Found::Algorithm_Not_Found(), and RandomNumberGenerator().

◆ name()

std::string Botan::Null_RNG::name ( ) const
inlinevirtual

Return the name of this object

Implements Botan::RandomNumberGenerator.

Definition at line 105 of file rng.h.

105{ return "Null_RNG"; }

◆ next_byte()

byte Botan::RandomNumberGenerator::next_byte ( )
inherited

Return a random byte

Returns
random byte

Definition at line 19 of file rng.cpp.

20 {
21 byte out;
22 this->randomize(&out, 1);
23 return out;
24 }
virtual void randomize(byte output[], size_t length)=0

References randomize().

Referenced by Botan::random_prime().

◆ random_vec()

SecureVector< byte > Botan::RandomNumberGenerator::random_vec ( size_t bytes)
inlineinherited

Return a random vector

Parameters
bytesnumber of bytes in the result
Returns
randomized vector of length bytes

Definition at line 40 of file rng.h.

41 {
42 SecureVector<byte> output(bytes);
43 randomize(&output[0], output.size());
44 return output;
45 }

References randomize(), and Botan::MemoryRegion< T >::size().

Referenced by Botan::Client_Hello::Client_Hello(), Botan::Client_Key_Exchange::Client_Key_Exchange(), Botan::KeyPair::encryption_consistency_check(), Botan::generate_bcrypt(), Botan::generate_dsa_primes(), Botan::OctetString::OctetString(), Botan::Client_Key_Exchange::pre_master_secret(), Botan::BigInt::randomize(), Botan::Server_Hello::Server_Hello(), and Botan::KeyPair::signature_consistency_check().

◆ randomize()

void Botan::Null_RNG::randomize ( byte output[],
size_t length )
inlinevirtual

Randomize a byte array.

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

Implements Botan::RandomNumberGenerator.

Definition at line 103 of file rng.h.

103{ throw PRNG_Unseeded("Null_RNG"); }
PRNG_Unseeded(const std::string &algo)
Definition exceptn.h:91

◆ reseed()

void Botan::Null_RNG::reseed ( size_t bits_to_collect)
inlinevirtual

Seed this RNG using the entropy sources it contains.

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

Implements Botan::RandomNumberGenerator.

Definition at line 107 of file rng.h.

107{}

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