Add TestRandomData class
2 files changed, 34 insertions, 0 deletions
diff --git a/crypto/test/UnitTests.csproj b/crypto/test/UnitTests.csproj
index eca33fae5..cdc4d10bc 100644
--- a/crypto/test/UnitTests.csproj
+++ b/crypto/test/UnitTests.csproj
@@ -478,6 +478,7 @@
<Compile Include="src\util\test\SimpleTestResult.cs" />
<Compile Include="src\util\test\TestFailedException.cs" />
<Compile Include="src\util\test\TestRandomBigInteger.cs" />
+ <Compile Include="src\util\test\TestRandomData.cs" />
<Compile Include="src\util\test\UncloseableStream.cs" />
<Compile Include="src\x509\test\TestCertificateGen.cs" />
</ItemGroup>
diff --git a/crypto/test/src/util/test/TestRandomData.cs b/crypto/test/src/util/test/TestRandomData.cs
new file mode 100644
index 000000000..7fe0cf305
--- /dev/null
+++ b/crypto/test/src/util/test/TestRandomData.cs
@@ -0,0 +1,33 @@
+using System;
+
+using Org.BouncyCastle.Utilities.Encoders;
+
+namespace Org.BouncyCastle.Utilities.Test
+{
+ /**
+ * A fixed secure random designed to return data for someone needing random bytes.
+ */
+ public class TestRandomData
+ : FixedSecureRandom
+ {
+ /**
+ * Constructor from a Hex encoding of the data.
+ *
+ * @param encoding a Hex encoding of the data to be returned.
+ */
+ public TestRandomData(string encoding)
+ : this(Hex.Decode(encoding))
+ {
+ }
+
+ /**
+ * Constructor from an array of bytes.
+ *
+ * @param encoding a byte array representing the data to be returned.
+ */
+ public TestRandomData(byte[] encoding)
+ : base(new FixedSecureRandom.Source[] { new FixedSecureRandom.Data(encoding)})
+ {
+ }
+ }
+}
|