@@ -63251,6 +63251,65 @@ static int test_session_ticket_no_id(void)
6325163251}
6325263252#endif
6325363253
63254+ #if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && \
63255+ defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_SECURE_RENEGOTIATION)
63256+ static void test_dtls_downgrade_scr_ctx_ready(WOLFSSL_CTX* ctx)
63257+ {
63258+ AssertIntEQ(wolfSSL_CTX_SetMinVersion(ctx, WOLFSSL_DTLSV1_2),
63259+ WOLFSSL_SUCCESS);
63260+ AssertIntEQ(wolfSSL_CTX_UseSecureRenegotiation(ctx), WOLFSSL_SUCCESS);
63261+ }
63262+
63263+ static void test_dtls_downgrade_scr_on_result(WOLFSSL* ssl)
63264+ {
63265+ char testMsg[] = "Message after SCR";
63266+ char msgBuf[sizeof(testMsg)];
63267+ if (wolfSSL_is_server(ssl)) {
63268+ AssertIntEQ(wolfSSL_Rehandshake(ssl), WOLFSSL_FATAL_ERROR);
63269+ AssertIntEQ(wolfSSL_get_error(ssl, -1), APP_DATA_READY);
63270+ AssertIntEQ(wolfSSL_read(ssl, msgBuf, sizeof(msgBuf)), sizeof(msgBuf));
63271+ AssertIntEQ(wolfSSL_Rehandshake(ssl), WOLFSSL_SUCCESS);
63272+ AssertIntEQ(wolfSSL_write(ssl, testMsg, sizeof(testMsg)),
63273+ sizeof(testMsg));
63274+ }
63275+ else {
63276+ AssertIntEQ(wolfSSL_write(ssl, testMsg, sizeof(testMsg)),
63277+ sizeof(testMsg));
63278+ AssertIntEQ(wolfSSL_read(ssl, msgBuf, sizeof(msgBuf)), sizeof(msgBuf));
63279+ }
63280+ }
63281+
63282+ static int test_dtls_downgrade_scr(void)
63283+ {
63284+ EXPECT_DECLS;
63285+ callback_functions func_cb_client;
63286+ callback_functions func_cb_server;
63287+
63288+ XMEMSET(&func_cb_client, 0, sizeof(callback_functions));
63289+ XMEMSET(&func_cb_server, 0, sizeof(callback_functions));
63290+
63291+ func_cb_client.doUdp = func_cb_server.doUdp = 1;
63292+ func_cb_server.method = wolfDTLSv1_2_server_method;
63293+ func_cb_client.method = wolfDTLS_client_method;
63294+ func_cb_client.ctx_ready = test_dtls_downgrade_scr_ctx_ready;
63295+ func_cb_client.on_result = test_dtls_downgrade_scr_on_result;
63296+ func_cb_server.on_result = test_dtls_downgrade_scr_on_result;
63297+
63298+ test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server);
63299+
63300+ ExpectIntEQ(func_cb_client.return_code, TEST_SUCCESS);
63301+ ExpectIntEQ(func_cb_server.return_code, TEST_SUCCESS);
63302+
63303+ return EXPECT_RESULT();
63304+ }
63305+ #else
63306+ static int test_dtls_downgrade_scr(void)
63307+ {
63308+ EXPECT_DECLS;
63309+ return EXPECT_RESULT();
63310+ }
63311+ #endif
63312+
6325463313/*----------------------------------------------------------------------------*
6325563314 | Main
6325663315 *----------------------------------------------------------------------------*/
@@ -64505,6 +64564,7 @@ TEST_CASE testCases[] = {
6450564564 TEST_DECL(test_TLSX_CA_NAMES_bad_extension),
6450664565 TEST_DECL(test_dtls_1_0_hvr_downgrade),
6450764566 TEST_DECL(test_session_ticket_no_id),
64567+ TEST_DECL(test_dtls_downgrade_scr),
6450864568 /* This test needs to stay at the end to clean up any caches allocated. */
6450964569 TEST_DECL(test_wolfSSL_Cleanup)
6451064570};
0 commit comments