Skip to content

Commit 45d814e

Browse files
authored
Merge pull request #9884 from Frauschi/f-204
Prevent session ticket nonce overflow
2 parents 313d27d + 1d88649 commit 45d814e

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/internal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27549,6 +27549,9 @@ const char* wolfSSL_ERR_reason_error_string(unsigned long e)
2754927549

2755027550
case WOLFSSL_EVP_R_PRIVATE_KEY_DECODE_ERROR:
2755127551
return "Private key decode error (EVP)";
27552+
27553+
case SESSION_TICKET_NONCE_OVERFLOW:
27554+
return "Session ticket nonce overflow";
2755227555
}
2755327556

2755427557
return "unknown error number";

src/tls13.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12175,6 +12175,13 @@ static int SendTls13NewSessionTicket(WOLFSSL* ssl)
1217512175
if (ssl->error != WC_NO_ERR_TRACE(WC_PENDING_E))
1217612176
#endif
1217712177
{
12178+
if (ssl->session->ticketNonce.data[0] == 255) {
12179+
/* RFC8446 Section 4.6.1: Each ticket must have a unique nonce
12180+
* value. As the nonce is only a single byte, we have to prevent
12181+
* the overflow and abort. */
12182+
return SESSION_TICKET_NONCE_OVERFLOW;
12183+
}
12184+
else
1217812185
ssl->session->ticketNonce.data[0]++;
1217912186
}
1218012187

wolfssl/error-ssl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ enum wolfSSL_ErrorCodes {
238238
CRYPTO_POLICY_FORBIDDEN = -516, /* operation forbidden by system
239239
* crypto-policy */
240240

241-
WOLFSSL_LAST_E = -516
241+
SESSION_TICKET_NONCE_OVERFLOW = -517, /* Session ticket nonce overflow */
242+
243+
WOLFSSL_LAST_E = -517
242244

243245
/* codes -1000 to -1999 are reserved for wolfCrypt. */
244246
};

0 commit comments

Comments
 (0)