Botan  1.11.10
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) override
 
void clear () override
 
bool is_seeded () const override
 
std::string name () const override
 
byte next_byte ()
 
virtual secure_vector< byterandom_vec (size_t bytes)
 
void randomize (byte[], size_t) override
 
void reseed (size_t) override
 

Static Public Member Functions

static RandomNumberGeneratormake_rng ()
 
static std::unique_ptr
< RandomNumberGenerator
make_rng (class Algorithm_Factory &af)
 

Detailed Description

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

Definition at line 109 of file rng.h.

Member Function Documentation

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

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 120 of file rng.h.

120 {}
void Botan::Null_RNG::clear ( )
inlineoverridevirtual

Clear all internally held values of this RNG.

Implements Botan::RandomNumberGenerator.

Definition at line 114 of file rng.h.

114 {}
bool Botan::Null_RNG::is_seeded ( ) const
inlineoverridevirtual

Check whether this RNG is seeded.

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

Implements Botan::RandomNumberGenerator.

Definition at line 119 of file rng.h.

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

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

Definition at line 14 of file rng.cpp.

References Botan::Global_State_Management::global_state().

15  {
16  return make_rng(global_state().algorithm_factory()).release();
17  }
static RandomNumberGenerator * make_rng()
Definition: rng.cpp:14
Library_State & global_state()
std::unique_ptr< RandomNumberGenerator > Botan::RandomNumberGenerator::make_rng ( class Algorithm_Factory af)
staticinherited

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

Definition at line 22 of file rng.cpp.

References Botan::Algorithm_Factory::make_mac().

23  {
24  std::unique_ptr<RandomNumberGenerator> rng(
25  new HMAC_RNG(af.make_mac("HMAC(SHA-512)"),
26  af.make_mac("HMAC(SHA-256)"))
27  );
28 
29  rng->reseed(256);
30 
31  return rng;
32  }
std::string Botan::Null_RNG::name ( ) const
inlineoverridevirtual

Return the name of this object

Implements Botan::RandomNumberGenerator.

Definition at line 116 of file rng.h.

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

Return a random byte

Returns
random byte

Definition at line 59 of file rng.h.

Referenced by Botan::random_prime().

60  {
61  byte out;
62  this->randomize(&out, 1);
63  return out;
64  }
virtual void randomize(byte output[], size_t length)=0
uint8_t byte
Definition: types.h:30
virtual secure_vector<byte> Botan::RandomNumberGenerator::random_vec ( size_t  bytes)
inlinevirtualinherited

Return a random vector

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

Definition at line 48 of file rng.h.

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::CryptoBox::encrypt(), Botan::KeyPair::encryption_consistency_check(), Botan::generate_bcrypt(), Botan::OctetString::OctetString(), Botan::pbes2_encrypt(), Botan::BigInt::randomize(), Botan::TLS::Session_Manager_SQLite::Session_Manager_SQLite(), and Botan::KeyPair::signature_consistency_check().

49  {
50  secure_vector<byte> output(bytes);
51  randomize(&output[0], output.size());
52  return output;
53  }
virtual void randomize(byte output[], size_t length)=0
void Botan::Null_RNG::randomize ( byte  output[],
size_t  length 
)
inlineoverridevirtual

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 112 of file rng.h.

112 { throw PRNG_Unseeded("Null_RNG"); }
void Botan::Null_RNG::reseed ( size_t  bits_to_collect)
inlineoverridevirtual

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 118 of file rng.h.

118 {}

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