|
Botan
1.11.15
|
#include <unix_procs.h>
Public Member Functions | |
| std::string | name () const |
| void | poll (Entropy_Accumulator &accum) |
Static Public Member Functions | |
| static void | poll_available_sources (class Entropy_Accumulator &accum) |
Definition at line 80 of file unix_procs.h.
| std::string Botan::UnixProcessInfo_EntropySource::name | ( | ) | const [inline, virtual] |
Implements Botan::EntropySource.
Definition at line 83 of file unix_procs.h.
{ return "Unix Process Info"; }
| void Botan::UnixProcessInfo_EntropySource::poll | ( | Entropy_Accumulator & | accum | ) | [virtual] |
Perform an entropy gathering poll
| accum | is an accumulator object that will be given entropy |
Implements Botan::EntropySource.
Definition at line 69 of file unix_procs.cpp.
References Botan::Entropy_Accumulator::add().
{
static std::atomic<int> last_pid;
int pid = ::getpid();
accum.add(pid, 0.0);
if(pid != last_pid)
{
last_pid = pid;
accum.add(::getppid(), 0.0);
accum.add(::getuid(), 0.0);
accum.add(::getgid(), 0.0);
accum.add(::getsid(0), 0.0);
accum.add(::getpgrp(), 0.0);
}
struct ::rusage usage;
::getrusage(RUSAGE_SELF, &usage);
accum.add(usage, 0.0);
}
| 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