aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/entropy/cryptoapi_rng
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
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')
-rw-r--r--src/lib/entropy/cryptoapi_rng/es_capi.cpp8
-rw-r--r--src/lib/entropy/cryptoapi_rng/es_capi.h5
2 files changed, 7 insertions, 6 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;
}
}
diff --git a/src/lib/entropy/cryptoapi_rng/es_capi.h b/src/lib/entropy/cryptoapi_rng/es_capi.h
index 81a5003b2..eb63183e9 100644
--- a/src/lib/entropy/cryptoapi_rng/es_capi.h
+++ b/src/lib/entropy/cryptoapi_rng/es_capi.h
@@ -16,10 +16,10 @@ namespace Botan {
/**
* Win32 CAPI Entropy Source
*/
-class Win32_CAPI_EntropySource : public EntropySource
+class Win32_CAPI_EntropySource : public Entropy_Source
{
public:
- std::string name() const override { return "Win32 CryptoGenRandom"; }
+ std::string name() const override { return "win32_cryptoapi"; }
void poll(Entropy_Accumulator& accum) override;
@@ -30,7 +30,6 @@ class Win32_CAPI_EntropySource : public EntropySource
Win32_CAPI_EntropySource(const std::string& provs = "");
private:
std::vector<u64bit> prov_types;
- secure_vector<byte> m_buf;
};
}