aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-27 18:30:07 +0000
committerlloyd <[email protected]>2008-06-27 18:30:07 +0000
commite2a465b75d8baeac912e3f4d428ebc5e03fd76f1 (patch)
tree7490308782cbac8b0ec9ca0cc23d73ec8a0a7b68 /include
parentd84a769cc563aebeae3893f952cba1659562e430 (diff)
New structure for entropy sources + RNGs. The entropy sources are owned by
Randpool, it will query them as needed (or if asked to do so). New function make_rng() that creates an RNG (X9.31 backed by a Randpool) and seeds it. Remove the entropy source related code from the Modules/Builtin_Modules classes.
Diffstat (limited to 'include')
-rw-r--r--include/modules.h4
-rw-r--r--include/randpool.h9
-rw-r--r--include/rng.h10
-rw-r--r--include/x931_rng.h5
4 files changed, 17 insertions, 11 deletions
diff --git a/include/modules.h b/include/modules.h
index fb021405a..48a07c437 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1,6 +1,6 @@
/*************************************************
* Module Factory Header File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#ifndef BOTAN_MODULE_FACTORIES_H__
@@ -23,7 +23,6 @@ class BOTAN_DLL Modules
virtual std::string default_allocator() const = 0;
virtual std::vector<class Allocator*> allocators() const = 0;
- virtual std::vector<class EntropySource*> entropy_sources() const = 0;
virtual std::vector<class Engine*> engines() const = 0;
virtual ~Modules() {}
@@ -40,7 +39,6 @@ class BOTAN_DLL Builtin_Modules : public Modules
std::string default_allocator() const;
std::vector<class Allocator*> allocators() const;
- std::vector<class EntropySource*> entropy_sources() const;
std::vector<class Engine*> engines() const;
Builtin_Modules(const InitializerOptions&);
diff --git a/include/randpool.h b/include/randpool.h
index e73ba7f3e..b68dec765 100644
--- a/include/randpool.h
+++ b/include/randpool.h
@@ -1,6 +1,6 @@
/*************************************************
* Randpool Header File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#ifndef BOTAN_RANDPOOL_H__
@@ -8,6 +8,7 @@
#include <botan/rng.h>
#include <botan/base.h>
+#include <vector>
namespace Botan {
@@ -22,10 +23,13 @@ class BOTAN_DLL Randpool : public RandomNumberGenerator
void clear() throw();
std::string name() const;
+ void reseed();
+ void add_entropy_source(EntropySource*);
+ void add_entropy(const byte[], u32bit);
+
Randpool(const std::string&, const std::string&);
~Randpool();
private:
- void add_randomness(const byte[], u32bit);
void update_buffer();
void mix_pool();
@@ -33,6 +37,7 @@ class BOTAN_DLL Randpool : public RandomNumberGenerator
BlockCipher* cipher;
MessageAuthenticationCode* mac;
+ std::vector<EntropySource*> entropy_sources;
SecureVector<byte> pool, buffer, counter;
u32bit entropy;
};
diff --git a/include/rng.h b/include/rng.h
index 3a3b66251..fc75237cc 100644
--- a/include/rng.h
+++ b/include/rng.h
@@ -33,14 +33,16 @@ class BOTAN_DLL RandomNumberGenerator
byte next_byte();
- void add_entropy(const byte[], u32bit);
- u32bit add_entropy(EntropySource&, bool = true);
+ virtual void reseed() {};
virtual ~RandomNumberGenerator() {}
- private:
- virtual void add_randomness(const byte[], u32bit) = 0;
};
+/*************************************************
+* Create and seed an RNG *
+*************************************************/
+RandomNumberGenerator* make_rng();
+
}
#endif
diff --git a/include/x931_rng.h b/include/x931_rng.h
index 0076bb3f7..2ba39361d 100644
--- a/include/x931_rng.h
+++ b/include/x931_rng.h
@@ -1,6 +1,6 @@
/*************************************************
* ANSI X9.31 RNG Header File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#ifndef BOTAN_ANSI_X931_RNG_H__
@@ -22,10 +22,11 @@ class BOTAN_DLL ANSI_X931_RNG : public RandomNumberGenerator
void clear() throw();
std::string name() const;
+ void reseed();
+
ANSI_X931_RNG(const std::string&, RandomNumberGenerator*);
~ANSI_X931_RNG();
private:
- void add_randomness(const byte[], u32bit);
void update_buffer();
BlockCipher* cipher;