summary refs log tree commit diff
path: root/crypto/src/security/SecureRandom.cs
diff options
context:
space:
mode:
authorOren Novotny <oren@novotny.org>2015-10-16 20:23:05 -0400
committerOren Novotny <oren@novotny.org>2015-10-16 20:23:05 -0400
commitde17e96f2d52a25a33e742d0f81e9052da77f49b (patch)
tree03ccef76aacc1bac6340df9faedf1d64dda76077 /crypto/src/security/SecureRandom.cs
parentprep release for 1.8.0-rc2 (diff)
parentMerge branch 'master' into master-vs12 (diff)
downloadBouncyCastle.NET-ed25519-de17e96f2d52a25a33e742d0f81e9052da77f49b.tar.xz
Merge branch 'master-vs12' into pcl
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 dc91069a1..4745c0bae 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 || PCL + private static object counterLock = new object(); private static long NextCounterValue() { - return Interlocked.Increment(ref counter); + lock (counterLock) + { + return ++counter; + } } -#if NETCF_1_0 || PCL 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 {