summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-08-25 12:10:06 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-08-25 12:10:06 +0700
commitb5baa77759a46d7890b563b75e9b696314d09e63 (patch)
tree387c75d60b04f6d24b72595d157d132e399c225f
parentPort TLS server impl/test from Java API (diff)
downloadBouncyCastle.NET-ed25519-b5baa77759a46d7890b563b75e9b696314d09e63.tar.xz
Rework the nonce-random initialisation and avoid GenerateSeed
-rw-r--r--crypto/src/crypto/tls/AbstractTlsContext.cs13
1 files changed, 8 insertions, 5 deletions
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;