|
Botan
1.11.15
|
#include <es_egd.h>
Classes | |
| class | EGD_Socket |
Public Member Functions | |
| EGD_EntropySource (const std::vector< std::string > &) | |
| std::string | name () const |
| void | poll (Entropy_Accumulator &accum) |
| ~EGD_EntropySource () | |
Static Public Member Functions | |
| static void | poll_available_sources (class Entropy_Accumulator &accum) |
| Botan::EGD_EntropySource::EGD_EntropySource | ( | const std::vector< std::string > & | paths | ) |
EGD_EntropySource constructor
Definition at line 122 of file es_egd.cpp.
{
for(size_t i = 0; i != paths.size(); ++i)
sockets.push_back(EGD_Socket(paths[i]));
}
Definition at line 128 of file es_egd.cpp.
{
for(size_t i = 0; i != sockets.size(); ++i)
sockets[i].close();
sockets.clear();
}
| std::string Botan::EGD_EntropySource::name | ( | ) | const [inline, virtual] |
Implements Botan::EntropySource.
Definition at line 24 of file es_egd.h.
{ return "EGD/PRNGD"; }
| void Botan::EGD_EntropySource::poll | ( | Entropy_Accumulator & | accum | ) | [virtual] |
Gather Entropy from EGD
Implements Botan::EntropySource.
Definition at line 138 of file es_egd.cpp.
References Botan::Entropy_Accumulator::add(), and Botan::Entropy_Accumulator::get_io_buffer().
{
const size_t READ_ATTEMPT = 32;
std::lock_guard<std::mutex> lock(m_mutex);
secure_vector<byte>& io_buffer = accum.get_io_buffer(READ_ATTEMPT);
for(size_t i = 0; i != sockets.size(); ++i)
{
size_t got = sockets[i].read(&io_buffer[0], io_buffer.size());
if(got)
{
accum.add(&io_buffer[0], got, 6);
break;
}
}
}
| void Botan::EntropySource::poll_available_sources | ( | class Entropy_Accumulator & | accum | ) | [static, inherited] |
Definition at line 108 of file entropy_srcs.cpp.
References Botan::Entropy_Accumulator::polling_goal_achieved().
Referenced by Botan::HMAC_RNG::reseed().
{
static std::vector<std::unique_ptr<EntropySource>> g_sources(get_default_entropy_sources());
if(g_sources.empty())
throw std::runtime_error("No entropy sources enabled at build time, poll failed");
size_t poll_attempt = 0;
while(!accum.polling_goal_achieved() && poll_attempt < 16)
{
const size_t src_idx = poll_attempt % g_sources.size();
g_sources[src_idx]->poll(accum);
++poll_attempt;
}
}
1.7.6.1