aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-01-31 12:46:36 +0000
committerlloyd <[email protected]>2009-01-31 12:46:36 +0000
commitc9c5f9ae8c136b8a6a94c41ccc7d5b55509125a4 (patch)
tree2b4fb2c8c707348b1b93e4d86fb795dc83f25505 /doc/examples
parentb118c41af387f765effcca47c08fc2dcc3844778 (diff)
Update examples for changed EntropySource and RandomNumberGenerator interfaces
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/rng_test.cpp2
-rw-r--r--doc/examples/test_es.cpp23
2 files changed, 14 insertions, 11 deletions
diff --git a/doc/examples/rng_test.cpp b/doc/examples/rng_test.cpp
index e38628d15..9ecb04e78 100644
--- a/doc/examples/rng_test.cpp
+++ b/doc/examples/rng_test.cpp
@@ -58,6 +58,8 @@ class Fixed_Output_RNG : public RandomNumberGenerator
std::string name() const { return "Fixed_Output_RNG"; }
+ void reseed(u32bit) {}
+
void clear() throw() {}
void add_entropy(const byte in[], u32bit len)
diff --git a/doc/examples/test_es.cpp b/doc/examples/test_es.cpp
index b7b2e9162..5d0c1ae5a 100644
--- a/doc/examples/test_es.cpp
+++ b/doc/examples/test_es.cpp
@@ -32,19 +32,21 @@
using namespace Botan;
-class Saver_Of_Bytes : public BufferedComputation
+class Saver_Of_Bytes : public Entropy_Accumulator
{
public:
- Saver_Of_Bytes() : BufferedComputation(0), outbuf(64), written(0) {}
- void add_data(const byte in[], u32bit length)
+ Saver_Of_Bytes(u32bit bits) :
+ Entropy_Accumulator(bits), outbuf(64), written(0) {}
+
+ void add_bytes(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); }
+
+ void trunc() { if(written < 64) outbuf.resize(written); }
std::vector<byte> outbuf;
u32bit written;
@@ -56,16 +58,15 @@ void test_entropy_source(EntropySource* es)
printf("Polling '%s':\n", es->name().c_str());
- Saver_Of_Bytes save;
+ Saver_Of_Bytes accum(128);
- Entropy_Accumulator accum(save, 128);
es->poll(accum);
- save.final_result(0);
+ accum.trunc();
- printf("Got %d bytes\n", save.written);
- for(size_t i = 0; i != save.outbuf.size(); ++i)
- printf("%02X", save.outbuf[i]);
+ printf("Got %d bytes\n", accum.written);
+ for(size_t i = 0; i != accum.outbuf.size(); ++i)
+ printf("%02X", accum.outbuf[i]);
printf("\n");
delete es;