Botan  1.11.15
Public Member Functions | Static Public Member Functions
Botan::Serialized_RNG Class Reference

#include <rng.h>

Inheritance diagram for Botan::Serialized_RNG:
Botan::RandomNumberGenerator

List of all members.

Public Member Functions

void add_entropy (const byte in[], size_t len)
void clear ()
bool is_seeded () const
std::string name () const
byte next_byte ()
virtual secure_vector< byterandom_vec (size_t bytes)
void randomize (byte out[], size_t len)
void reseed (size_t poll_bits)
 Serialized_RNG ()

Static Public Member Functions

static RandomNumberGeneratormake_rng ()

Detailed Description

Wraps access to a RNG in a mutex

Definition at line 120 of file rng.h.


Constructor & Destructor Documentation

Definition at line 159 of file rng.h.


Member Function Documentation

void Botan::Serialized_RNG::add_entropy ( const byte  in[],
size_t  length 
) [inline, virtual]

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

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         m_rng->add_entropy(in, len);
         }
void Botan::Serialized_RNG::clear ( ) [inline, virtual]

Clear all internally held values of this RNG.

Implements Botan::RandomNumberGenerator.

Definition at line 135 of file rng.h.

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         m_rng->clear();
         }
bool Botan::Serialized_RNG::is_seeded ( ) const [inline, virtual]

Check whether this RNG is seeded.

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

Implements Botan::RandomNumberGenerator.

Definition at line 129 of file rng.h.

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         return m_rng->is_seeded();
         }

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

Definition at line 14 of file rng.cpp.

   {
   std::unique_ptr<RandomNumberGenerator> rng(
      new HMAC_RNG(make_a<MessageAuthenticationCode>("HMAC(SHA-512)"),
                   make_a<MessageAuthenticationCode>("HMAC(SHA-256)"))
      );

   rng->reseed(256);

   return rng.release();
   }
std::string Botan::Serialized_RNG::name ( ) const [inline, virtual]

Return the name of this object

Implements Botan::RandomNumberGenerator.

Definition at line 141 of file rng.h.

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         return m_rng->name();
         }

Return a random byte

Returns:
random byte

Definition at line 53 of file rng.h.

Referenced by Botan::random_prime().

         {
         byte out;
         this->randomize(&out, 1);
         return out;
         }
virtual secure_vector<byte> Botan::RandomNumberGenerator::random_vec ( size_t  bytes) [inline, virtual, inherited]
void Botan::Serialized_RNG::randomize ( byte  output[],
size_t  length 
) [inline, virtual]

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

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         m_rng->randomize(out, len);
         }
void Botan::Serialized_RNG::reseed ( size_t  bits_to_collect) [inline, virtual]

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

References m_mutex.

         {
         std::lock_guard<std::mutex> lock(m_mutex);
         m_rng->reseed(poll_bits);
         }

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