summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-12 00:09:29 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-12 00:09:29 +0700
commit00809134ca4f89f1493fa11d56ee137b6ee87d72 (patch)
tree2541aa946de6cebe06d9e3ee2e12f478c39270ed
parentChange method names in IXof (diff)
downloadBouncyCastle.NET-ed25519-00809134ca4f89f1493fa11d56ee137b6ee87d72.tar.xz
Add BcTlsCrypto default constructor
-rw-r--r--crypto/src/tls/crypto/impl/bc/BcTlsCrypto.cs5
-rw-r--r--crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs3
-rw-r--r--crypto/test/src/tls/test/MockDtlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockDtlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskDtlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskDtlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskTls13Client.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskTls13Server.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskTlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockPskTlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/MockRawKeysTlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockRawKeysTlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/MockSrpTlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockSrpTlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/MockTlsClient.cs3
-rw-r--r--crypto/test/src/tls/test/MockTlsServer.cs3
-rw-r--r--crypto/test/src/tls/test/PrfTest.cs11
-rw-r--r--crypto/test/src/tls/test/TlsTestSuite.cs3
18 files changed, 25 insertions, 39 deletions
diff --git a/crypto/src/tls/crypto/impl/bc/BcTlsCrypto.cs b/crypto/src/tls/crypto/impl/bc/BcTlsCrypto.cs
index a4964c4b3..66f47c091 100644
--- a/crypto/src/tls/crypto/impl/bc/BcTlsCrypto.cs
+++ b/crypto/src/tls/crypto/impl/bc/BcTlsCrypto.cs
@@ -27,6 +27,11 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC
     {
         private readonly SecureRandom m_entropySource;
 
+        public BcTlsCrypto()
+            : this(new SecureRandom())
+        {
+        }
+
         public BcTlsCrypto(SecureRandom entropySource)
         {
             this.m_entropySource = entropySource;
diff --git a/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs b/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs
index a91d1dd31..16e53b60b 100644
--- a/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs
+++ b/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs
@@ -5,7 +5,6 @@ using System.IO;
 using NUnit.Framework;
 
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 using Org.BouncyCastle.Tls.Tests;
 using Org.BouncyCastle.Utilities;
@@ -69,7 +68,7 @@ namespace Org.BouncyCastle.Tls.Crypto.Tests
             + "c1 fc eb e1 1a 03 9e c1 76 94 fa c6 e9 85 27 b6 42 f2 ed d5 ce"
             + "61");
 
-        private readonly TlsCrypto m_crypto = new BcTlsCrypto(new SecureRandom());
+        private readonly TlsCrypto m_crypto = new BcTlsCrypto();
 
         protected TlsCredentialedSigner LoadCredentialedSigner(TlsCryptoParameters cryptoParams, string resource,
             SignatureAndHashAlgorithm signatureAndHashAlgorithm)
diff --git a/crypto/test/src/tls/test/MockDtlsClient.cs b/crypto/test/src/tls/test/MockDtlsClient.cs
index 5feab0c24..9898acd08 100644
--- a/crypto/test/src/tls/test/MockDtlsClient.cs
+++ b/crypto/test/src/tls/test/MockDtlsClient.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -17,7 +16,7 @@ namespace Org.BouncyCastle.Tls.Tests
         internal TlsSession m_session;
 
         internal MockDtlsClient(TlsSession session)
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
             this.m_session = session;
         }
diff --git a/crypto/test/src/tls/test/MockDtlsServer.cs b/crypto/test/src/tls/test/MockDtlsServer.cs
index adfc40db2..f69b6df91 100644
--- a/crypto/test/src/tls/test/MockDtlsServer.cs
+++ b/crypto/test/src/tls/test/MockDtlsServer.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Encoders;
 
 namespace Org.BouncyCastle.Tls.Tests
@@ -14,7 +13,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : DefaultTlsServer
     {
         internal MockDtlsServer()
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockPskDtlsClient.cs b/crypto/test/src/tls/test/MockPskDtlsClient.cs
index c32dd628b..fe666c98e 100644
--- a/crypto/test/src/tls/test/MockPskDtlsClient.cs
+++ b/crypto/test/src/tls/test/MockPskDtlsClient.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -22,7 +21,7 @@ namespace Org.BouncyCastle.Tls.Tests
         }
 
         internal MockPskDtlsClient(TlsSession session, TlsPskIdentity pskIdentity)
-            : base(new BcTlsCrypto(new SecureRandom()), pskIdentity)
+            : base(new BcTlsCrypto(), pskIdentity)
         {
             this.m_session = session;
         }
diff --git a/crypto/test/src/tls/test/MockPskDtlsServer.cs b/crypto/test/src/tls/test/MockPskDtlsServer.cs
index 5bcee9be7..8fba804ca 100644
--- a/crypto/test/src/tls/test/MockPskDtlsServer.cs
+++ b/crypto/test/src/tls/test/MockPskDtlsServer.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -13,7 +12,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : PskTlsServer
     {
         internal MockPskDtlsServer()
-            : base(new BcTlsCrypto(new SecureRandom()), new MyIdentityManager())
+            : base(new BcTlsCrypto(), new MyIdentityManager())
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockPskTls13Client.cs b/crypto/test/src/tls/test/MockPskTls13Client.cs
index 6655e8e5e..09d98c0f8 100644
--- a/crypto/test/src/tls/test/MockPskTls13Client.cs
+++ b/crypto/test/src/tls/test/MockPskTls13Client.cs
@@ -4,7 +4,6 @@ using System.IO;
 
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Tls.Tests
@@ -13,7 +12,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : AbstractTlsClient
     {
         internal MockPskTls13Client()
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockPskTls13Server.cs b/crypto/test/src/tls/test/MockPskTls13Server.cs
index b013c2710..aad076307 100644
--- a/crypto/test/src/tls/test/MockPskTls13Server.cs
+++ b/crypto/test/src/tls/test/MockPskTls13Server.cs
@@ -4,7 +4,6 @@ using System.IO;
 
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Tls.Tests
@@ -13,7 +12,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : AbstractTlsServer
     {
         internal MockPskTls13Server()
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockPskTlsClient.cs b/crypto/test/src/tls/test/MockPskTlsClient.cs
index 2a62cfa36..97137ba76 100644
--- a/crypto/test/src/tls/test/MockPskTlsClient.cs
+++ b/crypto/test/src/tls/test/MockPskTlsClient.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -22,7 +21,7 @@ namespace Org.BouncyCastle.Tls.Tests
         }
 
         internal MockPskTlsClient(TlsSession session, TlsPskIdentity pskIdentity)
-            : base(new BcTlsCrypto(new SecureRandom()), pskIdentity)
+            : base(new BcTlsCrypto(), pskIdentity)
         {
             this.m_session = session;
         }
diff --git a/crypto/test/src/tls/test/MockPskTlsServer.cs b/crypto/test/src/tls/test/MockPskTlsServer.cs
index 4276bbe3e..addd2c100 100644
--- a/crypto/test/src/tls/test/MockPskTlsServer.cs
+++ b/crypto/test/src/tls/test/MockPskTlsServer.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -13,7 +12,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : PskTlsServer
     {
         internal MockPskTlsServer()
-            : base(new BcTlsCrypto(new SecureRandom()), new MyIdentityManager())
+            : base(new BcTlsCrypto(), new MyIdentityManager())
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockRawKeysTlsClient.cs b/crypto/test/src/tls/test/MockRawKeysTlsClient.cs
index 594c4c94e..519c25ff2 100644
--- a/crypto/test/src/tls/test/MockRawKeysTlsClient.cs
+++ b/crypto/test/src/tls/test/MockRawKeysTlsClient.cs
@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 using Org.BouncyCastle.X509;
@@ -23,7 +22,7 @@ namespace Org.BouncyCastle.Tls.Tests
 
         internal MockRawKeysTlsClient(short serverCertType, short clientCertType, short[] offerServerCertTypes,
             short[] offerClientCertTypes, Ed25519PrivateKeyParameters privateKey, ProtocolVersion tlsVersion)
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
             m_serverCertType = serverCertType;
             m_clientCertType = clientCertType;
diff --git a/crypto/test/src/tls/test/MockRawKeysTlsServer.cs b/crypto/test/src/tls/test/MockRawKeysTlsServer.cs
index e136c6571..e786f376d 100644
--- a/crypto/test/src/tls/test/MockRawKeysTlsServer.cs
+++ b/crypto/test/src/tls/test/MockRawKeysTlsServer.cs
@@ -4,7 +4,6 @@ using System.Collections.Generic;
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 using Org.BouncyCastle.X509;
@@ -25,7 +24,7 @@ namespace Org.BouncyCastle.Tls.Tests
 
         internal MockRawKeysTlsServer(short serverCertType, short clientCertType, short[] allowedClientCertTypes,
             Ed25519PrivateKeyParameters privateKey, ProtocolVersion tlsVersion)
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
             m_serverCertType = serverCertType;
             m_clientCertType = clientCertType;
diff --git a/crypto/test/src/tls/test/MockSrpTlsClient.cs b/crypto/test/src/tls/test/MockSrpTlsClient.cs
index 5c91124a0..3fa510bc9 100644
--- a/crypto/test/src/tls/test/MockSrpTlsClient.cs
+++ b/crypto/test/src/tls/test/MockSrpTlsClient.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -17,7 +16,7 @@ namespace Org.BouncyCastle.Tls.Tests
         internal TlsSession m_session;
 
         internal MockSrpTlsClient(TlsSession session, TlsSrpIdentity srpIdentity)
-            : base(new BcTlsCrypto(new SecureRandom()), srpIdentity)
+            : base(new BcTlsCrypto(), srpIdentity)
         {
             this.m_session = session;
         }
diff --git a/crypto/test/src/tls/test/MockSrpTlsServer.cs b/crypto/test/src/tls/test/MockSrpTlsServer.cs
index 988be50d8..287b32219 100644
--- a/crypto/test/src/tls/test/MockSrpTlsServer.cs
+++ b/crypto/test/src/tls/test/MockSrpTlsServer.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Crypto.Agreement.Srp;
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 using Org.BouncyCastle.Utilities;
@@ -25,7 +24,7 @@ namespace Org.BouncyCastle.Tls.Tests
         internal static readonly byte[] TEST_SEED_KEY = Strings.ToUtf8ByteArray("seed_key");
 
         internal MockSrpTlsServer()
-            : base(new BcTlsCrypto(new SecureRandom()), new MyIdentityManager(new BcTlsCrypto(new SecureRandom())))
+            : base(new BcTlsCrypto(), new MyIdentityManager(new BcTlsCrypto()))
         {
         }
 
diff --git a/crypto/test/src/tls/test/MockTlsClient.cs b/crypto/test/src/tls/test/MockTlsClient.cs
index 731504757..c03a7fd1d 100644
--- a/crypto/test/src/tls/test/MockTlsClient.cs
+++ b/crypto/test/src/tls/test/MockTlsClient.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 
@@ -17,7 +16,7 @@ namespace Org.BouncyCastle.Tls.Tests
         internal TlsSession m_session;
 
         internal MockTlsClient(TlsSession session)
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
             this.m_session = session;
         }
diff --git a/crypto/test/src/tls/test/MockTlsServer.cs b/crypto/test/src/tls/test/MockTlsServer.cs
index c4aa2c74d..aee9ed8ee 100644
--- a/crypto/test/src/tls/test/MockTlsServer.cs
+++ b/crypto/test/src/tls/test/MockTlsServer.cs
@@ -5,7 +5,6 @@ using System.IO;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Encoders;
 
 namespace Org.BouncyCastle.Tls.Tests
@@ -14,7 +13,7 @@ namespace Org.BouncyCastle.Tls.Tests
         : DefaultTlsServer
     {
         internal MockTlsServer()
-            : base(new BcTlsCrypto(new SecureRandom()))
+            : base(new BcTlsCrypto())
         {
         }
 
diff --git a/crypto/test/src/tls/test/PrfTest.cs b/crypto/test/src/tls/test/PrfTest.cs
index de00166ed..b13bbf0d2 100644
--- a/crypto/test/src/tls/test/PrfTest.cs
+++ b/crypto/test/src/tls/test/PrfTest.cs
@@ -1,8 +1,5 @@
-using System;
+using NUnit.Framework;
 
-using NUnit.Framework;
-
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 using Org.BouncyCastle.Utilities;
@@ -26,7 +23,7 @@ namespace Org.BouncyCastle.Tls.Tests
 
             byte[] msSeed = Arrays.Concatenate(clientHello_random, serverHello_random);
 
-            BcTlsCrypto crypto = new BcTlsCrypto(new SecureRandom());
+            BcTlsCrypto crypto = new BcTlsCrypto();
             TlsSecret masterSecret = new BcTlsSecret(crypto, pre_master_secret)
                 .DeriveUsingPrf(PrfAlgorithm.tls_prf_legacy, ExporterLabel.master_secret, msSeed, master_secret.Length);
 
@@ -53,7 +50,7 @@ namespace Org.BouncyCastle.Tls.Tests
 
             byte[] msSeed = Arrays.Concatenate(clientHello_random, serverHello_random);
 
-            BcTlsCrypto crypto = new BcTlsCrypto(new SecureRandom());
+            BcTlsCrypto crypto = new BcTlsCrypto();
             TlsSecret masterSecret = new BcTlsSecret(crypto, pre_master_secret)
                 .DeriveUsingPrf(PrfAlgorithm.tls_prf_sha256, ExporterLabel.master_secret, msSeed, master_secret.Length);
 
@@ -80,7 +77,7 @@ namespace Org.BouncyCastle.Tls.Tests
 
             byte[] msSeed = Arrays.Concatenate(clientHello_random, serverHello_random);
 
-            BcTlsCrypto crypto = new BcTlsCrypto(new SecureRandom());
+            BcTlsCrypto crypto = new BcTlsCrypto();
             TlsSecret masterSecret = new BcTlsSecret(crypto, pre_master_secret)
                 .DeriveUsingPrf(PrfAlgorithm.tls_prf_sha384, ExporterLabel.master_secret, msSeed, master_secret.Length);
 
diff --git a/crypto/test/src/tls/test/TlsTestSuite.cs b/crypto/test/src/tls/test/TlsTestSuite.cs
index 5139a3e6b..c6335b969 100644
--- a/crypto/test/src/tls/test/TlsTestSuite.cs
+++ b/crypto/test/src/tls/test/TlsTestSuite.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
 
 using NUnit.Framework;
 
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Tls.Crypto.Impl.BC;
 
@@ -11,7 +10,7 @@ namespace Org.BouncyCastle.Tls.Tests
 {
     public class TlsTestSuite
     {
-        internal static TlsCrypto BC_CRYPTO = new BcTlsCrypto(new SecureRandom());
+        internal static TlsCrypto BC_CRYPTO = new BcTlsCrypto();
 
         internal static TlsCrypto GetCrypto(TlsTestConfig config)
         {