summary refs log tree commit diff
path: root/crypto/src/tls/TlsUtilities.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-06 17:15:29 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-06 17:15:29 +0700
commit806f7224c9c1f6708358115f0bb8a3fcfd0a0663 (patch)
treed705b3a45e0e86a0345430286d1a458a081c1579 /crypto/src/tls/TlsUtilities.cs
parentDTLS: Use SecurityParameters.m_resumedSession for resumption tracking (diff)
downloadBouncyCastle.NET-ed25519-806f7224c9c1f6708358115f0bb8a3fcfd0a0663.tar.xz
(D)TLS: Refactoring around the MFL extension
Diffstat (limited to 'crypto/src/tls/TlsUtilities.cs')
-rw-r--r--crypto/src/tls/TlsUtilities.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs
index 2f95e71ab..a9c7629d6 100644
--- a/crypto/src/tls/TlsUtilities.cs
+++ b/crypto/src/tls/TlsUtilities.cs
@@ -5731,6 +5731,23 @@ namespace Org.BouncyCastle.Tls
             return v;
         }
 
+        /// <exception cref="IOException"/>
+        internal static short ProcessMaxFragmentLengthExtension(IDictionary<int, byte[]> clientExtensions,
+            IDictionary<int, byte[]> serverExtensions, short alertDescription)
+        {
+            short maxFragmentLength = TlsExtensionsUtilities.GetMaxFragmentLengthExtension(serverExtensions);
+            if (maxFragmentLength >= 0)
+            {
+                if (!MaxFragmentLength.IsValid(maxFragmentLength) ||
+                    (clientExtensions != null &&
+                        maxFragmentLength != TlsExtensionsUtilities.GetMaxFragmentLengthExtension(clientExtensions)))
+                {
+                    throw new TlsFatalAlert(alertDescription);
+                }
+            }
+            return maxFragmentLength;
+        }
+
         // TODO[api] Not needed once GetHandshakeResendTimeMillis() has been added to TlsPeer
         internal static int GetHandshakeResendTimeMillis(TlsPeer tlsPeer)
         {