Botan 3.3.0
Crypto and TLS for C&
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 Entropy_Sources &other)=delete
 
 Entropy_Sources (const std::vector< std::string > &sources)
 
 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, std::string_view src)
 

Static Public Member Functions

static Entropy_Sourcesglobal_sources ()
 

Detailed Description

Definition at line 55 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 168 of file entropy_srcs.cpp.

168 {
169 for(auto&& src_name : sources) {
171 }
172}
static std::unique_ptr< Entropy_Source > create(std::string_view type)
void add_source(std::unique_ptr< Entropy_Source > src)

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

◆ 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 125 of file entropy_srcs.cpp.

125 {
126 if(src) {
127 m_srcs.push_back(std::move(src));
128 }
129}

Referenced by Entropy_Sources().

◆ enabled_sources()

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

Definition at line 131 of file entropy_srcs.cpp.

131 {
132 std::vector<std::string> sources;
133 sources.reserve(m_srcs.size());
134 for(const auto& src : m_srcs) {
135 sources.push_back(src->name());
136 }
137 return sources;
138}

◆ global_sources()

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

Definition at line 174 of file entropy_srcs.cpp.

174 {
175 static Entropy_Sources global_entropy_sources(BOTAN_ENTROPY_DEFAULT_SOURCES);
176
177 return global_entropy_sources;
178}
#define BOTAN_ENTROPY_DEFAULT_SOURCES
Definition build.h:438

References BOTAN_ENTROPY_DEFAULT_SOURCES.

◆ 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 140 of file entropy_srcs.cpp.

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

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

◆ poll_just()

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

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

Definition at line 158 of file entropy_srcs.cpp.

158 {
159 for(auto& src : m_srcs) {
160 if(src->name() == the_src) {
161 return src->poll(rng);
162 }
163 }
164
165 return 0;
166}

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