Botan
1.11.15
|
#include <es_capi.h>
Public Member Functions | |
std::string | name () const |
void | poll (Entropy_Accumulator &accum) |
Win32_CAPI_EntropySource (const std::string &provs="") | |
Static Public Member Functions | |
static void | poll_available_sources (class Entropy_Accumulator &accum) |
Botan::Win32_CAPI_EntropySource::Win32_CAPI_EntropySource | ( | const std::string & | provs = "" | ) |
Win32_Capi_Entropysource Constructor
provs | list of providers, separated by ':' |
Definition at line 79 of file es_capi.cpp.
References Botan::split_on().
{ std::vector<std::string> capi_provs = split_on(provs, ':'); for(size_t i = 0; i != capi_provs.size(); ++i) { if(capi_provs[i] == "RSA_FULL") prov_types.push_back(PROV_RSA_FULL); if(capi_provs[i] == "INTEL_SEC") prov_types.push_back(PROV_INTEL_SEC); if(capi_provs[i] == "FORTEZZA") prov_types.push_back(PROV_FORTEZZA); if(capi_provs[i] == "RNG") prov_types.push_back(PROV_RNG); } if(prov_types.size() == 0) prov_types.push_back(PROV_RSA_FULL); }
std::string Botan::Win32_CAPI_EntropySource::name | ( | ) | const [inline, virtual] |
Implements Botan::EntropySource.
Definition at line 22 of file es_capi.h.
{ return "Win32 CryptoGenRandom"; }
void Botan::Win32_CAPI_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 58 of file es_capi.cpp.
References Botan::Entropy_Accumulator::add(), and Botan::Entropy_Accumulator::get_io_buffer().
{ secure_vector<byte>& io_buffer = accum.get_io_buffer(32); for(size_t i = 0; i != prov_types.size(); ++i) { CSP_Handle csp(prov_types[i]); size_t got = csp.gen_random(&io_buffer[0], io_buffer.size()); if(got) { accum.add(&io_buffer[0], io_buffer.size(), 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; } }