Botan  1.10.9
Public Member Functions | Static Public Member Functions | List of all members
Botan::AutoSeeded_RNG Class Reference

#include <auto_rng.h>

Inheritance diagram for Botan::AutoSeeded_RNG:
Botan::RandomNumberGenerator

Public Member Functions

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

Static Public Member Functions

static RandomNumberGeneratormake_rng ()
 

Detailed Description

An automatically seeded PRNG

Definition at line 20 of file auto_rng.h.

Constructor & Destructor Documentation

Botan::AutoSeeded_RNG::AutoSeeded_RNG ( )
inline

Definition at line 40 of file auto_rng.h.

References Botan::Library_State::global_rng(), Botan::Global_State_Management::global_state(), and rng.

40 { rng = &global_state().global_rng(); }
RandomNumberGenerator & global_rng()
Definition: libstate.cpp:183
Library_State & global_state()

Member Function Documentation

void Botan::AutoSeeded_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 37 of file auto_rng.h.

References rng.

38  { rng->add_entropy(in, len); }
virtual void add_entropy(const byte in[], size_t length)=0
void Botan::AutoSeeded_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 34 of file auto_rng.h.

References rng.

35  { rng->add_entropy_source(es); }
virtual void add_entropy_source(EntropySource *source)=0
void Botan::AutoSeeded_RNG::clear ( )
inlinevirtual

Clear all internally held values of this RNG.

Implements Botan::RandomNumberGenerator.

Definition at line 28 of file auto_rng.h.

References rng.

28 { rng->clear(); }
bool Botan::AutoSeeded_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 26 of file auto_rng.h.

References rng.

26 { return rng->is_seeded(); }
virtual bool is_seeded() const
Definition: rng.h:57
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  }
std::string Botan::AutoSeeded_RNG::name ( ) const
inlinevirtual

Return the name of this object

Implements Botan::RandomNumberGenerator.

Definition at line 30 of file auto_rng.h.

References rng.

30 { return rng->name(); }
virtual std::string name() const =0
byte Botan::RandomNumberGenerator::next_byte ( )
inherited

Return a random byte

Returns
random byte

Definition at line 19 of file rng.cpp.

References Botan::RandomNumberGenerator::randomize().

Referenced by Botan::random_prime().

20  {
21  byte out;
22  this->randomize(&out, 1);
23  return out;
24  }
virtual void randomize(byte output[], size_t length)=0
unsigned char byte
Definition: types.h:22
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.

References 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().

41  {
42  SecureVector<byte> output(bytes);
43  randomize(&output[0], output.size());
44  return output;
45  }
virtual void randomize(byte output[], size_t length)=0
void Botan::AutoSeeded_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 23 of file auto_rng.h.

References rng.

24  { rng->randomize(out, len); }
virtual void randomize(byte output[], size_t length)=0
void Botan::AutoSeeded_RNG::reseed ( size_t  bits_to_collect = 256)
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 32 of file auto_rng.h.

References rng.

32 { rng->reseed(poll_bits); }
virtual void reseed(size_t bits_to_collect)=0

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