Skip to content

Commit 9ab06ac

Browse files
committed
Abort connection if we are about to send the same CH
1 parent 561fead commit 9ab06ac

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/ssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14209,6 +14209,10 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
1420914209
#if defined(WOLFSSL_TLS13) && defined(HAVE_CERTIFICATE_STATUS_REQUEST)
1421014210
ssl->response_idx = 0;
1421114211
#endif
14212+
#endif
14213+
14214+
#ifdef WOLFSSL_TLS13
14215+
ssl->initChHash = 0;
1421214216
#endif
1421314217
return WOLFSSL_SUCCESS;
1421414218
}

src/tls13.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,22 @@ int SendTls13ClientHello(WOLFSSL* ssl)
47394739
if (ret != 0)
47404740
return ret;
47414741

4742+
if (ssl->hsHashes == NULL)
4743+
return BAD_FUNC_ARG;
4744+
/* https://datatracker.ietf.org/doc/html/rfc8446#section-4.1.4
4745+
* Clients MUST abort the handshake with an
4746+
* "illegal_parameter" alert if the HelloRetryRequest would not result
4747+
* in any change in the ClientHello.
4748+
*/
4749+
if (ssl->options.connectState != HELLO_AGAIN)
4750+
ssl->initChHash = HashObject(args->output, args->idx, &ret);
4751+
else if (ssl->initChHash == HashObject(args->output, args->idx, &ret)) {
4752+
SendAlert(ssl, alert_fatal, illegal_parameter);
4753+
ret = DUPLICATE_MSG_E;
4754+
}
4755+
if (ret != 0)
4756+
return ret;
4757+
47424758
ssl->options.clientState = CLIENT_HELLO_COMPLETE;
47434759

47444760
#if defined(WOLFSSL_CALLBACKS) || defined(OPENSSL_EXTRA)

wolfcrypt/src/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ WC_MISC_STATIC WC_INLINE w64wrapper w64Mul(word32 a, word32 b)
12811281
#endif /* WOLFSSL_W64_WRAPPER */
12821282

12831283
#if defined(HAVE_SESSION_TICKET) || !defined(NO_CERTS) || \
1284-
!defined(NO_SESSION_CACHE)
1284+
!defined(NO_SESSION_CACHE) || defined(WOLFSSL_TLS13)
12851285
/* Make a word from the front of random hash */
12861286
WC_MISC_STATIC WC_INLINE word32 MakeWordFromHash(const byte* hashID)
12871287
{

wolfssl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5858,6 +5858,7 @@ struct WOLFSSL {
58585858
#ifdef WOLFSSL_TLS13
58595859
byte clientSecret[SECRET_LEN];
58605860
byte serverSecret[SECRET_LEN];
5861+
word32 initChHash; /* initial ClientHello hash */
58615862
#endif
58625863
HS_Hashes* hsHashes;
58635864
#if defined(WOLFSSL_TLS13) && defined(HAVE_ECH)

0 commit comments

Comments
 (0)