diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-06 15:42:14 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-06 15:42:14 +0700 |
commit | b68d839bdf21d0392125f52f0fc536e12132e345 (patch) | |
tree | e789d4ef4236bfceae272fe396c62afd369090f0 /crypto/src/tls/DtlsServerProtocol.cs | |
parent | Nerdbank.GitVersioning 3.6.133 (diff) | |
download | BouncyCastle.NET-ed25519-b68d839bdf21d0392125f52f0fc536e12132e345.tar.xz |
DTLS: Use SecurityParameters.m_resumedSession for resumption tracking
Diffstat (limited to '')
-rw-r--r-- | crypto/src/tls/DtlsServerProtocol.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crypto/src/tls/DtlsServerProtocol.cs b/crypto/src/tls/DtlsServerProtocol.cs index a4f8f4bc5..82c6ff290 100644 --- a/crypto/src/tls/DtlsServerProtocol.cs +++ b/crypto/src/tls/DtlsServerProtocol.cs @@ -129,6 +129,7 @@ namespace Org.BouncyCastle.Tls state.sessionMasterSecret = null; } + securityParameters.m_resumedSession = false; securityParameters.m_sessionID = state.tlsSession.SessionID; state.server.NotifySession(state.tlsSession); @@ -447,6 +448,8 @@ namespace Org.BouncyCastle.Tls } } + bool resumedSession = securityParameters.IsResumedSession; + { int cipherSuite = ValidateSelectedCipherSuite(state.server.GetSelectedCipherSuite(), AlertDescription.internal_error); @@ -526,7 +529,7 @@ namespace Org.BouncyCastle.Tls { throw new TlsFatalAlert(AlertDescription.handshake_failure); } - else if (state.resumedSession && !state.server.AllowLegacyResumption()) + else if (resumedSession && !state.server.AllowLegacyResumption()) { throw new TlsFatalAlert(AlertDescription.internal_error); } @@ -578,7 +581,7 @@ namespace Org.BouncyCastle.Tls securityParameters.m_encryptThenMac = TlsExtensionsUtilities.HasEncryptThenMacExtension( state.serverExtensions); - securityParameters.m_maxFragmentLength = EvaluateMaxFragmentLengthExtension(state.resumedSession, + securityParameters.m_maxFragmentLength = EvaluateMaxFragmentLengthExtension(resumedSession, state.clientExtensions, state.serverExtensions, AlertDescription.internal_error); securityParameters.m_truncatedHmac = TlsExtensionsUtilities.HasTruncatedHmacExtension(state.serverExtensions); @@ -587,7 +590,7 @@ namespace Org.BouncyCastle.Tls * TODO It's surprising that there's no provision to allow a 'fresh' CertificateStatus to be sent in * a session resumption handshake. */ - if (!state.resumedSession) + if (!resumedSession) { // TODO[tls13] See RFC 8446 4.4.2.1 if (TlsUtilities.HasExpectedEmptyExtensionData(state.serverExtensions, @@ -600,11 +603,10 @@ namespace Org.BouncyCastle.Tls { securityParameters.m_statusRequestVersion = 1; } - } - state.expectSessionTicket = !state.resumedSession - && TlsUtilities.HasExpectedEmptyExtensionData(state.serverExtensions, ExtensionType.session_ticket, - AlertDescription.internal_error); + state.expectSessionTicket = TlsUtilities.HasExpectedEmptyExtensionData(state.serverExtensions, + ExtensionType.session_ticket, AlertDescription.internal_error); + } } ApplyMaxFragmentLengthExtension(recordLayer, securityParameters.MaxFragmentLength); @@ -879,7 +881,6 @@ namespace Org.BouncyCastle.Tls internal IDictionary<int, byte[]> clientExtensions = null; internal IDictionary<int, byte[]> serverExtensions = null; internal bool offeredExtendedMasterSecret = false; - internal bool resumedSession = false; internal bool expectSessionTicket = false; internal TlsKeyExchange keyExchange = null; internal TlsCredentials serverCredentials = null; |