diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-08-19 15:13:06 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-08-19 15:13:06 +0700 |
commit | cf1ad240147c298b6adabad399a8bf0f5756f606 (patch) | |
tree | 32c456ebb4e0470df04d6633cac88af2985286b7 /crypto/src/security/SecureRandom.cs | |
parent | Remove unnecessary TODO (diff) | |
download | BouncyCastle.NET-ed25519-cf1ad240147c298b6adabad399a8bf0f5756f606.tar.xz |
Implement NextBytes(Span<byte)
Diffstat (limited to 'crypto/src/security/SecureRandom.cs')
-rw-r--r-- | crypto/src/security/SecureRandom.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/security/SecureRandom.cs b/crypto/src/security/SecureRandom.cs index e8cac56f5..4e118e77a 100644 --- a/crypto/src/security/SecureRandom.cs +++ b/crypto/src/security/SecureRandom.cs @@ -181,6 +181,22 @@ namespace Org.BouncyCastle.Security generator.NextBytes(buf, off, len); } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override void NextBytes(Span<byte> buffer) + { + if (generator != null) + { + generator.NextBytes(buffer); + } + else + { + byte[] tmp = new byte[buffer.Length]; + NextBytes(tmp); + tmp.CopyTo(buffer); + } + } +#endif + private static readonly double DoubleScale = 1.0 / Convert.ToDouble(1L << 53); public override double NextDouble() |