summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-08-28 09:55:29 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-08-28 09:55:29 +0700
commit5b9077eee3b746a4881b75f2f1bbbfa5b7a17378 (patch)
tree10b9d02d7f019d166d8a1fbd7559baf4bcc82004 /crypto/src
parentFormatting (diff)
downloadBouncyCastle.NET-ed25519-5b9077eee3b746a4881b75f2f1bbbfa5b7a17378.tar.xz
Minor improvements to MaxFragmentLength handling
Diffstat (limited to 'crypto/src')
-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>