8 #ifndef BOTAN_ENTROPY_SOURCE_BASE_H__
9 #define BOTAN_ENTROPY_SOURCE_BASE_H__
11 #include <botan/buf_comp.h>
27 entropy_goal(goal), collected_bits(0) {}
39 { io_buffer.
resize(size);
return io_buffer; }
45 {
return static_cast<size_t>(collected_bits); }
51 {
return (collected_bits >= entropy_goal); }
58 if(collected_bits >= entropy_goal)
60 return static_cast<size_t>(entropy_goal - collected_bits);
70 void add(
const void* bytes,
size_t length,
double entropy_bits_per_byte)
72 add_bytes(reinterpret_cast<const byte*>(bytes), length);
73 collected_bits += entropy_bits_per_byte * length;
83 void add(
const T& v,
double entropy_bits_per_byte)
85 add(&v,
sizeof(T), entropy_bits_per_byte);
88 virtual void add_bytes(
const byte bytes[],
size_t length) = 0;
92 double collected_bits;
111 virtual void add_bytes(
const byte bytes[],
size_t length)
113 entropy_sink.update(bytes, length);
116 Buffered_Computation& entropy_sink;
128 virtual std::string name()
const = 0;
virtual ~Entropy_Accumulator()
MemoryRegion< byte > & get_io_buffer(size_t size)
void add(const void *bytes, size_t length, double entropy_bits_per_byte)
bool polling_goal_achieved() const
size_t bits_collected() const
Entropy_Accumulator(size_t goal)
void add(const T &v, double entropy_bits_per_byte)
Entropy_Accumulator_BufferedComputation(Buffered_Computation &sink, size_t goal)
size_t desired_remaining_bits() const