Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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_Sources & | operator= (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_Sources & | global_sources ()

## Detailed Description

Definition at line 56 of file entropy_src.h.

## Constructor & Destructor Documentation

Botan::Entropy_Sources::Entropy_Sources | ( |  | ) |
| default

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

Definition at line 183 of file entropy_srcs.cpp.

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

184 {
185 for(auto&& src_name : sources)
186 {
187 add_source(Entropy_Source::create(src_name));
188 }
189 }
Botan::Entropy_Sources::add_source
void add_source(std::unique_ptr< Entropy_Source > src)
Definition: entropy_srcs.cpp:131
Botan::Entropy_Source::create
static std::unique_ptr< Entropy_Source > create(const std::string &type)
Definition: entropy_srcs.cpp:67

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

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

## Member Function Documentation

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

Definition at line 131 of file entropy_srcs.cpp.

Referenced by Entropy_Sources().

132 {
133 if(src.get())
134 {
135 m_srcs.push_back(std::move(src));
136 }
137 }

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

Definition at line 139 of file entropy_srcs.cpp.

References name.

140 {
141 std::vector<std::string> sources;
142 for(size_t i = 0; i != m_srcs.size(); ++i)
143 {
144 sources.push_back(m_srcs[i]->name());
145 }
146 return sources;
147 }
name
std::string name
Definition: commoncrypto_hash.cpp:23

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

Definition at line 191 of file entropy_srcs.cpp.

192 {
193 static Entropy_Sources global_entropy_sources(BOTAN_ENTROPY_DEFAULT_SOURCES);
194
195 return global_entropy_sources;
196 }
Botan::Entropy_Sources::Entropy_Sources
Entropy_Sources()=default

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

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

Definition at line 149 of file entropy_srcs.cpp.

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

152 {
153 typedef std::chrono::system_clock clock;
154
155 auto deadline = clock::now() + timeout;
156
157 size_t bits_collected = 0;
158
159 for(size_t i = 0; i != m_srcs.size(); ++i)
160 {
161 bits_collected += m_srcs[i]->poll(rng);
162
163 if (bits_collected >= poll_bits || clock::now() > deadline)
164 break;
165 }
166
167 return bits_collected;
168 }

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

References name.

171 {
172 for(size_t i = 0; i != m_srcs.size(); ++i)
173 {
174 if(m_srcs[i]->name() == the_src)
175 {
176 return m_srcs[i]->poll(rng);
177 }
178 }
179
180 return 0;
181 }
name
std::string name
Definition: commoncrypto_hash.cpp:23

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

- src/lib/entropy/entropy_src.h
- src/lib/entropy/entropy_srcs.cpp