Botan: Botan::AutoSeeded_RNG Class Reference

Botan 1.10.16

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:

## 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< byte > | random_vec (size_t bytes)
void | randomize (byte out[], size_t len)
void | reseed (size_t poll_bits=256)

## Static Public Member Functions
static RandomNumberGenerator * | make_rng ()

## Detailed Description

An automatically seeded PRNG

Definition at line 20 of file auto_rng.h.

## Constructor & Destructor Documentation

## ◆ AutoSeeded_RNG()

Botan::AutoSeeded_RNG::AutoSeeded_RNG | ( |  | ) |
| inline

Definition at line 40 of file auto_rng.h.

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

## Member Function Documentation

## ◆ add_entropy()

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

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 37 of file auto_rng.h.

38 { rng->add_entropy(in, len); }
Botan::RandomNumberGenerator::add_entropy
virtual void add_entropy(const byte in[], size_t length)=0

## ◆ add_entropy_source()

void Botan::AutoSeeded_RNG::add_entropy_source | ( | EntropySource * | source | ) |
| inlinevirtual

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 34 of file auto_rng.h.

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

## ◆ clear()

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.

28 { rng->clear(); }
Botan::RandomNumberGenerator::clear
virtual void clear()=0

## ◆ is_seeded()

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.

26 { return rng->is_seeded(); }
Botan::RandomNumberGenerator::is_seeded
virtual bool is_seeded() const
Definition: rng.h:57

## ◆ 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 }

## ◆ name()

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.

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

## ◆ 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 | ) |
| inlineinherited

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

Referenced by Botan::ANSI_X931_RNG::randomize().

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::AutoSeeded_RNG::randomize | ( | byte | output[],
|  | size_t | length
| ) |  |
| inlinevirtual

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 23 of file auto_rng.h.

24 { rng->randomize(out, len); }
Botan::RandomNumberGenerator::randomize
virtual void randomize(byte output[], size_t length)=0

## ◆ reseed()

void Botan::AutoSeeded_RNG::reseed | ( | size_t | bits_to_collect = `256` | ) |
| inlinevirtual

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 32 of file auto_rng.h.

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

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

- src/rng/auto_rng/auto_rng.h