Skip to content

Commit fa6f294

Browse files
skip ECH decrypt when ECH was rejected
1 parent 6b0dc35 commit fa6f294

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/internal.c

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

1687416874
domainName = (char*)ssl->buffers.domainName.buffer;
1687516875
#if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_ECH)
16876-
/* RFC 9849 s6.1.7: ECH was offered but rejected by the server..
16876+
/* RFC 9849 s6.1.7: ECH offered but rejected by the server...
1687716877
* verify cert is valid for ECHConfig.public_name */
1687816878
if (ssl->options.side == WOLFSSL_CLIENT_END &&
1687916879
ssl->echConfigs != NULL &&

src/tls.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13999,7 +13999,7 @@ static int TLSX_ECH_ExpandOuterExtensions(WOLFSSL* ssl, WOLFSSL_ECH* ech,
1399913999
int foundEchOuter = 0;
1400014000
word16 numOuterRefs = 0;
1400114001
const byte* outerRefTypes = NULL;
14002-
word32 extraSize;
14002+
word32 extraSize = 0;
1400314003
byte* newInnerCh = NULL;
1400414004
byte* newInnerChRef;
1400514005
word32 newInnerChLen;
@@ -14325,6 +14325,14 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
1432514325
return BAD_FUNC_ARG;
1432614326
ech = (WOLFSSL_ECH*)echX->data;
1432714327

14328+
/* if the first ECH was rejected or CH1 did not have ECH then there is
14329+
* no need to decrypt this one */
14330+
if (!ssl->options.echAccepted && ssl->options.serverState ==
14331+
SERVER_HELLO_RETRY_REQUEST_COMPLETE) {
14332+
ech->state = ECH_WRITE_RETRY_CONFIGS;
14333+
return 0;
14334+
}
14335+
1432814336
/* read the ech parameters before the payload */
1432914337
ech->type = *readBuf_p;
1433014338
readBuf_p++;

src/tls13.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5769,7 +5769,7 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
57695769
}
57705770
else {
57715771
#if defined(HAVE_ECH)
5772-
/* do not resume when outerHandshake will be negotiated */
5772+
/* do not resume when outerHandshake will be negotiated */
57735773
if (ssl->echConfigs != NULL && !ssl->options.disableECH &&
57745774
!ssl->options.echAccepted) {
57755775
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
@@ -15127,9 +15127,9 @@ static int test_wolfSSL_Tls13_ECH_retry_configs_auth_fail(void)
1512715127
EXPECT_DECLS;
1512815128

1512915129
ExpectIntEQ(test_wolfSSL_Tls13_ECH_retry_configs_auth_fail_ex(0),
15130-
WOLFSSL_SUCCESS);
15130+
TEST_SUCCESS);
1513115131
ExpectIntEQ(test_wolfSSL_Tls13_ECH_retry_configs_auth_fail_ex(1),
15132-
WOLFSSL_SUCCESS);
15132+
TEST_SUCCESS);
1513315133

1513415134
return EXPECT_RESULT();
1513515135
}

0 commit comments

Comments
 (0)