Skip to content

Commit 04bd3a7

Browse files
skip ECH decrypt when ECH was rejected
1 parent e77a5f2 commit 04bd3a7

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16909,7 +16909,7 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1690916909

1691016910
domainName = (char*)ssl->buffers.domainName.buffer;
1691116911
#if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_ECH)
16912-
/* RFC 9849 s6.1.7: ECH was offered but rejected by the server..
16912+
/* RFC 9849 s6.1.7: ECH offered but rejected by the server...
1691316913
* verify cert is valid for ECHConfig.public_name */
1691416914
if (ssl->options.side == WOLFSSL_CLIENT_END &&
1691516915
ssl->echConfigs != NULL &&

src/tls.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14082,7 +14082,7 @@ static int TLSX_ECH_ExpandOuterExtensions(WOLFSSL* ssl, WOLFSSL_ECH* ech,
1408214082
int foundEchOuter = 0;
1408314083
word16 numOuterRefs = 0;
1408414084
const byte* outerRefTypes = NULL;
14085-
word32 extraSize;
14085+
word32 extraSize = 0;
1408614086
byte* newInnerCh = NULL;
1408714087
byte* newInnerChRef;
1408814088
word32 newInnerChLen;
@@ -14408,6 +14408,14 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
1440814408
return BAD_FUNC_ARG;
1440914409
ech = (WOLFSSL_ECH*)echX->data;
1441014410

14411+
/* if the first ECH was rejected or CH1 did not have ECH then there is
14412+
* no need to decrypt this one */
14413+
if (!ssl->options.echAccepted && ssl->options.serverState ==
14414+
SERVER_HELLO_RETRY_REQUEST_COMPLETE) {
14415+
ech->state = ECH_WRITE_RETRY_CONFIGS;
14416+
return 0;
14417+
}
14418+
1441114419
/* read the ech parameters before the payload */
1441214420
ech->type = *readBuf_p;
1441314421
readBuf_p++;

src/tls13.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5778,7 +5778,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
57785778
}
57795779
else {
57805780
#if defined(HAVE_ECH)
5781-
/* do not resume when outerHandshake will be negotiated */
5781+
/* do not resume when outerHandshake will be negotiated */
57825782
if (ssl->echConfigs != NULL && !ssl->options.disableECH &&
57835783
!ssl->options.echAccepted) {
57845784
WOLFSSL_MSG("ECH rejected but server negotiated PSK");

tests/api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15141,9 +15141,9 @@ static int test_wolfSSL_Tls13_ECH_retry_configs_auth_fail(void)
1514115141
EXPECT_DECLS;
1514215142

1514315143
ExpectIntEQ(test_wolfSSL_Tls13_ECH_retry_configs_auth_fail_ex(0),
15144-
WOLFSSL_SUCCESS);
15144+
TEST_SUCCESS);
1514515145
ExpectIntEQ(test_wolfSSL_Tls13_ECH_retry_configs_auth_fail_ex(1),
15146-
WOLFSSL_SUCCESS);
15146+
TEST_SUCCESS);
1514715147

1514815148
return EXPECT_RESULT();
1514915149
}

0 commit comments

Comments
 (0)