aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-18 17:03:03 +0000
committerlloyd <[email protected]>2008-06-18 17:03:03 +0000
commit2479786db380d92aa6d777a72108ec725e625426 (patch)
tree8f4b762accd1f41b576f42b3318c4f0dfa685874
parentf1588d6d5c7c891f42164a36b9cab94c808855c6 (diff)
Move RNG code from base.cpp to new rng.cpp
-rw-r--r--src/base.cpp49
-rw-r--r--src/rng.cpp57
2 files changed, 57 insertions, 49 deletions
diff --git a/src/base.cpp b/src/base.cpp
index a1fd1ab1a..eb38d0c85 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -4,10 +4,7 @@
*************************************************/
#include <botan/base.h>
-#include <botan/rng.h>
#include <botan/version.h>
-#include <botan/util.h>
-#include <botan/config.h>
namespace Botan {
@@ -199,50 +196,4 @@ SecureVector<byte> BufferedComputation::process(const std::string& in)
return final();
}
-/*************************************************
-* Default fast poll for EntropySources *
-*************************************************/
-u32bit EntropySource::fast_poll(byte buf[], u32bit len)
- {
- return slow_poll(buf, len);
- }
-
-/*************************************************
-* Get a single random byte *
-*************************************************/
-byte RandomNumberGenerator::next_byte()
- {
- byte out;
- this->randomize(&out, 1);
- return out;
- }
-
-/*************************************************
-* Add entropy to internal state *
-*************************************************/
-void RandomNumberGenerator::add_entropy(const byte random[], u32bit length)
- {
- add_randomness(random, length);
- }
-
-/*************************************************
-* Add entropy to internal state *
-*************************************************/
-u32bit RandomNumberGenerator::add_entropy(EntropySource& source,
- bool slow_poll)
- {
- SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
-
- u32bit bytes_gathered = 0;
-
- if(slow_poll)
- bytes_gathered = source.slow_poll(buffer, buffer.size());
- else
- bytes_gathered = source.fast_poll(buffer, buffer.size());
-
- add_entropy(buffer, bytes_gathered);
-
- return entropy_estimate(buffer, bytes_gathered);
- }
-
}
diff --git a/src/rng.cpp b/src/rng.cpp
new file mode 100644
index 000000000..59d4e576d
--- /dev/null
+++ b/src/rng.cpp
@@ -0,0 +1,57 @@
+/*************************************************
+* Random Number Generator Base Source File *
+* (C) 1999-2008 Jack Lloyd *
+*************************************************/
+
+#include <botan/rng.h>
+#include <botan/secmem.h>
+#include <botan/util.h>
+
+namespace Botan {
+
+/*************************************************
+* Default fast poll for EntropySources *
+*************************************************/
+u32bit EntropySource::fast_poll(byte buf[], u32bit len)
+ {
+ return this->slow_poll(buf, len);
+ }
+
+/*************************************************
+* Get a single random byte *
+*************************************************/
+byte RandomNumberGenerator::next_byte()
+ {
+ byte out;
+ this->randomize(&out, 1);
+ return out;
+ }
+
+/*************************************************
+* Add entropy to internal state *
+*************************************************/
+void RandomNumberGenerator::add_entropy(const byte random[], u32bit length)
+ {
+ this->add_randomness(random, length);
+ }
+
+/*************************************************
+* Add entropy to internal state *
+*************************************************/
+u32bit RandomNumberGenerator::add_entropy(EntropySource& source,
+ bool slow_poll)
+ {
+ SecureVector<byte> buffer(1024);
+ u32bit bytes_gathered = 0;
+
+ if(slow_poll)
+ bytes_gathered = source.slow_poll(buffer, buffer.size());
+ else
+ bytes_gathered = source.fast_poll(buffer, buffer.size());
+
+ this->add_entropy(buffer, bytes_gathered);
+
+ return entropy_estimate(buffer, bytes_gathered);
+ }
+
+}