@@ -2999,6 +2999,85 @@ int test_dtls_drop_client_ack(void)
29992999 return EXPECT_RESULT();
30003000}
30013001
3002+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
3003+ defined(WOLFSSL_DTLS13) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) && \
3004+ !defined(WOLFSSL_NO_CLIENT_AUTH)
3005+ /* A quick timeout that sends ACKs with nothing to retransmit doesn't back
3006+ * off, also when the timeout is already at its maximum. */
3007+ static int test_dtls13_quick_timeout_no_backoff_ex(int atMax)
3008+ {
3009+ EXPECT_DECLS;
3010+ struct test_memio_ctx test_ctx;
3011+ WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
3012+ WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
3013+ int timeout = 0;
3014+
3015+ XMEMSET(&test_ctx, 0, sizeof(test_ctx));
3016+ ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
3017+ wolfDTLSv1_3_client_method, wolfDTLSv1_3_server_method), 0);
3018+ ExpectIntEQ(wolfSSL_use_certificate_file(ssl_c, cliCertFile,
3019+ WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
3020+ ExpectIntEQ(wolfSSL_use_PrivateKey_file(ssl_c, cliKeyFile,
3021+ WOLFSSL_FILETYPE_PEM), WOLFSSL_SUCCESS);
3022+ ExpectIntEQ(wolfSSL_CTX_load_verify_locations(ctx_s, cliCertFile, NULL),
3023+ WOLFSSL_SUCCESS);
3024+ wolfSSL_set_verify(ssl_s, WOLFSSL_VERIFY_PEER |
3025+ WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
3026+ wolfSSL_dtls13_set_send_more_acks(ssl_s, 0);
3027+ if (atMax) {
3028+ ExpectIntEQ(wolfSSL_dtls_set_timeout_max(ssl_s,
3029+ wolfSSL_dtls_get_current_timeout(ssl_s)), WOLFSSL_SUCCESS);
3030+ }
3031+
3032+ ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
3033+ ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
3034+ ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
3035+ ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
3036+ ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
3037+ ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WOLFSSL_ERROR_WANT_READ);
3038+ /* The server only gets the first record of the client's flight. */
3039+ ExpectIntGE(test_ctx.s_msg_count, 2);
3040+ while (EXPECT_SUCCESS() && test_ctx.s_msg_count > 1)
3041+ ExpectIntEQ(test_memio_drop_message(&test_ctx, 0, 1), 0);
3042+ ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
3043+ ExpectIntEQ(wolfSSL_get_error(ssl_s, -1), WOLFSSL_ERROR_WANT_READ);
3044+ ExpectIntEQ(test_ctx.c_msg_count, 0);
3045+ ExpectIntEQ(wolfSSL_dtls13_use_quick_timeout(ssl_s), 1);
3046+ timeout = wolfSSL_dtls_get_current_timeout(ssl_s);
3047+
3048+ ExpectIntEQ(wolfSSL_dtls_got_timeout(ssl_s), WOLFSSL_SUCCESS);
3049+ ExpectIntEQ(test_ctx.c_msg_count, 1);
3050+ ExpectIntEQ(wolfSSL_dtls_get_current_timeout(ssl_s), timeout);
3051+ ExpectIntEQ(wolfSSL_dtls13_use_quick_timeout(ssl_s), 0);
3052+
3053+ if (!atMax) {
3054+ /* The next full timeout still backs off. */
3055+ ExpectIntEQ(wolfSSL_dtls_got_timeout(ssl_s), WOLFSSL_SUCCESS);
3056+ ExpectIntEQ(wolfSSL_dtls_get_current_timeout(ssl_s),
3057+ timeout * DTLS_TIMEOUT_MULTIPLIER);
3058+ }
3059+ ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);
3060+
3061+ wolfSSL_free(ssl_c);
3062+ wolfSSL_free(ssl_s);
3063+ wolfSSL_CTX_free(ctx_c);
3064+ wolfSSL_CTX_free(ctx_s);
3065+ return EXPECT_RESULT();
3066+ }
3067+ #endif
3068+
3069+ int test_dtls13_quick_timeout_no_backoff(void)
3070+ {
3071+ EXPECT_DECLS;
3072+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
3073+ defined(WOLFSSL_DTLS13) && !defined(NO_RSA) && !defined(NO_FILESYSTEM) && \
3074+ !defined(WOLFSSL_NO_CLIENT_AUTH)
3075+ ExpectIntEQ(test_dtls13_quick_timeout_no_backoff_ex(0), TEST_SUCCESS);
3076+ ExpectIntEQ(test_dtls13_quick_timeout_no_backoff_ex(1), TEST_SUCCESS);
3077+ #endif
3078+ return EXPECT_RESULT();
3079+ }
3080+
30023081int test_dtls_bogus_finished_epoch_zero(void)
30033082{
30043083 EXPECT_DECLS;
0 commit comments