Botan 1.10.17
Botan::Win32_CAPI_EntropySource Class Reference

#include <es_capi.h>

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

Public Member Functions

std::string name () const
void poll (Entropy_Accumulator &accum)
 Win32_CAPI_EntropySource (const std::string &provs="")

Detailed Description

Win32 CAPI Entropy Source

Definition at line 19 of file es_capi.h.

Constructor & Destructor Documentation

◆ Win32_CAPI_EntropySource()

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

Win32_Capi_Entropysource Constructor

Parameters
provslist of providers, separated by ':'

Definition at line 77 of file es_capi.cpp.

78 {
79 std::vector<std::string> capi_provs = split_on(provs, ':');
80
81 for(size_t i = 0; i != capi_provs.size(); ++i)
82 {
83 if(capi_provs[i] == "RSA_FULL") prov_types.push_back(PROV_RSA_FULL);
84 if(capi_provs[i] == "INTEL_SEC") prov_types.push_back(PROV_INTEL_SEC);
85 if(capi_provs[i] == "FORTEZZA") prov_types.push_back(PROV_FORTEZZA);
86 if(capi_provs[i] == "RNG") prov_types.push_back(PROV_RNG);
87 }
88
89 if(prov_types.size() == 0)
90 prov_types.push_back(PROV_RSA_FULL);
91 }
std::vector< std::string > split_on(const std::string &str, char delim)
Definition parsing.cpp:152

References Botan::split_on().

Member Function Documentation

◆ name()

std::string Botan::Win32_CAPI_EntropySource::name ( ) const
inlinevirtual
Returns
name identifying this entropy source

Implements Botan::EntropySource.

Definition at line 22 of file es_capi.h.

22{ return "Win32 CryptoGenRandom"; }

◆ poll()

void Botan::Win32_CAPI_EntropySource::poll ( Entropy_Accumulator & accum)
virtual

Perform an entropy gathering poll

Parameters
accumis an accumulator object that will be given entropy

Implements Botan::EntropySource.

Definition at line 56 of file es_capi.cpp.

57 {
58 MemoryRegion<byte>& io_buffer = accum.get_io_buffer(32);
59
60 for(size_t i = 0; i != prov_types.size(); ++i)
61 {
62 CSP_Handle csp(prov_types[i]);
63
64 size_t got = csp.gen_random(&io_buffer[0], io_buffer.size());
65
66 if(got)
67 {
68 accum.add(&io_buffer[0], io_buffer.size(), 6);
69 break;
70 }
71 }
72 }

References Botan::Entropy_Accumulator::add(), Botan::Entropy_Accumulator::get_io_buffer(), and Botan::MemoryRegion< T >::size().


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