summaryrefslogtreecommitdiff
path: root/validat3.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-08-12 05:34:11 -0400
committerJeffrey Walton <noloader@gmail.com>2019-08-12 05:34:11 -0400
commit6028587b9f7870b15bc8845080cd572a347354ea (patch)
tree17e3b989def9a4ed39b5973980ed45259d274d46 /validat3.cpp
parent34e49627b77e5a2e800ec7cd709a63d5d49860b6 (diff)
downloadcryptopp-git-6028587b9f7870b15bc8845080cd572a347354ea.tar.gz
Tighten Test_RandomNumberGenerator test
Debian HURD was slipping between the cracks. HURD appeared to be a minor failure because entropy on the heap improved the test result. After we zero'd the block, it was a catastrophic failure.
Diffstat (limited to 'validat3.cpp')
-rw-r--r--validat3.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/validat3.cpp b/validat3.cpp
index b5dcd6d2..bd4c4f51 100644
--- a/validat3.cpp
+++ b/validat3.cpp
@@ -429,8 +429,17 @@ bool Test_RandomNumberGenerator(RandomNumberGenerator& prng, bool drain=false)
RandomNumberSource(prng, UINT_MAX, true, new Redirector(TheBitBucket()));
}
+ // Use a block that is zero'd to catch bad RNG's that appear [somewhat]
+ // OK due to entropy in the heap. We found Debian HURD was failing, but
+ // not that badly. For example, we would see "100000 generated bytes
+ // compressed to 98749 bytes by DEFLATE". Once we zero'd the block, the
+ // message changed to "100000 generated bytes compressed to 27 bytes by
+ // DEFLATE". Doh...
+ SecByteBlock block(NULLPTR, GENERATE_SIZE);
+ RandomNumberSource(prng, GENERATE_SIZE, new ArraySink(block, block.size()));
+
MeterFilter meter(new Redirector(TheBitBucket()));
- RandomNumberSource(prng, GENERATE_SIZE, true, new Deflator(new Redirector(meter)));
+ StringSource(block, block.size(), true, new Deflator(new Redirector(meter)));
if (meter.GetTotalBytes() < GENERATE_SIZE)
{