@@ -1836,6 +1836,98 @@ int test_dtls_rtx_across_epoch_change(void)
18361836 return EXPECT_RESULT ();
18371837}
18381838
1839+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && \
1840+ defined(WOLFSSL_DTLS13 ) && defined(WOLFSSL_DTLS )
1841+ static int test_dtls13_get_message_seq (const char * msg , int msgSz ,
1842+ word16 * msgSeq )
1843+ {
1844+ int hsOff = DTLS_RECORD_HEADER_SZ ;
1845+
1846+ if (msg == NULL || msgSeq == NULL ||
1847+ msgSz < DTLS_RECORD_HEADER_SZ + DTLS_HANDSHAKE_HEADER_SZ ) {
1848+ return BAD_FUNC_ARG ;
1849+ }
1850+
1851+ * msgSeq = ((word16 )(byte )msg [hsOff + 4 ] << 8 ) |
1852+ (word16 )(byte )msg [hsOff + 5 ];
1853+
1854+ return WOLFSSL_SUCCESS ;
1855+ }
1856+ #endif
1857+
1858+ int test_dtls13_ch2_rtx_no_ch1 (void )
1859+ {
1860+ EXPECT_DECLS ;
1861+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && \
1862+ defined(WOLFSSL_DTLS13 ) && defined(WOLFSSL_DTLS )
1863+ WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
1864+ WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
1865+ struct test_memio_ctx test_ctx ;
1866+ const char * msg = NULL ;
1867+ int msgSz = 0 ;
1868+ word16 ch1Seq = 0 ;
1869+ int i ;
1870+ int foundCh1Seq = 0 ;
1871+
1872+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
1873+
1874+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
1875+ wolfDTLSv1_3_client_method , wolfDTLSv1_3_server_method ),
1876+ 0 );
1877+
1878+ /* To force HRR */
1879+ ExpectIntEQ (wolfSSL_NoKeyShares (ssl_c ), WOLFSSL_SUCCESS );
1880+
1881+ /* CH1 */
1882+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
1883+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1884+ ExpectIntEQ (test_memio_get_message (& test_ctx , 0 , & msg , & msgSz , 0 ), 0 );
1885+ ExpectIntGE (msgSz , DTLS_RECORD_HEADER_SZ + DTLS_HANDSHAKE_HEADER_SZ );
1886+ ExpectIntEQ (test_dtls13_get_message_seq (msg , msgSz , & ch1Seq ),
1887+ WOLFSSL_SUCCESS );
1888+
1889+ /* HRR */
1890+ ExpectIntEQ (wolfSSL_accept (ssl_s ), -1 );
1891+ ExpectIntEQ (wolfSSL_get_error (ssl_s , -1 ), WOLFSSL_ERROR_WANT_READ );
1892+ ExpectIntGT (test_ctx .c_msg_count , 0 );
1893+
1894+ /* CH2 */
1895+ ExpectIntEQ (wolfSSL_connect (ssl_c ), -1 );
1896+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1897+ ExpectIntGT (test_ctx .s_msg_count , 0 );
1898+
1899+ /* Drop CH2 and trigger the client retransmission timeout. */
1900+ test_memio_clear_buffer (& test_ctx , 0 );
1901+ if (wolfSSL_dtls13_use_quick_timeout (ssl_c ))
1902+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1903+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1904+ ExpectIntGT (test_ctx .s_msg_count , 0 );
1905+
1906+ for (i = 0 ; i < test_ctx .s_msg_count && EXPECT_SUCCESS (); i ++ ) {
1907+ int hsOff = DTLS_RECORD_HEADER_SZ ;
1908+ word16 msgSeq = 0 ;
1909+
1910+ ExpectIntEQ (test_memio_get_message (& test_ctx , 0 , & msg , & msgSz , i ), 0 );
1911+ /* memio stores one DTLS record per message in this handshake path. */
1912+ if (msgSz >= DTLS_RECORD_HEADER_SZ + DTLS_HANDSHAKE_HEADER_SZ &&
1913+ (byte )msg [0 ] == handshake && msg [hsOff ] == client_hello ) {
1914+ ExpectIntEQ (test_dtls13_get_message_seq (msg , msgSz , & msgSeq ),
1915+ WOLFSSL_SUCCESS );
1916+ if (msgSeq == ch1Seq )
1917+ foundCh1Seq = 1 ;
1918+ }
1919+ }
1920+
1921+ ExpectIntEQ (foundCh1Seq , 0 );
1922+
1923+ wolfSSL_free (ssl_c );
1924+ wolfSSL_CTX_free (ctx_c );
1925+ wolfSSL_free (ssl_s );
1926+ wolfSSL_CTX_free (ctx_s );
1927+ #endif
1928+ return EXPECT_RESULT ();
1929+ }
1930+
18391931int test_dtls_drop_client_ack (void )
18401932{
18411933 EXPECT_DECLS ;
0 commit comments