diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-02-10 13:27:20 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-02-10 13:27:20 +0700 |
commit | cb28ec625a8f96e88a1668da3d0fa51a365f8b8a (patch) | |
tree | fbe84d80eded81d7afdfd867d8c5b4171be677b0 | |
parent | Various SHA512/224, SHA512/256, SHA3 support (diff) | |
download | BouncyCastle.NET-ed25519-cb28ec625a8f96e88a1668da3d0fa51a365f8b8a.tar.xz |
Add TestRandomData class
-rw-r--r-- | crypto/crypto.csproj | 5 | ||||
-rw-r--r-- | crypto/test/UnitTests.csproj | 1 | ||||
-rw-r--r-- | crypto/test/src/util/test/TestRandomData.cs | 33 |
3 files changed, 39 insertions, 0 deletions
diff --git a/crypto/crypto.csproj b/crypto/crypto.csproj index d3afdafe3..38be94ebf 100644 --- a/crypto/crypto.csproj +++ b/crypto/crypto.csproj @@ -13762,6 +13762,11 @@ BuildAction = "Compile" /> <File + RelPath = "test\src\util\test\TestRandomData.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "test\src\util\test\UncloseableStream.cs" SubType = "Code" BuildAction = "Compile" 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)}) + { + } + } +} |