diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-06-11 20:30:29 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-06-11 20:30:29 +0700 |
commit | 6198fad8061760809fa1e6d3ca48e96fe40f51d3 (patch) | |
tree | 209281ffc4f80c147aac7ef3a55057f5e3a873e3 | |
parent | Fix reset for ISO9792-2 scheme (diff) | |
download | BouncyCastle.NET-ed25519-6198fad8061760809fa1e6d3ca48e96fe40f51d3.tar.xz |
Fix race condition
-rw-r--r-- | crypto/src/crypto/prng/SP800SecureRandom.cs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/src/crypto/prng/SP800SecureRandom.cs b/crypto/src/crypto/prng/SP800SecureRandom.cs index ac69e27e2..30c838c1b 100644 --- a/crypto/src/crypto/prng/SP800SecureRandom.cs +++ b/crypto/src/crypto/prng/SP800SecureRandom.cs @@ -81,7 +81,15 @@ namespace Org.BouncyCastle.Crypto.Prng /// <param name="additionalInput">optional additional input</param> public virtual void Reseed(byte[] additionalInput) { - mDrbg.Reseed(additionalInput); + lock (this) + { + if (mDrbg == null) + { + mDrbg = mDrbgProvider.Get(mEntropySource); + } + + mDrbg.Reseed(additionalInput); + } } } } |