示例#1
0
        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;
        }
示例#2
0
        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;
        }