@@ -6367,7 +6367,7 @@ static THREAD_RETURN WOLFSSL_THREAD test_server_nofail(void* args)
63676367 if (ret < 0) { break; } else if (ret == 0) { continue; }
63686368 }
63696369 #endif
6370- ret = wolfSSL_accept (ssl);
6370+ ret = wolfSSL_negotiate (ssl);
63716371 err = wolfSSL_get_error(ssl, 0);
63726372 } while (err == WC_PENDING_E);
63736373 if (ret != WOLFSSL_SUCCESS) {
@@ -63162,8 +63162,8 @@ static int test_dtls_1_0_hvr_downgrade(void)
6316263162 XMEMSET(&func_cb_server, 0, sizeof(callback_functions));
6316363163
6316463164 func_cb_client.doUdp = func_cb_server.doUdp = 1;
63165- func_cb_server.method = wolfDTLSv1_2_server_method;
6316663165 func_cb_client.method = wolfDTLS_client_method;
63166+ func_cb_server.method = wolfDTLSv1_2_server_method;
6316763167 func_cb_client.ctx_ready = test_dtls_1_0_hvr_downgrade_ctx_ready;
6316863168
6316963169 test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server);
@@ -63251,6 +63251,71 @@ 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_server_ctx_ready_server(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_server_ctx_ready(WOLFSSL_CTX* ctx)
63264+ {
63265+ AssertIntEQ(wolfSSL_CTX_UseSecureRenegotiation(ctx), WOLFSSL_SUCCESS);
63266+ }
63267+
63268+ static void test_dtls_downgrade_scr_server_on_result(WOLFSSL* ssl)
63269+ {
63270+ char testMsg[] = "Message after SCR";
63271+ char msgBuf[sizeof(testMsg)];
63272+ if (wolfSSL_is_server(ssl)) {
63273+ AssertIntEQ(wolfSSL_Rehandshake(ssl), WOLFSSL_FATAL_ERROR);
63274+ AssertIntEQ(wolfSSL_get_error(ssl, -1), APP_DATA_READY);
63275+ AssertIntEQ(wolfSSL_read(ssl, msgBuf, sizeof(msgBuf)), sizeof(msgBuf));
63276+ AssertIntEQ(wolfSSL_Rehandshake(ssl), WOLFSSL_SUCCESS);
63277+ AssertIntEQ(wolfSSL_write(ssl, testMsg, sizeof(testMsg)),
63278+ sizeof(testMsg));
63279+ }
63280+ else {
63281+ AssertIntEQ(wolfSSL_write(ssl, testMsg, sizeof(testMsg)),
63282+ sizeof(testMsg));
63283+ AssertIntEQ(wolfSSL_read(ssl, msgBuf, sizeof(msgBuf)), sizeof(msgBuf));
63284+ }
63285+ }
63286+
63287+ static int test_dtls_downgrade_scr_server(void)
63288+ {
63289+ EXPECT_DECLS;
63290+ callback_functions func_cb_client;
63291+ callback_functions func_cb_server;
63292+
63293+ XMEMSET(&func_cb_client, 0, sizeof(callback_functions));
63294+ XMEMSET(&func_cb_server, 0, sizeof(callback_functions));
63295+
63296+ func_cb_client.doUdp = func_cb_server.doUdp = 1;
63297+ func_cb_client.method = wolfDTLSv1_2_client_method;
63298+ func_cb_server.method = wolfDTLS_server_method;
63299+ func_cb_client.ctx_ready = test_dtls_downgrade_scr_server_ctx_ready;
63300+ func_cb_server.ctx_ready = test_dtls_downgrade_scr_server_ctx_ready_server;
63301+ func_cb_client.on_result = test_dtls_downgrade_scr_server_on_result;
63302+ func_cb_server.on_result = test_dtls_downgrade_scr_server_on_result;
63303+
63304+ test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server);
63305+
63306+ ExpectIntEQ(func_cb_client.return_code, TEST_SUCCESS);
63307+ ExpectIntEQ(func_cb_server.return_code, TEST_SUCCESS);
63308+
63309+ return EXPECT_RESULT();
63310+ }
63311+ #else
63312+ static int test_dtls_downgrade_scr_server(void)
63313+ {
63314+ EXPECT_DECLS;
63315+ return EXPECT_RESULT();
63316+ }
63317+ #endif
63318+
6325463319#if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && \
6325563320 defined(HAVE_IO_TESTS_DEPENDENCIES) && defined(HAVE_SECURE_RENEGOTIATION)
6325663321static void test_dtls_downgrade_scr_ctx_ready(WOLFSSL_CTX* ctx)
@@ -63289,8 +63354,8 @@ static int test_dtls_downgrade_scr(void)
6328963354 XMEMSET(&func_cb_server, 0, sizeof(callback_functions));
6329063355
6329163356 func_cb_client.doUdp = func_cb_server.doUdp = 1;
63292- func_cb_server.method = wolfDTLSv1_2_server_method;
6329363357 func_cb_client.method = wolfDTLS_client_method;
63358+ func_cb_server.method = wolfDTLSv1_2_server_method;
6329463359 func_cb_client.ctx_ready = test_dtls_downgrade_scr_ctx_ready;
6329563360 func_cb_client.on_result = test_dtls_downgrade_scr_on_result;
6329663361 func_cb_server.on_result = test_dtls_downgrade_scr_on_result;
@@ -64564,6 +64629,7 @@ TEST_CASE testCases[] = {
6456464629 TEST_DECL(test_TLSX_CA_NAMES_bad_extension),
6456564630 TEST_DECL(test_dtls_1_0_hvr_downgrade),
6456664631 TEST_DECL(test_session_ticket_no_id),
64632+ TEST_DECL(test_dtls_downgrade_scr_server),
6456764633 TEST_DECL(test_dtls_downgrade_scr),
6456864634 /* This test needs to stay at the end to clean up any caches allocated. */
6456964635 TEST_DECL(test_wolfSSL_Cleanup)
0 commit comments