summary refs log tree commit diff
path: root/crypto/src/crypto/prng/DigestRandomGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/crypto/prng/DigestRandomGenerator.cs')
-rw-r--r--crypto/src/crypto/prng/DigestRandomGenerator.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/src/crypto/prng/DigestRandomGenerator.cs b/crypto/src/crypto/prng/DigestRandomGenerator.cs

index 024db2852..3587956b6 100644 --- a/crypto/src/crypto/prng/DigestRandomGenerator.cs +++ b/crypto/src/crypto/prng/DigestRandomGenerator.cs
@@ -90,6 +90,28 @@ namespace Org.BouncyCastle.Crypto.Prng } } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public virtual void NextBytes(Span<byte> bytes) + { + lock (this) + { + int stateOff = 0; + + GenerateState(); + + for (int i = 0; i < bytes.Length; ++i) + { + if (stateOff == state.Length) + { + GenerateState(); + stateOff = 0; + } + bytes[i] = state[stateOff++]; + } + } + } +#endif + private void CycleSeed() { DigestUpdate(seed);