diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-08-28 09:55:29 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-08-28 09:55:29 +0700 |
commit | 5b9077eee3b746a4881b75f2f1bbbfa5b7a17378 (patch) | |
tree | 10b9d02d7f019d166d8a1fbd7559baf4bcc82004 | |
parent | Formatting (diff) | |
download | BouncyCastle.NET-ed25519-5b9077eee3b746a4881b75f2f1bbbfa5b7a17378.tar.xz |
Minor improvements to MaxFragmentLength handling
-rw-r--r-- | crypto/src/crypto/tls/AbstractTlsServer.cs | 6 | ||||
-rw-r--r-- | crypto/src/crypto/tls/TlsExtensionsUtilities.cs | 10 |
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> |