summary refs log tree commit diff
path: root/crypto/src/tls/TlsUtilities.cs
diff options
context:
space:
mode:
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)
         {