diff --git a/crypto/test/src/security/test/SecureRandomTest.cs b/crypto/test/src/security/test/SecureRandomTest.cs
index f93afc0aa..f1d83b29c 100644
--- a/crypto/test/src/security/test/SecureRandomTest.cs
+++ b/crypto/test/src/security/test/SecureRandomTest.cs
@@ -3,7 +3,12 @@ using System.Text;
using NUnit.Framework;
+using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Digests;
+using Org.BouncyCastle.Crypto.Engines;
+using Org.BouncyCastle.Crypto.Macs;
using Org.BouncyCastle.Crypto.Prng;
+using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Security.Tests
@@ -61,6 +66,30 @@ namespace Org.BouncyCastle.Security.Tests
}
[Test]
+ public void TestSP800Ctr()
+ {
+ SecureRandom random = new SP800SecureRandomBuilder().BuildCtr(new AesFastEngine(), 256, new byte[32], false);
+
+ CheckSecureRandom(random);
+ }
+
+ [Test]
+ public void TestSP800Hash()
+ {
+ SecureRandom random = new SP800SecureRandomBuilder().BuildHash(new Sha256Digest(), new byte[32], false);
+
+ CheckSecureRandom(random);
+ }
+
+ [Test]
+ public void TestSP800HMac()
+ {
+ SecureRandom random = new SP800SecureRandomBuilder().BuildHMac(new HMac(new Sha256Digest()), new byte[32], false);
+
+ CheckSecureRandom(random);
+ }
+
+ [Test]
public void TestThreadedSeed()
{
SecureRandom random = SecureRandom.GetInstance("SHA1PRNG", false);
@@ -73,7 +102,15 @@ namespace Org.BouncyCastle.Security.Tests
public void TestVmpcPrng()
{
SecureRandom random = new SecureRandom(new VmpcRandomGenerator());
- random.SetSeed(SecureRandom.GetSeed(32));
+ random.SetSeed(random.GenerateSeed(32));
+
+ CheckSecureRandom(random);
+ }
+
+ [Test]
+ public void TestX931()
+ {
+ SecureRandom random = new X931SecureRandomBuilder().Build(new AesFastEngine(), new KeyParameter(new byte[16]), false);
CheckSecureRandom(random);
}
@@ -106,7 +143,7 @@ namespace Org.BouncyCastle.Security.Tests
private static double MeasureChiSquared(SecureRandom random, int rounds)
{
- byte[] opts = SecureRandom.GetSeed(2);
+ byte[] opts = random.GenerateSeed(2);
int[] counts = new int[256];
byte[] bs = new byte[256];
diff --git a/crypto/test/src/test/BlockCipherTest.cs b/crypto/test/src/test/BlockCipherTest.cs
index 93cf2b0a5..fc3a99f4e 100644
--- a/crypto/test/src/test/BlockCipherTest.cs
+++ b/crypto/test/src/test/BlockCipherTest.cs
@@ -410,7 +410,7 @@ namespace Org.BouncyCastle.Tests
else
{
// NB: rand always generates same values each test run
- iv = rand.GenerateSeed(ivLength);
+ iv = SecureRandom.GetNextBytes(rand, ivLength);
}
parameters = new ParametersWithIV(key, iv);
diff --git a/crypto/test/src/util/test/FixedSecureRandom.cs b/crypto/test/src/util/test/FixedSecureRandom.cs
index 15a2e9bb3..d8598ac24 100644
--- a/crypto/test/src/util/test/FixedSecureRandom.cs
+++ b/crypto/test/src/util/test/FixedSecureRandom.cs
@@ -38,7 +38,12 @@ namespace Org.BouncyCastle.Utilities.Test
return new FixedSecureRandom(bOut.ToArray());
}
- public override void NextBytes(
+ public override byte[] GenerateSeed(int numBytes)
+ {
+ return SecureRandom.GetNextBytes(this, numBytes);
+ }
+
+ public override void NextBytes(
byte[] buf)
{
Array.Copy(_data, _index, buf, 0, buf.Length);
|