Skip to content

Commit 5922b5d

Browse files
authored
Merge pull request #9363 from julek-wolfssl/refactor-zero-return
Improve TLS 1.3 early data handling.
2 parents b6cfdcb + 3209d26 commit 5922b5d

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

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
@@ -15041,10 +15041,13 @@ int wolfSSL_read_early_data(WOLFSSL* ssl, void* data, int sz, int* outSz)
1504115041
return WOLFSSL_FATAL_ERROR;
1504215042
}
1504315043
if (ssl->options.handShakeState == SERVER_FINISHED_COMPLETE) {
15044+
ssl->options.clientInEarlyData = 1;
1504415045
ret = ReceiveData(ssl, (byte*)data, (size_t)sz, FALSE);
15046+
ssl->options.clientInEarlyData = 0;
1504515047
if (ret > 0)
1504615048
*outSz = ret;
15047-
if (ssl->error == WC_NO_ERR_TRACE(ZERO_RETURN)) {
15049+
if (ssl->error == WC_NO_ERR_TRACE(APP_DATA_READY)) {
15050+
ret = 0;
1504815051
ssl->error = WOLFSSL_ERROR_NONE;
1504915052
#ifdef WOLFSSL_DTLS13
1505015053
if (ssl->options.dtls) {

wolfssl/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5087,6 +5087,10 @@ struct Options {
50875087
word16 hrrSentKeyShare:1; /* HRR sent with key share */
50885088
#endif
50895089
word16 disableRead:1;
5090+
5091+
#ifdef WOLFSSL_EARLY_DATA
5092+
word16 clientInEarlyData:1; /* Client is in wolfSSL_read_early_data */
5093+
#endif
50905094
#ifdef WOLFSSL_DTLS
50915095
byte haveMcast; /* using multicast ? */
50925096
#endif

0 commit comments

Comments
 (0)