diff options
Diffstat (limited to 'src/entropy/buf_es/buf_es.cpp')
-rw-r--r-- | src/entropy/buf_es/buf_es.cpp | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/entropy/buf_es/buf_es.cpp b/src/entropy/buf_es/buf_es.cpp deleted file mode 100644 index 4a88d67bd..000000000 --- a/src/entropy/buf_es/buf_es.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************* -* Buffered EntropySource Source File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#include <botan/buf_es.h> -#include <botan/xor_buf.h> -#include <botan/util.h> -#include <algorithm> - -namespace Botan { - -/************************************************* -* Buffered_EntropySource Constructor * -*************************************************/ -Buffered_EntropySource::Buffered_EntropySource() : buffer(128) - { - read_pos = write_pos = 0; - } - -/************************************************* -* Fast Poll * -*************************************************/ -u32bit Buffered_EntropySource::fast_poll(byte out[], u32bit length) - { - do_fast_poll(); - return copy_out(out, length, buffer.size() / 4); - } - -/************************************************* -* Slow Poll * -*************************************************/ -u32bit Buffered_EntropySource::slow_poll(byte out[], u32bit length) - { - do_slow_poll(); - return copy_out(out, length, buffer.size()); - } - -/************************************************* -* Default fast poll operation * -*************************************************/ -void Buffered_EntropySource::do_fast_poll() - { - return do_slow_poll(); - } - -/************************************************* -* Add entropy to the internal buffer * -*************************************************/ -void Buffered_EntropySource::add_bytes(const void* entropy_ptr, u32bit length) - { - const byte* bytes = static_cast<const byte*>(entropy_ptr); - - while(length) - { - u32bit copied = std::min(length, buffer.size() - write_pos); - xor_buf(buffer + write_pos, bytes, copied); - bytes += copied; - length -= copied; - write_pos = (write_pos + copied) % buffer.size(); - } - } - -/************************************************* -* Add entropy to the internal buffer * -*************************************************/ -void Buffered_EntropySource::add_bytes(u64bit entropy) - { - add_bytes(&entropy, 8); - } - -/************************************************* -* Take entropy from the internal buffer * -*************************************************/ -u32bit Buffered_EntropySource::copy_out(byte out[], u32bit length, - u32bit max_read) - { - length = std::min(length, max_read); - u32bit copied = std::min(length, buffer.size() - read_pos); - xor_buf(out, buffer + read_pos, copied); - read_pos = (read_pos + copied) % buffer.size(); - return copied; - } - -} |