aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/rng.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/rng.h')
-rw-r--r--src/core/rng.h57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/core/rng.h b/src/core/rng.h
index d313ad028..d6d37a7a0 100644
--- a/src/core/rng.h
+++ b/src/core/rng.h
@@ -21,24 +21,63 @@ class BOTAN_DLL EntropySource
virtual ~EntropySource() {}
};
-/*************************************************
-* Random Number Generator *
-*************************************************/
+/**
+* This class represents a random number (RNG) generator object.
+*/
class BOTAN_DLL RandomNumberGenerator
{
public:
+ /**
+ * Create a seeded and active RNG object for general application use
+ */
static RandomNumberGenerator* make_rng();
- virtual void randomize(byte[], u32bit) = 0;
- virtual bool is_seeded() const = 0;
- virtual void clear() throw() = 0;
- virtual std::string name() const = 0;
+ /**
+ * Randomize a byte array.
+ * @param output the byte array to hold the random output.
+ * @param length the length of the byte array output.
+ */
+ virtual void randomize(byte output[], u32bit length) = 0;
+ /**
+ * Return a random byte
+ * @return random byte
+ */
byte next_byte();
+ /**
+ * Check whether this RNG is seeded.
+ * @return true if this RNG was already seeded, false otherwise.
+ */
+ virtual bool is_seeded() const { return true; }
+
+ /**
+ * Clear all internally held values of this RNG.
+ */
+ virtual void clear() throw() = 0;
+
+ /**
+ * Return the name of this object
+ */
+ virtual std::string name() const = 0;
+
+ /**
+ * Force a reseed of the PRNG
+ */
virtual void reseed() {}
- virtual void add_entropy_source(EntropySource*) = 0;
- virtual void add_entropy(const byte[], u32bit) = 0;
+
+ /**
+ * Add this entropy source to the RNG object
+ * @param source the entropy source which will be retained and used by RNG
+ */
+ virtual void add_entropy_source(EntropySource* source) = 0;
+
+ /**
+ * Add entropy to this RNG.
+ * @param in a byte array containg the entropy to be added
+ * @param length the length of the byte array in
+ */
+ virtual void add_entropy(const byte in[], u32bit length) = 0;
RandomNumberGenerator() {}
virtual ~RandomNumberGenerator() {}