diff options
author | Jeffrey Walton <noloader@gmail.com> | 2021-03-19 15:19:03 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2021-03-19 15:19:03 -0400 |
commit | bc1a4d5b5c977899e86209814663c983eaed7f8f (patch) | |
tree | 4fad9123a4e7fb23ca29955019bea133a7068a1f /validat3.cpp | |
parent | 793f795ef3b3737bbb3d8b00ea8e6a0dabae11ab (diff) | |
download | cryptopp-git-bc1a4d5b5c977899e86209814663c983eaed7f8f.tar.gz |
Update RDRAND, RDSEED and Packlock rng tests
Diffstat (limited to 'validat3.cpp')
-rw-r--r-- | validat3.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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<PadlockRNG&>(*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<RDRAND&>(*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<RDSEED&>(*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));
|