From bc1a4d5b5c977899e86209814663c983eaed7f8f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 19 Mar 2021 15:19:03 -0400 Subject: Update RDRAND, RDSEED and Packlock rng tests --- validat3.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'validat3.cpp') diff --git a/validat3.cpp b/validat3.cpp index 9e215959..ce9c6bdb 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -711,7 +711,7 @@ bool TestMersenne() bool pass = true; try {rng.reset(new MT19937ar);} - catch (const PadlockRNG_Err &) {} + catch (const Exception &) {} if(rng.get()) { @@ -720,7 +720,7 @@ bool TestMersenne() // Reset state try {rng.reset(new MT19937ar);} - catch (const PadlockRNG_Err &) {} + catch (const Exception &) {} if(rng.get()) { @@ -761,6 +761,10 @@ bool TestPadlockRNG() PadlockRNG& padlock = dynamic_cast(*rng.get()); pass = Test_RandomNumberGenerator(padlock); + // PadlockRNG does not accept entropy. However, the contract is no throw + const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + (void)padlock.IncorporateEntropy(entropy, sizeof(entropy)); + SecByteBlock zero(16), one(16), t(16); std::memset(zero, 0x00, zero.size()); std::memset( one, 0xff, one.size()); @@ -839,6 +843,10 @@ bool TestRDRAND() RDRAND& rdrand = dynamic_cast(*rng.get()); pass = Test_RandomNumberGenerator(rdrand) && pass; + // RDRAND does not accept entropy. However, the contract is no throw + const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + (void)rdrand.IncorporateEntropy(entropy, sizeof(entropy)); + MaurerRandomnessTest maurer; const unsigned int SIZE = 1024*10; RandomNumberSource(rdrand, SIZE, true, new Redirector(maurer)); @@ -880,6 +888,10 @@ bool TestRDSEED() RDSEED& rdseed = dynamic_cast(*rng.get()); pass = Test_RandomNumberGenerator(rdseed) && pass; + // RDSEED does not accept entropy. However, the contract is no throw + const byte entropy[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + (void)rdseed.IncorporateEntropy(entropy, sizeof(entropy)); + MaurerRandomnessTest maurer; const unsigned int SIZE = 1024*10; RandomNumberSource(rdseed, SIZE, true, new Redirector(maurer)); -- cgit v1.2.1