Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static int FindExtByType(WolfSSL_ConstVector* ret, word16 extType,
#if defined(WOLFSSL_DTLS_NO_HVR_ON_RESUME)
#ifdef HAVE_SESSION_TICKET
static int TlsTicketIsValid(const WOLFSSL* ssl, WolfSSL_ConstVector exts,
int* resume)
int* resume, int* haveTicket)
{
WolfSSL_ConstVector tlsxSessionTicket;
byte tempTicket[SESSION_TICKET_LEN];
Expand All @@ -440,9 +440,16 @@ static int TlsTicketIsValid(const WOLFSSL* ssl, WolfSSL_ConstVector exts,
&tlsxFound);
if (ret != 0)
return ret;
if (tlsxSessionTicket.size == 0)
if (tlsxSessionTicket.size == 0) {
/* The server answers a blank ticket with a new one, not resumption */
if (tlsxFound && ssl->ctx->ticketEncCb != NULL &&
!ssl->options.noTicketTls12)
*haveTicket = TRUE;
return 0;
if (tlsxSessionTicket.size > SESSION_TICKET_LEN)
}
*haveTicket = TRUE;
Comment thread
Frauschi marked this conversation as resolved.
Resolved
if (ssl->options.noTicketTls12 ||
tlsxSessionTicket.size > SESSION_TICKET_LEN)
return 0;
XMEMCPY(tempTicket, tlsxSessionTicket.elements, tlsxSessionTicket.size);
ret = DoDecryptTicket(ssl, tempTicket, (word32)tlsxSessionTicket.size, &it);
Expand Down Expand Up @@ -522,12 +529,14 @@ static int TlsResumptionIsValid(const WOLFSSL* ssl, WolfSSL_CH* ch,
int* resume)
{
int ret;

#ifdef HAVE_SESSION_TICKET
ret = TlsTicketIsValid(ssl, ch->extension, resume);
int haveTicket = FALSE;

ret = TlsTicketIsValid(ssl, ch->extension, resume, &haveTicket);
if (ret != 0)
return ret;
if (*resume)
/* No resumption by the session ID that came with a ticket */
if (*resume || haveTicket)
return 0;
#endif /* HAVE_SESSION_TICKET */
ret = TlsSessionIdIsValid(ssl, ch->sessionId, resume);
Expand Down
30 changes: 26 additions & 4 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -22543,9 +22543,8 @@ int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
* "certificate" or "server_key_exchange" are received then we
* are doing a full handshake */

/* If the server included a session id then we
* treat this as a fatal error, since the server said it was
* doing resumption, but did not. */
/* A server that echoed the client's session id said it was
* resuming, so a full handshake after it is a fatal error. */

/* https://www.rfc-editor.org/rfc/rfc5077.html#section-3.4
* Alternatively, the client MAY include an empty Session ID
Expand All @@ -22555,7 +22554,12 @@ int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
* messages.
*/
#ifndef WOLFSSL_WPAS
if (ssl->arrays->sessionIDSz != 0) {
if (ssl->arrays->sessionIDSz != 0
#ifdef HAVE_SESSION_TICKET
/* A ticket goes out with an empty session ID */
&& ssl->session->ticketLen == 0
#endif
) {
/* Fatal error. Only try to send an alert. RFC 5246 does not
* allow for reverting back to a full handshake after the
* server has indicated the intention to do a resumption. */
Expand All @@ -22571,6 +22575,24 @@ int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
ssl->options.resuming = 0;
/* No longer resuming, reset peer authentication state. */
ssl->options.peerAuthGood = 0;
#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_CLIENT)
/* The declined ticket does not belong to the new session */
if (ssl->session->ticketLen > 0) {
if (!HaveUniqueSessionObj(ssl))
return MEMORY_ERROR;
ForceZero(ssl->session->ticket, ssl->session->ticketLen);
if (ssl->session->ticketLenAlloc > 0) {
XFREE(ssl->session->ticket, ssl->session->heap,
DYNAMIC_TYPE_SESSION_TICK);
ssl->session->ticket = ssl->session->staticTicket;
ssl->session->ticketLenAlloc = 0;
}
ssl->session->ticketLen = 0;
/* The ID made up for the ticket goes with it */
ForceZero(ssl->session->altSessionID, ID_LEN);
ssl->session->haveAltSessionID = 0;
}
#endif
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -7093,18 +7093,23 @@ static int TLSX_SessionTicket_Parse(WOLFSSL* ssl, const byte* input,
#ifndef NO_WOLFSSL_SERVER
else {
/* server side */
if (ssl->ctx->ticketEncCb == NULL) {
WOLFSSL_MSG("Client sent session ticket, server has no callback");
return 0;
}

#ifdef HAVE_SECURE_RENEGOTIATION
if (IsSCR(ssl)) {
WOLFSSL_MSG("Client sent session ticket during SCR. Ignoring.");
return 0;
}
#endif

/* No stateful resumption with the session ID that came with a ticket
* (RFC 5077 Section 3.4) */
if (length > 0 && !IsAtLeastTLSv1_3(ssl->version))
ssl->options.resuming = 0;

if (ssl->ctx->ticketEncCb == NULL) {
WOLFSSL_MSG("Client sent session ticket, server has no callback");
return 0;
}

if (length > SESSION_TICKET_LEN) {
ret = BAD_TICKET_MSG_SZ;
WOLFSSL_ERROR_VERBOSE(ret);
Expand Down
Loading
Loading