aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/entropy/cryptoapi_rng/es_capi.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-11-24 17:51:59 -0500
committerJack Lloyd <[email protected]>2015-11-24 17:51:59 -0500
commit5f208fab1890e2ad64b52306eccd82f031425c7a (patch)
tree6bbbf1408e10538e441e3d603d80ebb2cabc6a78 /src/lib/entropy/cryptoapi_rng/es_capi.cpp
parentbf59ffc4de374d7b27b7ab400789ab2723131b7a (diff)
New reseed_with_sources call on RNGs
Provides an easier way for an application to configure a list of entropy sources they'd like to use, or add a custom entropy source to their seeding. Exposes some toggles for the global/default entropy sources to build.h Adds basic entropy tests which runs the polls and does sanity checking on the results, including compression tests if available. These are less useful for the CSPRNG outputs but a good check for the ones producing plain ASCII like the /proc reader.
Diffstat (limited to 'src/lib/entropy/cryptoapi_rng/es_capi.cpp')
-rw-r--r--src/lib/entropy/cryptoapi_rng/es_capi.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/entropy/cryptoapi_rng/es_capi.cpp b/src/lib/entropy/cryptoapi_rng/es_capi.cpp
index 019b55a10..6ffc03c12 100644
--- a/src/lib/entropy/cryptoapi_rng/es_capi.cpp
+++ b/src/lib/entropy/cryptoapi_rng/es_capi.cpp
@@ -57,15 +57,17 @@ class CSP_Handle
*/
void Win32_CAPI_EntropySource::poll(Entropy_Accumulator& accum)
{
- m_buf.resize(32);
+ const size_t ENTROPY_BITS_PER_BYTE = 8;
+
+ secure_vector<byte>& buf = accum.get_io_buf(BOTAN_SYSTEM_RNG_POLL_REQUEST);
for(size_t i = 0; i != prov_types.size(); ++i)
{
CSP_Handle csp(prov_types[i]);
- if(size_t got = csp.gen_random(m_buf.data(), m_buf.size()))
+ if(size_t got = csp.gen_random(buf.data(), buf.size()))
{
- accum.add(m_buf.data(), got, 6);
+ accum.add(buf.data(), got, ENTROPY_BITS_PER_BYTE);
break;
}
}