From b5baa77759a46d7890b563b75e9b696314d09e63 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 25 Aug 2014 12:10:06 +0700 Subject: Rework the nonce-random initialisation and avoid GenerateSeed --- crypto/src/crypto/tls/AbstractTlsContext.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'crypto/src') diff --git a/crypto/src/crypto/tls/AbstractTlsContext.cs b/crypto/src/crypto/tls/AbstractTlsContext.cs index 6c663f54d..83150d37e 100644 --- a/crypto/src/crypto/tls/AbstractTlsContext.cs +++ b/crypto/src/crypto/tls/AbstractTlsContext.cs @@ -28,11 +28,14 @@ namespace Org.BouncyCastle.Crypto.Tls internal AbstractTlsContext(SecureRandom secureRandom, SecurityParameters securityParameters) { - secureRandom.SetSeed(NextCounterValue()); - secureRandom.SetSeed(Times.NanoTime()); - - this.mNonceRandom = new DigestRandomGenerator(TlsUtilities.CreateHash(HashAlgorithm.sha256)); - this.mNonceRandom.AddSeedMaterial(secureRandom.GenerateSeed(32)); + IDigest d = TlsUtilities.CreateHash(HashAlgorithm.sha256); + byte[] seed = new byte[d.GetDigestSize()]; + secureRandom.NextBytes(seed); + + this.mNonceRandom = new DigestRandomGenerator(d); + mNonceRandom.AddSeedMaterial(NextCounterValue()); + mNonceRandom.AddSeedMaterial(Times.NanoTime()); + mNonceRandom.AddSeedMaterial(seed); this.mSecureRandom = secureRandom; this.mSecurityParameters = securityParameters; -- cgit 1.5.1