From 6198fad8061760809fa1e6d3ca48e96fe40f51d3 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 11 Jun 2017 20:30:29 +0700 Subject: Fix race condition --- crypto/src/crypto/prng/SP800SecureRandom.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crypto/src') 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 /// optional additional input public virtual void Reseed(byte[] additionalInput) { - mDrbg.Reseed(additionalInput); + lock (this) + { + if (mDrbg == null) + { + mDrbg = mDrbgProvider.Get(mEntropySource); + } + + mDrbg.Reseed(additionalInput); + } } } } -- cgit 1.5.1