@@ -1637,3 +1637,62 @@ int test_dtls_srtp(void)
16371637 return EXPECT_RESULT ();
16381638}
16391639#endif
1640+
1641+ int test_dtls_timeout (void )
1642+ {
1643+ EXPECT_DECLS ;
1644+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES ) && defined(WOLFSSL_DTLS )
1645+ size_t i ;
1646+ struct {
1647+ method_provider client_meth ;
1648+ method_provider server_meth ;
1649+ } params [] = {
1650+ #if defined(WOLFSSL_TLS13 ) && defined (WOLFSSL_DTLS13 )
1651+ { wolfDTLSv1_3_client_method , wolfDTLSv1_3_server_method },
1652+ #endif
1653+ #if !defined (WOLFSSL_NO_TLS12 ) && defined (WOLFSSL_DTLS )
1654+ { wolfDTLSv1_2_client_method , wolfDTLSv1_2_server_method },
1655+ #endif
1656+ #if !defined (NO_OLD_TLS ) && defined (WOLFSSL_DTLS )
1657+ { wolfDTLSv1_client_method , wolfDTLSv1_server_method },
1658+ #endif
1659+ };
1660+
1661+ for (i = 0 ; i < XELEM_CNT (params ) && !EXPECT_FAIL (); i ++ ) {
1662+ WOLFSSL_CTX * ctx_c = NULL , * ctx_s = NULL ;
1663+ WOLFSSL * ssl_c = NULL , * ssl_s = NULL ;
1664+ struct test_memio_ctx test_ctx ;
1665+
1666+ XMEMSET (& test_ctx , 0 , sizeof (test_ctx ));
1667+
1668+ ExpectIntEQ (test_memio_setup (& test_ctx , & ctx_c , & ctx_s , & ssl_c , & ssl_s ,
1669+ params [i ].client_meth , params [i ].server_meth ), 0 );
1670+ ExpectIntEQ (wolfSSL_dtls_set_timeout_max (ssl_c , 2 ), WOLFSSL_SUCCESS );
1671+ ExpectIntEQ (wolfSSL_negotiate (ssl_c ), -1 );
1672+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1673+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_DTLS13 )
1674+ /* will return 0 when not 1.3 */
1675+ if (wolfSSL_dtls13_use_quick_timeout (ssl_c ))
1676+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1677+ #endif
1678+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1679+ ExpectIntEQ (wolfSSL_negotiate (ssl_s ), -1 );
1680+ ExpectIntEQ (wolfSSL_get_error (ssl_s , -1 ), WOLFSSL_ERROR_WANT_READ );
1681+ ExpectIntEQ (wolfSSL_negotiate (ssl_c ), -1 );
1682+ ExpectIntEQ (wolfSSL_get_error (ssl_c , -1 ), WOLFSSL_ERROR_WANT_READ );
1683+ #if defined(WOLFSSL_TLS13 ) && defined(WOLFSSL_DTLS13 )
1684+ /* will return 0 when not 1.3 */
1685+ if (wolfSSL_dtls13_use_quick_timeout (ssl_c ))
1686+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1687+ #endif
1688+ ExpectIntEQ (wolfSSL_dtls_got_timeout (ssl_c ), WOLFSSL_SUCCESS );
1689+ ExpectIntEQ (test_memio_do_handshake (ssl_c , ssl_s , 10 , NULL ), 0 );
1690+
1691+ wolfSSL_free (ssl_s );
1692+ wolfSSL_free (ssl_c );
1693+ wolfSSL_CTX_free (ctx_s );
1694+ wolfSSL_CTX_free (ctx_c );
1695+ }
1696+ #endif
1697+ return EXPECT_RESULT ();
1698+ }
0 commit comments