summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/tls/AbstractTlsServer.cs6
-rw-r--r--crypto/src/crypto/tls/TlsExtensionsUtilities.cs10
2 files changed, 5 insertions, 11 deletions
diff --git a/crypto/src/crypto/tls/AbstractTlsServer.cs b/crypto/src/crypto/tls/AbstractTlsServer.cs
index 47542c796..08bb289cf 100644
--- a/crypto/src/crypto/tls/AbstractTlsServer.cs
+++ b/crypto/src/crypto/tls/AbstractTlsServer.cs
@@ -233,9 +233,11 @@ namespace Org.BouncyCastle.Crypto.Tls
                 }
             }
 
-            if (this.mMaxFragmentLengthOffered >= 0)
+            if (this.mMaxFragmentLengthOffered >= 0
+                && TlsUtilities.IsValidUint8(mMaxFragmentLengthOffered)
+                && MaxFragmentLength.IsValid((byte)mMaxFragmentLengthOffered))
             {
-                TlsExtensionsUtilities.AddMaxFragmentLengthExtension(CheckServerExtensions(), (byte)this.mMaxFragmentLengthOffered);
+                TlsExtensionsUtilities.AddMaxFragmentLengthExtension(CheckServerExtensions(), (byte)mMaxFragmentLengthOffered);
             }
 
             if (this.mTruncatedHMacOffered && AllowTruncatedHMac)
diff --git a/crypto/src/crypto/tls/TlsExtensionsUtilities.cs b/crypto/src/crypto/tls/TlsExtensionsUtilities.cs
index 696b86db2..46851b66c 100644
--- a/crypto/src/crypto/tls/TlsExtensionsUtilities.cs
+++ b/crypto/src/crypto/tls/TlsExtensionsUtilities.cs
@@ -132,9 +132,6 @@ namespace Org.BouncyCastle.Crypto.Tls
         /// <exception cref="IOException"></exception>
         public static byte[] CreateMaxFragmentLengthExtension(byte maxFragmentLength)
         {
-            if (!MaxFragmentLength.IsValid(maxFragmentLength))
-                throw new TlsFatalAlert(AlertDescription.internal_error);
-
             return new byte[]{ maxFragmentLength };
         }
 
@@ -219,12 +216,7 @@ namespace Org.BouncyCastle.Crypto.Tls
             if (extensionData.Length != 1)
                 throw new TlsFatalAlert(AlertDescription.decode_error);
 
-            byte maxFragmentLength = extensionData[0];
-
-            if (!MaxFragmentLength.IsValid(maxFragmentLength))
-                throw new TlsFatalAlert(AlertDescription.illegal_parameter);
-
-            return maxFragmentLength;
+            return extensionData[0];
         }
 
         /// <exception cref="IOException"></exception>