Botan 1.10.17

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)
void | add_entropy_source (EntropySource *es)
void | clear ()
bool | is_seeded () const
std::string | name () const
byte | next_byte ()
SecureVector< byte > | random_vec (size_t bytes)
void | randomize (byte[], size_t)
void | reseed (size_t)

## Static Public Member Functions
static RandomNumberGenerator * | make_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
| ) |  |
| inline virtual

Add entropy to this RNG.

Parameters

  in | a byte array containg the entropy to be added
  length | the 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 | ) |
| inline virtual

Add this entropy source to the RNG object

Parameters

  source | the 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 | ( |  | ) |
| inline virtual

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
| inline virtual

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 | ( |  | ) |
| static inherited

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 }

## ◆ name()

std::string Botan::Null_RNG::name | ( |  | ) | const
| inline virtual

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.

References Botan::RandomNumberGenerator::randomize().

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

## ◆ random_vec()

SecureVector<byte> Botan::RandomNumberGenerator::random_vec | ( | size_t | bytes | ) |
| inline inherited

Return a random vector

Parameters

  bytes | number of bytes in the result

Returns
  randomized vector of length bytes

Definition at line 40 of file rng.h.

References Botan::MemoryRegion< T >::size().

41 {
42 SecureVector<byte> output(bytes);
43 randomize(&output[0], output.size());
44 return output;
45 }
Botan::RandomNumberGenerator::randomize
virtual void randomize(byte output[], size_t length)=0

## ◆ randomize()

void Botan::Null_RNG::randomize | ( | byte | output[],
|  | size_t | length
| ) |  |
| inline virtual

Randomize a byte array.

Parameters

  output | the byte array to hold the random output.
  length | the length of the byte array output.

Implements Botan::RandomNumberGenerator.

Definition at line 103 of file rng.h.

103 { throw PRNG_Unseeded("Null_RNG"); }

## ◆ reseed()

void Botan::Null_RNG::reseed | ( | size_t | bits_to_collect | ) |
| inline virtual

Seed this RNG using the entropy sources it contains.

Parameters

  bits_to_collect | is 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:

- src/rng/rng.h