Botan  1.10.9
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:
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

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 {}
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; }
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 {}
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; }
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::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"; }
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::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"); }
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: