@@ -1383,3 +1383,82 @@ int test_dtls_rtx_across_epoch_change(void)
13831383 defined(WOLFSSL_DTLS13) */
13841384 return EXPECT_RESULT ();
13851385}
1386+ int test_dtls_drop_client_ack (void )
1387+ {
1388+ EXPECT_DECLS ;
1389+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && \
1390+ defined(WOLFSSL_DTLS13 ) && defined(WOLFSSL_DTLS )
1391+ WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
1392+ WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
1393+ struct test_memio_ctx test_ctx ;
1394+ char data [32 ];
1395+
1396+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
1397+
1398+ /* Setup DTLS contexts */
1399+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
1400+ wolfDTLSv1_3_client_method , wolfDTLSv1_3_server_method ),
1401+ 0 );
1402+
1403+ /* disable new session ticket to simplify testing */
1404+ ExpectIntEQ (wolfSSL_no_ticket_TLSv13 (ssl_s ), 0 );
1405+
1406+ /* CH0 */
1407+ wolfSSL_SetLoggingPrefix ("client:" );
1408+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
1409+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1410+
1411+ /* HRR */
1412+ wolfSSL_SetLoggingPrefix ("server:" );
1413+ ExpectIntEQ (wolfSSL_accept (ssl_s ), -1 );
1414+ ExpectIntEQ (wolfSSL_get_error (ssl_s , -1 ), WOLFSSL_ERROR_WANT_READ );
1415+
1416+ /* CH1 */
1417+ wolfSSL_SetLoggingPrefix ("client:" );
1418+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
1419+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1420+
1421+ /* SH ... FINISHED */
1422+ wolfSSL_SetLoggingPrefix ("server:" );
1423+ ExpectIntEQ (wolfSSL_accept (ssl_s ), -1 );
1424+ ExpectIntEQ (wolfSSL_get_error (ssl_s , -1 ), WOLFSSL_ERROR_WANT_READ );
1425+
1426+ /* ... FINISHED */
1427+ wolfSSL_SetLoggingPrefix ("client:" );
1428+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
1429+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1430+
1431+ /* init is finished should return false at this point */
1432+ ExpectFalse (wolfSSL_is_init_finished (ssl_c ));
1433+
1434+ /* ACK */
1435+ ExpectIntEQ (wolfSSL_accept (ssl_s ), WOLFSSL_SUCCESS );
1436+ /* Drop the ack */
1437+ test_memio_clear_buffer (& test_ctx , 1 );
1438+
1439+ /* trigger client timeout, finished should be rtx */
1440+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1441+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1442+ /* this should have triggered a rtx */
1443+ ExpectIntGT (test_ctx .s_msg_count , 0 );
1444+
1445+ /* this should re-send the ack immediately */
1446+ ExpectIntEQ (wolfSSL_read (ssl_s , data , 32 ), -1 );
1447+ ExpectIntEQ (wolfSSL_get_error (ssl_s , -1 ), WOLFSSL_ERROR_WANT_READ );
1448+ ExpectIntEQ (test_ctx .c_msg_count , 1 );
1449+
1450+ /* This should advance the connection on the client */
1451+ ExpectIntEQ (wolfSSL_negotiate (ssl_c ), WOLFSSL_SUCCESS );
1452+
1453+ /* Test communication works correctly */
1454+ ExpectIntEQ (test_dtls_communication (ssl_s , ssl_c ), TEST_SUCCESS );
1455+
1456+ /* Cleanup */
1457+ wolfSSL_free (ssl_c );
1458+ wolfSSL_CTX_free (ctx_c );
1459+ wolfSSL_free (ssl_s );
1460+ wolfSSL_CTX_free (ctx_s );
1461+ #endif /* defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
1462+ defined(WOLFSSL_DTLS13) */
1463+ return EXPECT_RESULT ();
1464+ }
0 commit comments