Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/dtls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -3476,8 +3476,6 @@ int Dtls13RtxTimeout(WOLFSSL* ssl)
(ssl->options.serverState >= SERVER_HELLO_COMPLETE ||
ssl->options.seenUnifiedHdr)) {
ssl->dtls13Rtx.sendAcks = 0;
/* reset fast timeout as we are sending ACKs */
ssl->dtls13FastTimeout = 0;
ret = SendDtls13Ack(ssl);
if (ret != 0)
return ret;
Expand Down
79 changes: 79 additions & 0 deletions tests/api/test_dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,85 @@ int test_dtls_drop_client_ack(void)
return EXPECT_RESULT();
}

#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
defined(WOLFSSL_DTLS13) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) && \
!defined(WOLFSSL_NO_CLIENT_AUTH)
/* A quick timeout that sends ACKs with nothing to retransmit doesn't back
* off, also when the timeout is already at its maximum. */
static int test_dtls13_quick_timeout_no_backoff_ex(int atMax)
{
EXPECT_DECLS;
struct test_memio_ctx test_ctx;
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
int timeout = 0;

XMEMSET(&test_ctx, 0, sizeof(test_ctx));
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
wolfDTLSv1_3_client_method, wolfDTLSv1_3_server_method), 0);
ExpectIntEQ(wolfSSL_use_certificate_file(ssl_c, cliCertFile,
WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_use_PrivateKey_file(ssl_c, cliKeyFile,
WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_CTX_load_verify_locations(ctx_s, cliCertFile, NULL),
WOLFSSL_SUCCESS);
wolfSSL_set_verify(ssl_s, WOLFSSL_VERIFY_PEER |
WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
wolfSSL_dtls13_set_send_more_acks(ssl_s, 0);
if (atMax) {
ExpectIntEQ(wolfSSL_dtls_set_timeout_max(ssl_s,
wolfSSL_dtls_get_current_timeout(ssl_s)), WOLFSSL_SUCCESS);
}

ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WOLFSSL_ERROR_WANT_READ);
/* The server only gets the first record of the client's flight. */
ExpectIntGE(test_ctx.s_msg_count, 2);
while (EXPECT_SUCCESS() && test_ctx.s_msg_count > 1)
ExpectIntEQ(test_memio_drop_message(&test_ctx, 0, 1), 0);
ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
ExpectIntEQ(wolfSSL_get_error(ssl_s, -1), WOLFSSL_ERROR_WANT_READ);
ExpectIntEQ(test_ctx.c_msg_count, 0);
ExpectIntEQ(wolfSSL_dtls13_use_quick_timeout(ssl_s), 1);
timeout = wolfSSL_dtls_get_current_timeout(ssl_s);

ExpectIntEQ(wolfSSL_dtls_got_timeout(ssl_s), WOLFSSL_SUCCESS);
ExpectIntEQ(test_ctx.c_msg_count, 1);
ExpectIntEQ(wolfSSL_dtls_get_current_timeout(ssl_s), timeout);
ExpectIntEQ(wolfSSL_dtls13_use_quick_timeout(ssl_s), 0);

if (!atMax) {
/* The next full timeout still backs off. */
ExpectIntEQ(wolfSSL_dtls_got_timeout(ssl_s), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_dtls_get_current_timeout(ssl_s),
timeout * DTLS_TIMEOUT_MULTIPLIER);
}
ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);

wolfSSL_free(ssl_c);
wolfSSL_free(ssl_s);
wolfSSL_CTX_free(ctx_c);
wolfSSL_CTX_free(ctx_s);
return EXPECT_RESULT();
}
#endif

int test_dtls13_quick_timeout_no_backoff(void)
{
EXPECT_DECLS;
#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
defined(WOLFSSL_DTLS13) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) && \
!defined(WOLFSSL_NO_CLIENT_AUTH)
ExpectIntEQ(test_dtls13_quick_timeout_no_backoff_ex(0), TEST_SUCCESS);
ExpectIntEQ(test_dtls13_quick_timeout_no_backoff_ex(1), TEST_SUCCESS);
#endif
return EXPECT_RESULT();
}

int test_dtls_bogus_finished_epoch_zero(void)
{
EXPECT_DECLS;
Expand Down
2 changes: 2 additions & 0 deletions tests/api/test_dtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ int test_records_span_network_boundaries(void);
int test_dtls_record_cross_boundaries(void);
int test_dtls_rtx_across_epoch_change(void);
int test_dtls_drop_client_ack(void);
int test_dtls13_quick_timeout_no_backoff(void);
int test_dtls_bogus_finished_epoch_zero(void);
int test_dtls_replay(void);
int test_dtls_timeout(void);
Expand Down Expand Up @@ -262,6 +263,7 @@ int test_dtls_no_cookie_ch_pause(WOLFSSL* ssl, void* ctx);
TEST_DECL_GROUP("dtls", test_dtls_record_cross_boundaries), \
TEST_DECL_GROUP("dtls", test_dtls_rtx_across_epoch_change), \
TEST_DECL_GROUP("dtls", test_dtls_drop_client_ack), \
TEST_DECL_GROUP("dtls", test_dtls13_quick_timeout_no_backoff), \
TEST_DECL_GROUP("dtls", test_dtls_bogus_finished_epoch_zero), \
TEST_DECL_GROUP("dtls", test_dtls_replay), \
TEST_DECL_GROUP("dtls", test_dtls_certreq_order), \
Expand Down
Loading