Skip to content

Commit 3209d26

Browse files
committed
Improve TLS 1.3 early data handling.
Introduce `clientInEarlyData` to only return when in `wolfSSL_read_early_data`. This makes sure that other API don't return `ZERO_RETURN` when not in `wolfSSL_read_early_data`. Chose `APP_DATA_READY` as it won't result in a false positive return from `wolfSSL_read_early_data`.
1 parent d456784 commit 3209d26

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

src/internal.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22842,8 +22842,8 @@ static int DoProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
2284222842
exit */
2284322843
ssl->earlyData = no_early_data;
2284422844
ssl->options.processReply = doProcessInit;
22845-
22846-
return ZERO_RETURN;
22845+
if (ssl->options.clientInEarlyData)
22846+
return APP_DATA_READY;
2284722847
}
2284822848
#endif /* WOLFSSL_EARLY_DATA */
2284922849
if (ret == 0 ||
@@ -22889,7 +22889,8 @@ static int DoProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
2288922889
ssl->options.handShakeState == HANDSHAKE_DONE) {
2289022890
ssl->earlyData = no_early_data;
2289122891
ssl->options.processReply = doProcessInit;
22892-
return ZERO_RETURN;
22892+
if (ssl->options.clientInEarlyData)
22893+
return APP_DATA_READY;
2289322894
}
2289422895
#endif
2289522896
#else

src/quic.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,6 @@ int wolfSSL_quic_do_handshake(WOLFSSL* ssl)
608608
else {
609609
ret = wolfSSL_read_early_data(ssl, tmpbuffer,
610610
sizeof(tmpbuffer), &len);
611-
if (ret < 0 && ssl->error == WC_NO_ERR_TRACE(ZERO_RETURN)) {
612-
/* this is expected, since QUIC handles the actual early
613-
* data separately. */
614-
ret = WOLFSSL_SUCCESS;
615-
}
616611
}
617612
if (ret < 0) {
618613
goto cleanup;

src/tls13.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15092,10 +15092,13 @@ int wolfSSL_read_early_data(WOLFSSL* ssl, void* data, int sz, int* outSz)
1509215092
return WOLFSSL_FATAL_ERROR;
1509315093
}
1509415094
if (ssl->options.handShakeState == SERVER_FINISHED_COMPLETE) {
15095+
ssl->options.clientInEarlyData = 1;
1509515096
ret = ReceiveData(ssl, (byte*)data, (size_t)sz, FALSE);
15097+
ssl->options.clientInEarlyData = 0;
1509615098
if (ret > 0)
1509715099
*outSz = ret;
15098-
if (ssl->error == WC_NO_ERR_TRACE(ZERO_RETURN)) {
15100+
if (ssl->error == WC_NO_ERR_TRACE(APP_DATA_READY)) {
15101+
ret = 0;
1509915102
ssl->error = WOLFSSL_ERROR_NONE;
1510015103
#ifdef WOLFSSL_DTLS13
1510115104
if (ssl->options.dtls) {

wolfssl/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5083,6 +5083,10 @@ struct Options {
50835083
word16 hrrSentKeyShare:1; /* HRR sent with key share */
50845084
#endif
50855085
word16 disableRead:1;
5086+
5087+
#ifdef WOLFSSL_EARLY_DATA
5088+
word16 clientInEarlyData:1; /* Client is in wolfSSL_read_early_data */
5089+
#endif
50865090
#ifdef WOLFSSL_DTLS
50875091
byte haveMcast; /* using multicast ? */
50885092
#endif

0 commit comments

Comments
 (0)