public WindowsPrng() { // this.m_rnd = new Org.BouncyCastle.Crypto.Prng.CryptoApiRandomGenerator(); const string digestName = "SHA256"; Org.BouncyCastle.Crypto.IDigest digest = Org.BouncyCastle.Security.DigestUtilities.GetDigest(digestName); if (digest == null) { return; } Org.BouncyCastle.Crypto.Prng.DigestRandomGenerator prng = new Org.BouncyCastle.Crypto.Prng.DigestRandomGenerator(digest); const bool autoSeed = true; if (autoSeed) { // prng.AddSeedMaterial(NextCounterValue()); // prng.AddSeedMaterial(GetNextBytes(Master, digest.GetDigestSize())); } this.m_rnd = prng; }
public WindowsPrng() { // Don't use the bugged CryptoAPI // this.m_rnd = new Org.BouncyCastle.Crypto.Prng.CryptoApiRandomGenerator(); Org.BouncyCastle.Crypto.IDigest digest = Org.BouncyCastle.Security.DigestUtilities.GetDigest("SHA256"); if (digest == null) { return; } Org.BouncyCastle.Crypto.Prng.DigestRandomGenerator prng = new Org.BouncyCastle.Crypto.Prng.DigestRandomGenerator(digest); prng.AddSeedMaterial(NextCounterValue()); prng.AddSeedMaterial(GetNextBytes(digest.GetDigestSize())); this.m_rnd = prng; }