@@ -19597,7 +19597,8 @@ int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx, int sniff)
1959719597 return BUFFER_ERROR;
1959819598 }
1959919599#ifdef WOLFSSL_EARLY_DATA
19600- if (ssl->earlyData > early_data_ext) {
19600+ if (ssl->options.side == WOLFSSL_SERVER_END &&
19601+ ssl->earlyData > early_data_ext) {
1960119602 if (ssl->earlyDataSz + dataSz > ssl->options.maxEarlyDataSz) {
1960219603 if (sniff == NO_SNIFF) {
1960319604 SendAlert(ssl, alert_fatal, unexpected_message);
@@ -19637,6 +19638,15 @@ int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx, int sniff)
1963719638#endif
1963819639
1963919640 *inOutIdx = idx;
19641+ #ifdef WOLFSSL_DTLS13
19642+ if (ssl->options.connectState == WAIT_FINISHED_ACK) {
19643+ /* Reset the processReply state since
19644+ * we finished processing this message. */
19645+ ssl->options.processReply = doProcessInit;
19646+ /* DTLS 1.3 is waiting for an ACK but we can still return app data. */
19647+ return APP_DATA_READY;
19648+ }
19649+ #endif
1964019650#ifdef HAVE_SECURE_RENEGOTIATION
1964119651 if (IsSCR(ssl)) {
1964219652 /* Reset the processReply state since
@@ -20234,7 +20244,7 @@ int ProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
2023420244#endif
2023520245
2023620246 if (ssl->error != 0 && ssl->error != WANT_READ && ssl->error != WANT_WRITE
20237- #ifdef HAVE_SECURE_RENEGOTIATION
20247+ #if defined( HAVE_SECURE_RENEGOTIATION) || defined(WOLFSSL_DTLS13)
2023820248 && ssl->error != APP_DATA_READY
2023920249 #endif
2024020250 #ifdef WOLFSSL_ASYNC_CRYPT
@@ -21258,9 +21268,18 @@ int ProcessReplyEx(WOLFSSL* ssl, int allowSocketErr)
2125821268 /* input exhausted */
2125921269 if (ssl->buffers.inputBuffer.idx >= ssl->buffers.inputBuffer.length
2126021270#ifdef WOLFSSL_DTLS
21261- /* If app data was processed then return now to avoid
21262- * dropping any app data. */
21263- || (ssl->options.dtls && ssl->curRL.type == application_data)
21271+ || (ssl->options.dtls &&
21272+ /* If app data was processed then return now to avoid
21273+ * dropping any app data. */
21274+ (ssl->curRL.type == application_data ||
21275+ /* client: if we processed a finished message, return to
21276+ * allow higher layers to establish the crypto
21277+ * parameters of the connection. The remaining data
21278+ * may be app data that we would drop without the
21279+ * crypto setup. */
21280+ (ssl->options.side == WOLFSSL_CLIENT_END &&
21281+ ssl->options.serverState == SERVER_FINISHED_COMPLETE &&
21282+ ssl->options.handShakeState != HANDSHAKE_DONE)))
2126421283#endif
2126521284 ) {
2126621285 /* Shrink input buffer when we successfully finish record
@@ -23586,6 +23605,12 @@ int SendData(WOLFSSL* ssl, const void* data, int sz)
2358623605 groupMsgs = 1;
2358723606 #endif
2358823607 }
23608+ else if (IsAtLeastTLSv1_3(ssl->version) &&
23609+ ssl->options.side == WOLFSSL_SERVER_END &&
23610+ ssl->options.acceptState >= TLS13_ACCEPT_FINISHED_SENT) {
23611+ /* We can send data without waiting on peer finished msg */
23612+ WOLFSSL_MSG("server sending data before receiving client finished");
23613+ }
2358923614 else
2359023615#endif
2359123616 if (ssl->options.handShakeState != HANDSHAKE_DONE && !IsSCR(ssl)) {
@@ -23823,7 +23848,7 @@ int ReceiveData(WOLFSSL* ssl, byte* output, int sz, int peek)
2382323848#ifdef WOLFSSL_ASYNC_CRYPT
2382423849 && ssl->error != WC_PENDING_E
2382523850#endif
23826- #ifdef HAVE_SECURE_RENEGOTIATION
23851+ #if defined( HAVE_SECURE_RENEGOTIATION) || defined(WOLFSSL_DTLS13)
2382723852 && ssl->error != APP_DATA_READY
2382823853#endif
2382923854 ) {
0 commit comments