diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-29 17:35:58 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-29 17:35:58 +0700 |
commit | 60c2d34deac485cb50c2350735b4efff50c88a62 (patch) | |
tree | c1b9cbe64d347b8572f2d41010bab158647da20a /crypto/test | |
parent | Refactor X509CertificatePair (diff) | |
download | BouncyCastle.NET-ed25519-60c2d34deac485cb50c2350735b4efff50c88a62.tar.xz |
Improve seed generation
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/crypto/prng/test/TestEntropySourceProvider.cs | 2 | ||||
-rw-r--r-- | crypto/test/src/util/test/FixedSecureRandom.cs | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/crypto/test/src/crypto/prng/test/TestEntropySourceProvider.cs b/crypto/test/src/crypto/prng/test/TestEntropySourceProvider.cs index ae80b3dbe..1c0d24dba 100644 --- a/crypto/test/src/crypto/prng/test/TestEntropySourceProvider.cs +++ b/crypto/test/src/crypto/prng/test/TestEntropySourceProvider.cs @@ -53,7 +53,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test #if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER int IEntropySource.GetEntropy(Span<byte> output) { - int length = bitsRequired / 8; + int length = System.Math.Min(output.Length, bitsRequired / 8); data.AsSpan(index, length).CopyTo(output); index += length; return length; diff --git a/crypto/test/src/util/test/FixedSecureRandom.cs b/crypto/test/src/util/test/FixedSecureRandom.cs index a7f3c1f3b..a23438794 100644 --- a/crypto/test/src/util/test/FixedSecureRandom.cs +++ b/crypto/test/src/util/test/FixedSecureRandom.cs @@ -213,6 +213,15 @@ namespace Org.BouncyCastle.Utilities.Test return GetNextBytes(this, numBytes); } + // NOTE: .NET Core 3.1 has Span<T>, but is tested against our .NET Standard 2.0 assembly. +//#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER +#if NET6_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override void GenerateSeed(Span<byte> seed) + { + NextBytes(seed); + } +#endif + public override void NextBytes(byte[] buf) { NextBytes(buf, 0, buf.Length); |