aboutsummaryrefslogtreecommitdiffstats
path: root/src/entropy/entropy_src.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-16 03:54:59 +0000
committerlloyd <[email protected]>2010-06-16 03:54:59 +0000
commitaa0c77746be858f094debf0d96e87c02908e8dc3 (patch)
tree98d66a941f476ad035ffc18138998b4bc1dfb8b9 /src/entropy/entropy_src.h
parent85780f6bbe02d7abd573f5b47bf9e79c611f5022 (diff)
Yet more Doxygen comments
Diffstat (limited to 'src/entropy/entropy_src.h')
-rw-r--r--src/entropy/entropy_src.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/entropy/entropy_src.h b/src/entropy/entropy_src.h
index 63fd6a1f7..898d650ce 100644
--- a/src/entropy/entropy_src.h
+++ b/src/entropy/entropy_src.h
@@ -20,23 +20,40 @@ namespace Botan {
class BOTAN_DLL Entropy_Accumulator
{
public:
+ /**
+ * Initialize an Entropy_Accumulator
+ * @param goal is how many bits we would like to collect
+ */
Entropy_Accumulator(u32bit goal) :
entropy_goal(goal), collected_bits(0) {}
virtual ~Entropy_Accumulator() {}
/**
- @return cached I/O buffer for repeated polls
+ * Get a cached I/O buffer (purely for minimizing allocation
+ * overhead to polls)
+ *
+ * @param size requested size for the I/O buffer
+ * @return cached I/O buffer for repeated polls
*/
MemoryRegion<byte>& get_io_buffer(u32bit size)
{ io_buffer.resize(size); return io_buffer; }
+ /**
+ * @return number of bits collected so far
+ */
u32bit bits_collected() const
{ return static_cast<u32bit>(collected_bits); }
+ /**
+ * @return if our polling goal has been achieved
+ */
bool polling_goal_achieved() const
{ return (collected_bits >= entropy_goal); }
+ /**
+ * @return how many bits we need to reach our polling goal
+ */
u32bit desired_remaining_bits() const
{
if(collected_bits >= entropy_goal)
@@ -44,12 +61,25 @@ class BOTAN_DLL Entropy_Accumulator
return static_cast<u32bit>(entropy_goal - collected_bits);
}
+ /**
+ * Add entropy to the accumulator
+ * @param bytes the input bytes
+ * @param length specifies how many bytes the input is
+ * @param entropy_bits_per_byte is a best guess at how much
+ * entropy per byte is in this input
+ */
void add(const void* bytes, u32bit length, double entropy_bits_per_byte)
{
add_bytes(reinterpret_cast<const byte*>(bytes), length);
collected_bits += entropy_bits_per_byte * length;
}
+ /**
+ * Add entropy to the accumulator
+ * @param v is some value
+ * @param entropy_bits_per_byte is a best guess at how much
+ * entropy per byte is in this input
+ */
template<typename T>
void add(const T& v, double entropy_bits_per_byte)
{
@@ -88,8 +118,17 @@ class BOTAN_DLL Entropy_Accumulator_BufferedComputation : public Entropy_Accumul
class BOTAN_DLL EntropySource
{
public:
+ /**
+ * @return name identifying this entropy source
+ */
virtual std::string name() const = 0;
+
+ /**
+ * Perform an entropy gathering poll
+ * @param accum is an accumulator object that will be given entropy
+ */
virtual void poll(Entropy_Accumulator& accum) = 0;
+
virtual ~EntropySource() {}
};