aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-01-31 12:30:31 +0000
committerlloyd <[email protected]>2009-01-31 12:30:31 +0000
commitb118c41af387f765effcca47c08fc2dcc3844778 (patch)
tree5b63b0ee31cdb8226249e3488b065e51ddfc18e3 /doc
parent3f5c33c9ece2e7373dde96af045cd5a4853697be (diff)
parentf985e438ca768e59626ff08b143a6c80cf671b9e (diff)
propagate from branch 'net.randombit.botan' (head 4518ef63a5e28e22a61d21a6066d0d4a5cf0616e)
to branch 'net.randombit.botan.entropy-poll-redesign' (head c8e07f10a193b25bab726af99ea2ea77a0f30eaf)
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/test_es.cpp41
-rw-r--r--doc/license.txt2
2 files changed, 28 insertions, 15 deletions
diff --git a/doc/examples/test_es.cpp b/doc/examples/test_es.cpp
index 18531b326..b7b2e9162 100644
--- a/doc/examples/test_es.cpp
+++ b/doc/examples/test_es.cpp
@@ -32,27 +32,40 @@
using namespace Botan;
+class Saver_Of_Bytes : public BufferedComputation
+ {
+ public:
+ Saver_Of_Bytes() : BufferedComputation(0), outbuf(64), written(0) {}
+ void add_data(const byte in[], u32bit length)
+ {
+ for(size_t i = 0; i != length; ++i)
+ outbuf[i % outbuf.size()] ^= in[i];
+
+ written += length;
+ //outbuf.insert(outbuf.end(), in, in+length);
+ }
+ void final_result(byte[]) { if(written < 64) outbuf.resize(written); }
+
+ std::vector<byte> outbuf;
+ u32bit written;
+ };
+
void test_entropy_source(EntropySource* es)
{
// sometimes iostreams really is just a pain
- // upper buffer size of 96 to match HMAC_RNG's
- byte buf[96] = { 0 };
-
printf("Polling '%s':\n", es->name().c_str());
- printf(" Fast poll... ");
- u32bit fast_poll_got = es->fast_poll(buf, sizeof(buf));
- printf("got %d bytes: ", fast_poll_got);
- for(u32bit i = 0; i != fast_poll_got; ++i)
- printf("%02X", buf[i]);
- printf("\n");
+ Saver_Of_Bytes save;
+
+ Entropy_Accumulator accum(save, 128);
+ es->poll(accum);
+
+ save.final_result(0);
- printf(" Slow poll... ");
- u32bit slow_poll_got = es->slow_poll(buf, sizeof(buf));
- printf("got %d bytes: ", slow_poll_got);
- for(u32bit i = 0; i != slow_poll_got; ++i)
- printf("%02X", buf[i]);
+ printf("Got %d bytes\n", save.written);
+ for(size_t i = 0; i != save.outbuf.size(); ++i)
+ printf("%02X", save.outbuf[i]);
printf("\n");
delete es;
diff --git a/doc/license.txt b/doc/license.txt
index 0f281171c..4c3fc1999 100644
--- a/doc/license.txt
+++ b/doc/license.txt
@@ -1,4 +1,4 @@
-Copyright (C) 1999-2008 Jack Lloyd
+Copyright (C) 1999-2009 Jack Lloyd
2001 Peter J Jones
2004-2007 Justin Karneges
2005 Matthew Gregan