From 4dc05f350dadb70caf7d52f051110f5509ef46e1 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 23 Jun 2022 23:59:11 +0700 Subject: Remvoe ThreadedSeedGenerator --- crypto/src/security/SecureRandom.cs | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'crypto/src/security/SecureRandom.cs') diff --git a/crypto/src/security/SecureRandom.cs b/crypto/src/security/SecureRandom.cs index 4a16a6c4d..eb5d69618 100644 --- a/crypto/src/security/SecureRandom.cs +++ b/crypto/src/security/SecureRandom.cs @@ -2,7 +2,6 @@ using System; using System.Threading; using Org.BouncyCastle.Crypto; -using Org.BouncyCastle.Crypto.Digests; using Org.BouncyCastle.Crypto.Prng; using Org.BouncyCastle.Crypto.Utilities; using Org.BouncyCastle.Utilities; @@ -14,40 +13,6 @@ namespace Org.BouncyCastle.Security { private static long counter = Times.NanoTime(); -#if PORTABLE - private static object counterLock = new object(); - private static long NextCounterValue() - { - lock (counterLock) - { - return ++counter; - } - } - - private static readonly SecureRandom[] master = { null }; - private static SecureRandom Master - { - get - { - lock (master) - { - if (master[0] == null) - { - SecureRandom sr = master[0] = GetInstance("SHA256PRNG", false); - - // Even though Ticks has at most 8 or 14 bits of entropy, there's no harm in adding it. - sr.SetSeed(DateTime.Now.Ticks); - - // 32 will be enough when ThreadedSeedGenerator is fixed. Until then, ThreadedSeedGenerator returns low - // entropy, and this is not sufficient to be secure. http://www.bouncycastle.org/csharpdevmailarchive/msg00814.html - sr.SetSeed(new ThreadedSeedGenerator().GenerateSeed(32, true)); - } - - return master[0]; - } - } - } -#else private static long NextCounterValue() { return Interlocked.Increment(ref counter); @@ -58,7 +23,6 @@ namespace Org.BouncyCastle.Security { get { return master; } } -#endif private static DigestRandomGenerator CreatePrng(string digestName, bool autoSeed) { @@ -155,7 +119,6 @@ namespace Org.BouncyCastle.Security public override int Next(int maxValue) { - if (maxValue < 2) { if (maxValue < 0) -- cgit 1.4.1