Botan  1.11.15
Public Member Functions | Static Public Member Functions
Botan::Win32_CAPI_EntropySource Class Reference

#include <es_capi.h>

Inheritance diagram for Botan::Win32_CAPI_EntropySource:
Botan::EntropySource

List of all members.

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)

Detailed Description

Win32 CAPI Entropy Source

Definition at line 19 of file es_capi.h.


Constructor & Destructor Documentation

Botan::Win32_CAPI_EntropySource::Win32_CAPI_EntropySource ( const std::string &  provs = "")

Win32_Capi_Entropysource Constructor

Parameters:
provslist 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);
   }

Member Function Documentation

std::string Botan::Win32_CAPI_EntropySource::name ( ) const [inline, virtual]
Returns:
name identifying this entropy source

Implements Botan::EntropySource.

Definition at line 22 of file es_capi.h.

{ return "Win32 CryptoGenRandom"; }

Perform an entropy gathering poll

Parameters:
accumis 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;
      }
   }

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