summary refs log tree commit diff
path: root/crypto/src/security/SecureRandom.cs
diff options
context:
space:
mode:
authorDavid Hook <dgh@bouncycastle.org>2015-10-17 12:02:13 +1100
committerDavid Hook <dgh@bouncycastle.org>2015-10-17 12:02:13 +1100
commita5cbee77ad34986bdeedd1560a6a2b373176d16b (patch)
treef4f550192ecfd912924864e01d0a394a819f03f0 /crypto/src/security/SecureRandom.cs
parentInitial cut of SignerInfoGenerator for CMS (diff)
parentPort of non-blocking TLS API from Java (diff)
downloadBouncyCastle.NET-ed25519-a5cbee77ad34986bdeedd1560a6a2b373176d16b.tar.xz
Merge branch 'master' of bcgit@git.bouncycastle.org:bc-csharp.git
Diffstat (limited to 'crypto/src/security/SecureRandom.cs')
-rw-r--r--crypto/src/security/SecureRandom.cs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/src/security/SecureRandom.cs b/crypto/src/security/SecureRandom.cs

index f46427a5c..137a471c1 100644 --- a/crypto/src/security/SecureRandom.cs +++ b/crypto/src/security/SecureRandom.cs
@@ -13,12 +13,16 @@ namespace Org.BouncyCastle.Security { private static long counter = Times.NanoTime(); +#if NETCF_1_0 + private static object counterLock = new object(); private static long NextCounterValue() { - return Interlocked.Increment(ref counter); + lock (counterLock) + { + return ++counter; + } } -#if NETCF_1_0 private static readonly SecureRandom[] master = { null }; private static SecureRandom Master { @@ -43,6 +47,11 @@ namespace Org.BouncyCastle.Security } } #else + private static long NextCounterValue() + { + return Interlocked.Increment(ref counter); + } + private static readonly SecureRandom master = new SecureRandom(new CryptoApiRandomGenerator()); private static SecureRandom Master {