Botan  2.9.0
Crypto and TLS for C++11
Public Member Functions | Static Public Member Functions | List of all members
Botan::Entropy_Sources Class Referencefinal

#include <entropy_src.h>

Public Member Functions

void add_source (std::unique_ptr< Entropy_Source > src)
 
std::vector< std::string > enabled_sources () const
 
 Entropy_Sources ()=default
 
 Entropy_Sources (const std::vector< std::string > &sources)
 
 Entropy_Sources (const Entropy_Sources &other)=delete
 
 Entropy_Sources (Entropy_Sources &&other)=delete
 
Entropy_Sourcesoperator= (const Entropy_Sources &other)=delete
 
size_t poll (RandomNumberGenerator &rng, size_t bits, std::chrono::milliseconds timeout)
 
size_t poll_just (RandomNumberGenerator &rng, const std::string &src)
 

Static Public Member Functions

static Entropy_Sourcesglobal_sources ()
 

Detailed Description

Definition at line 56 of file entropy_src.h.

Constructor & Destructor Documentation

◆ Entropy_Sources() [1/4]

Botan::Entropy_Sources::Entropy_Sources ( )
default

◆ Entropy_Sources() [2/4]

Botan::Entropy_Sources::Entropy_Sources ( const std::vector< std::string > &  sources)
explicit

Definition at line 172 of file entropy_srcs.cpp.

References add_source(), and Botan::Entropy_Source::create().

173  {
174  for(auto&& src_name : sources)
175  {
177  }
178  }
void add_source(std::unique_ptr< Entropy_Source > src)
static std::unique_ptr< Entropy_Source > create(const std::string &type)

◆ Entropy_Sources() [3/4]

Botan::Entropy_Sources::Entropy_Sources ( const Entropy_Sources other)
delete

◆ Entropy_Sources() [4/4]

Botan::Entropy_Sources::Entropy_Sources ( Entropy_Sources &&  other)
delete

Member Function Documentation

◆ add_source()

void Botan::Entropy_Sources::add_source ( std::unique_ptr< Entropy_Source src)

Definition at line 120 of file entropy_srcs.cpp.

Referenced by Entropy_Sources().

121  {
122  if(src.get())
123  {
124  m_srcs.push_back(std::move(src));
125  }
126  }

◆ enabled_sources()

std::vector< std::string > Botan::Entropy_Sources::enabled_sources ( ) const

Definition at line 128 of file entropy_srcs.cpp.

References name.

129  {
130  std::vector<std::string> sources;
131  for(size_t i = 0; i != m_srcs.size(); ++i)
132  {
133  sources.push_back(m_srcs[i]->name());
134  }
135  return sources;
136  }
std::string name

◆ global_sources()

Entropy_Sources & Botan::Entropy_Sources::global_sources ( )
static

Definition at line 180 of file entropy_srcs.cpp.

181  {
182  static Entropy_Sources global_entropy_sources(BOTAN_ENTROPY_DEFAULT_SOURCES);
183 
184  return global_entropy_sources;
185  }

◆ operator=()

Entropy_Sources& Botan::Entropy_Sources::operator= ( const Entropy_Sources other)
delete

◆ poll()

size_t Botan::Entropy_Sources::poll ( RandomNumberGenerator rng,
size_t  bits,
std::chrono::milliseconds  timeout 
)

Definition at line 138 of file entropy_srcs.cpp.

Referenced by Botan::RandomNumberGenerator::reseed().

141  {
142  typedef std::chrono::system_clock clock;
143 
144  auto deadline = clock::now() + timeout;
145 
146  size_t bits_collected = 0;
147 
148  for(size_t i = 0; i != m_srcs.size(); ++i)
149  {
150  bits_collected += m_srcs[i]->poll(rng);
151 
152  if (bits_collected >= poll_bits || clock::now() > deadline)
153  break;
154  }
155 
156  return bits_collected;
157  }

◆ poll_just()

size_t Botan::Entropy_Sources::poll_just ( RandomNumberGenerator rng,
const std::string &  src 
)

Poll just a single named source. Ordinally only used for testing

Definition at line 159 of file entropy_srcs.cpp.

References name.

160  {
161  for(size_t i = 0; i != m_srcs.size(); ++i)
162  {
163  if(m_srcs[i]->name() == the_src)
164  {
165  return m_srcs[i]->poll(rng);
166  }
167  }
168 
169  return 0;
170  }
std::string name

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