From a50f679a981b253f36af5414285081f2c8bf9db3 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 12 Apr 2024 23:11:20 +0700 Subject: Refactoring in Tls --- crypto/src/tls/DtlsClientProtocol.cs | 7 +++---- crypto/src/tls/DtlsServerProtocol.cs | 7 +++---- crypto/src/tls/TlsProtocol.cs | 10 ++-------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/crypto/src/tls/DtlsClientProtocol.cs b/crypto/src/tls/DtlsClientProtocol.cs index 2b132f564..1328a940e 100644 --- a/crypto/src/tls/DtlsClientProtocol.cs +++ b/crypto/src/tls/DtlsClientProtocol.cs @@ -612,11 +612,10 @@ namespace Org.BouncyCastle.Tls if (null == sessionVersion || !sessionVersion.IsDtls) return false; - bool isEms = sessionParameters.IsExtendedMasterSecret; - if (!TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) + if (!sessionParameters.IsExtendedMasterSecret && + !TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) { - if (!isEms) - return false; + return false; } TlsCrypto crypto = state.clientContext.Crypto; diff --git a/crypto/src/tls/DtlsServerProtocol.cs b/crypto/src/tls/DtlsServerProtocol.cs index a3d04f01e..fcdc94cd6 100644 --- a/crypto/src/tls/DtlsServerProtocol.cs +++ b/crypto/src/tls/DtlsServerProtocol.cs @@ -740,11 +740,10 @@ namespace Org.BouncyCastle.Tls if (null == sessionVersion || !sessionVersion.IsDtls) return false; - bool isEms = sessionParameters.IsExtendedMasterSecret; - if (!TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) + if (!sessionParameters.IsExtendedMasterSecret && + !TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) { - if (!isEms) - return false; + return false; } TlsCrypto crypto = state.serverContext.Crypto; diff --git a/crypto/src/tls/TlsProtocol.cs b/crypto/src/tls/TlsProtocol.cs index 773412973..2ee5982cb 100644 --- a/crypto/src/tls/TlsProtocol.cs +++ b/crypto/src/tls/TlsProtocol.cs @@ -1458,15 +1458,9 @@ namespace Org.BouncyCastle.Tls if (null == sessionVersion || !sessionVersion.IsTls) return false; - bool isEms = sessionParameters.IsExtendedMasterSecret; - if (sessionVersion.IsSsl) + if (!TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) { - if (isEms) - return false; - } - else if (!TlsUtilities.IsExtendedMasterSecretOptional(sessionVersion)) - { - if (!isEms) + if (sessionParameters.IsExtendedMasterSecret == sessionVersion.IsSsl) return false; } -- cgit 1.4.1