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
35 changes: 28 additions & 7 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31478,16 +31478,36 @@ static void MakePSKPreMasterSecret(Arrays* arrays, byte use_psk_key)
if (ssl->options.resuming && ssl->session->ticketLen > 0) {
SessionTicket* ticket;

ticket = TLSX_SessionTicket_Create(0, ssl->session->ticket,
#if !defined(WOLFSSL_NO_TICKET_EXPIRE) && !defined(NO_ASN_TIME)
/* RFC 5077 Section 3.3 / RFC 8446 Section 4.6.1: a client SHOULD
* NOT use a ticket whose lifetime has expired. If the stored
* session has aged past its timeout the server would just reject
* the resumption, so suppress the ticket here and fall back to a
* full handshake (avoids leaking a stale ticket and saves a
* round-trip). Expiry is measured against ssl->session->timeout
* (the session's own lifetime) so this stays consistent with
* wolfSSL_SetSession(), which gates resumption on the same field;
* keying off ssl->timeout instead could contradict a decision
* SetSession() already made when the two values differ. */
if (LowResTimer() >=
(ssl->session->bornOn + ssl->session->timeout)) {
WOLFSSL_MSG("Stored session ticket expired; full handshake");
ssl->options.resuming = 0;
}
Comment on lines +31492 to +31496
else
#endif
{
ticket = TLSX_SessionTicket_Create(0, ssl->session->ticket,
ssl->session->ticketLen, ssl->heap);
if (ticket == NULL) return MEMORY_E;
if (ticket == NULL) return MEMORY_E;

ret = TLSX_UseSessionTicket(&ssl->extensions, ticket, ssl->heap);
if (ret != WOLFSSL_SUCCESS) {
TLSX_SessionTicket_Free(ticket, ssl->heap);
return ret;
ret = TLSX_UseSessionTicket(&ssl->extensions, ticket,
ssl->heap);
if (ret != WOLFSSL_SUCCESS) {
TLSX_SessionTicket_Free(ticket, ssl->heap);
return ret;
}
}

idSz = 0;
}
#endif /* HAVE_SESSION_TICKET */
Expand Down Expand Up @@ -35695,6 +35715,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
{
switch (err) {
case WC_NO_ERR_TRACE(BUFFER_ERROR):
case WC_NO_ERR_TRACE(BUFFER_E):
return decode_error;
case WC_NO_ERR_TRACE(EXT_NOT_ALLOWED):
case WC_NO_ERR_TRACE(PEER_KEY_ERROR):
Expand Down
11 changes: 11 additions & 0 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6021,6 +6021,17 @@ int wolfSSL_export_keying_material(WOLFSSL *ssl,
return WOLFSSL_FAILURE;
}

/* RFC 8446 Section 7.5 / RFC 5705: keying-material exporters derive from
* exporter_master_secret, which exists only after the handshake is
* complete. Refuse the export until the handshake has completed so that
* a premature call cannot derive material from an uninitialised
* exporterSecret buffer. */
if (ssl->options.handShakeDone == 0 ||
ssl->options.handShakeState != HANDSHAKE_DONE) {
WOLFSSL_MSG("Handshake not complete; refusing keying-material export");
return WOLFSSL_FAILURE;
}
Comment on lines +6029 to +6033

/* Sanity check contextLen to prevent integer overflow when cast to word32
* and to ensure it fits in the 2-byte length encoding (max 65535). */
if (use_context && contextLen > WOLFSSL_MAX_16BIT) {
Expand Down
Loading