Skip to content

Commit 30cfb38

Browse files
fixed seg fault when confirmation not present
1 parent 3605c2a commit 30cfb38

2 files changed

Lines changed: 12 additions & 24 deletions

File tree

src/tls.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13584,8 +13584,6 @@ static int TLSX_ECH_Parse(WOLFSSL* ssl, const byte* readBuf, word16 size,
1358413584
}
1358513585
/* HRR with special confirmation */
1358613586
else if (msgType == hello_retry_request && ssl->options.useEch) {
13587-
/* TODO: confirmation may not exist -> segfault? */
13588-
printf("\n\ngot special confirmation\n\n\n");
1358913587
/* length must be 8 */
1359013588
if (size != ECH_ACCEPT_CONFIRMATION_SZ)
1359113589
return BAD_FUNC_ARG;
@@ -14441,7 +14439,6 @@ static int TLSX_Write(TLSX* list, byte* output, byte* semaphore,
1444114439
WOLFSSL_MSG("ECH extension to write");
1444214440
ret = ECH_WRITE((WOLFSSL_ECH*)extension->data, msgType,
1444314441
output + offset, &offset);
14444-
fprintf(stderr, "\t\thit this\n");
1444514442
break;
1444614443
#endif
1444714444
default:
@@ -16975,6 +16972,18 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
1697516972
if (ret == 0)
1697616973
ret = TCA_VERIFY_PARSE(ssl, isRequest);
1697716974

16975+
#if defined(WOLFSSL_TLS13) && defined(HAVE_ECH)
16976+
/* If client used ECH, server HRR must include ECH confirmation */
16977+
if (ret == 0 && msgType == hello_retry_request && ssl->options.useEch == 1) {
16978+
TLSX* echX = TLSX_Find(ssl->extensions, TLSX_ECH);
16979+
if (echX == NULL || ((WOLFSSL_ECH*)echX->data)->confBuf == NULL) {
16980+
WOLFSSL_MSG("ECH used but HRR missing ECH confirmation");
16981+
WOLFSSL_ERROR_VERBOSE(EXT_MISSING);
16982+
ret = EXT_MISSING;
16983+
}
16984+
}
16985+
#endif
16986+
1697816987
WOLFSSL_LEAVE("Leaving TLSX_Parse", ret);
1697916988
return ret;
1698016989
}

src/tls13.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
257257
#endif
258258

259259
#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
260-
printf("Running this\n");
261260
ret = wc_Tls13_HKDF_Expand_Label_ex(okm, okmLen, prk, prkLen,
262261
protocol, protocolLen,
263262
label, labelLen,
@@ -5681,18 +5680,15 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
56815680
if (args->extMsgType == hello_retry_request) {
56825681
args->acceptOffset =
56835682
(word32)(((WOLFSSL_ECH*)args->echX->data)->confBuf - input);
5684-
printf("\n\n\nCONFBUF %p\n", ((WOLFSSL_ECH*)args->echX->data)->confBuf);
56855683
args->acceptLabel = (byte*)echHrrAcceptConfirmationLabel;
56865684
args->acceptLabelSz = ECH_HRR_ACCEPT_CONFIRMATION_LABEL_SZ;
5687-
printf("\n\nHELLO RETRY REQUEST\n\n\n");
56885685
}
56895686
else {
56905687
args->acceptLabel = (byte*)echAcceptConfirmationLabel;
56915688
args->acceptLabelSz = ECH_ACCEPT_CONFIRMATION_LABEL_SZ;
56925689
}
56935690
/* check acceptance */
56945691
if (ret == 0) {
5695-
printf("inOutIdx %d acceptOffset %d\n", *inOutIdx, args->acceptOffset);
56965692
ret = EchCheckAcceptance(ssl, args->acceptLabel,
56975693
args->acceptLabelSz, input, args->acceptOffset, helloSz);
56985694
}
@@ -5762,7 +5758,6 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
57625758
ssl->options.tls1_3 = 1;
57635759
ssl->options.serverState = SERVER_HELLO_RETRY_REQUEST_COMPLETE;
57645760

5765-
printf("\n\n\nRestarting HASH\n\n\n\n");
57665761
ret = RestartHandshakeHash(ssl);
57675762
}
57685763

@@ -13062,19 +13057,11 @@ int DoTls13HandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1306213057
return OUT_OF_ORDER_E;
1306313058
}
1306413059

13065-
if (ssl->options.echAccepted == 1) {
13066-
printf("\n\n\nHIGH LEVEL - ECH ACCEPTED\n\n\n\n");
13067-
}
13068-
else {
13069-
printf("\n\n\nHIGH LEVEL - ECH REJECTED\n\n\n\n");
13070-
}
13071-
1307213060
/* above checks handshake state */
1307313061
switch (type) {
1307413062
#ifndef NO_WOLFSSL_CLIENT
1307513063
/* Messages only received by client. */
1307613064
case server_hello:
13077-
printf("\n\n\nProcessing SERVER HELLO\n\n\n\n");
1307813065
WOLFSSL_MSG("processing server hello");
1307913066
ret = DoTls13ServerHello(ssl, input, inOutIdx, size, &type);
1308013067
#if !defined(WOLFSSL_NO_CLIENT_AUTH) && \
@@ -13225,14 +13212,6 @@ int DoTls13HandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1322513212
break;
1322613213
}
1322713214

13228-
if (ssl->options.echAccepted == 1) {
13229-
printf("\n\n\nHIGH LEVEL 2 - ECH ACCEPTED\n\n\n\n");
13230-
}
13231-
else {
13232-
printf("\n\n\nHIGH LEVEL 2 - ECH REJECTED\n\n\n\n");
13233-
}
13234-
13235-
1323613215
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_ASYNC_IO)
1323713216
/* if async, offset index so this msg will be processed again */
1323813217
/* NOTE: check this now before other calls can overwrite ret */

0 commit comments

Comments
 (0)