summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2017-06-11 20:30:29 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2017-06-11 20:30:29 +0700
commit6198fad8061760809fa1e6d3ca48e96fe40f51d3 (patch)
tree209281ffc4f80c147aac7ef3a55057f5e3a873e3 /crypto
parentFix reset for ISO9792-2 scheme (diff)
downloadBouncyCastle.NET-ed25519-6198fad8061760809fa1e6d3ca48e96fe40f51d3.tar.xz
Fix race condition
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/prng/SP800SecureRandom.cs10
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);
+            }
         }
     }
 }