aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-01-31 12:12:59 +0000
committerlloyd <[email protected]>2009-01-31 12:12:59 +0000
commit0f01c1e26394fabdb6eee7442bc657f159eccfef (patch)
tree6833562780d3c43641c97dbc168609449889d310 /src
parent0a9152898efe593bb96a619caf9d74f0bc7f75e4 (diff)
Track the collected entropy as a double instead of a unsigned int. Otherwise
inputs might end up not contributing anything to the count even when they should. This was paricularly noticable with the proc walker - it uses an estimate of .01 bits / byte, so if the file was < 100 bytes it would not count for anything at all.
Diffstat (limited to 'src')
-rw-r--r--src/entropy/entropy_src.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/entropy/entropy_src.h b/src/entropy/entropy_src.h
index c294ca6ac..3fd5c443e 100644
--- a/src/entropy/entropy_src.h
+++ b/src/entropy/entropy_src.h
@@ -29,7 +29,8 @@ class Entropy_Accumulator
MemoryRegion<byte>& get_io_buffer(u32bit size)
{ io_buffer.create(size); return io_buffer; }
- u32bit bits_collected() const { return collected_bits; }
+ u32bit bits_collected() const
+ { return static_cast<u32bit>(collected_bits); }
bool polling_goal_achieved() const
{ return (collected_bits >= entropy_goal); }
@@ -44,7 +45,7 @@ class Entropy_Accumulator
void add(const void* bytes, u32bit length, double entropy_bits_per_byte)
{
add_bytes(bytes, length);
- collected_bits += std::min<u32bit>(8, entropy_bits_per_byte) * length;
+ collected_bits += entropy_bits_per_byte * length;
}
template<typename T>
@@ -56,7 +57,8 @@ class Entropy_Accumulator
virtual void add_bytes(const void* bytes, u32bit length) = 0;
SecureVector<byte> io_buffer;
- u32bit entropy_goal, collected_bits;
+ u32bit entropy_goal;
+ double collected_bits;
};
class Entropy_Accumulator_BufferedComputation : public Entropy_Accumulator