summary refs log tree commit diff
path: root/crypto/src/tls/TlsUtilities.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-07-14 23:45:24 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-07-14 23:45:24 +0700
commit7abd4af6873142092f5f38f93888a73c0a1bd17a (patch)
tree6039a22223a82fa0ad7194433f753910664a5afd /crypto/src/tls/TlsUtilities.cs
parentRefactoring around TlsEncryptor (diff)
downloadBouncyCastle.NET-ed25519-7abd4af6873142092f5f38f93888a73c0a1bd17a.tar.xz
Avoid redundant CheckUsageInRole calls
Diffstat (limited to 'crypto/src/tls/TlsUtilities.cs')
-rw-r--r--crypto/src/tls/TlsUtilities.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs
index 98d834b6d..4cec13bae 100644
--- a/crypto/src/tls/TlsUtilities.cs
+++ b/crypto/src/tls/TlsUtilities.cs
@@ -5327,6 +5327,18 @@ namespace Org.BouncyCastle.Tls
             }
         }
 
+        /// <summary>Generate a pre_master_secret and send it encrypted to the server.</summary>
+        /// <exception cref="IOException"/>
+        public static TlsSecret GenerateEncryptedPreMasterSecret(TlsContext context, TlsEncryptor encryptor,
+            Stream output)
+        {
+            ProtocolVersion version = context.RsaPreMasterSecretVersion;
+            TlsSecret preMasterSecret = context.Crypto.GenerateRsaPreMasterSecret(version);
+            byte[] encryptedPreMasterSecret = preMasterSecret.Encrypt(encryptor);
+            WriteEncryptedPms(context, encryptedPreMasterSecret, output);
+            return preMasterSecret;
+        }
+
 #if !PORTABLE || DOTNET
         public static bool IsTimeout(SocketException e)
         {