Skip to content

Commit fbc6ed4

Browse files
Merge pull request #6662 from julek-wolfssl/zd/16504
DoHelloVerifyRequest: only do DTLS 1.3 version check
2 parents a885a94 + 6f4faba commit fbc6ed4

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27700,9 +27700,11 @@ static int HashSkeData(WOLFSSL* ssl, enum wc_HashType hashType,
2770027700
#if defined(WOLFSSL_DTLS13) && defined(WOLFSSL_TLS13)
2770127701
if (IsAtLeastTLSv1_3(ssl->version) && ssl->options.dtls) {
2770227702
/* we sent a TLSv1.3 ClientHello but received a
27703-
* HELLO_VERIFY_REQUEST */
27703+
* HELLO_VERIFY_REQUEST. We only check if DTLSv1_3_MINOR is the
27704+
* min downgrade option as per the server_version field comments in
27705+
* https://www.rfc-editor.org/rfc/rfc6347#section-4.2.1 */
2770427706
if (!ssl->options.downgrade ||
27705-
ssl->options.minDowngrade < pv.minor)
27707+
ssl->options.minDowngrade <= DTLSv1_3_MINOR)
2770627708
return VERSION_ERROR;
2770727709
}
2770827710
#endif /* defined(WOLFSSL_DTLS13) && defined(WOLFSSL_TLS13) */

tests/api.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57425,7 +57425,7 @@ static int test_openssl_generate_key_and_cert(void)
5742557425

5742657426
#if !defined(NO_CERTS) && defined(WOLFSSL_CERT_GEN) && \
5742757427
defined(WOLFSSL_CERT_REQ) && !defined(NO_ASN_TIME)
57428-
expectedDerSz = 345;
57428+
expectedDerSz = 344;
5742957429
ExpectIntEQ(test_openssl_make_self_signed_certificate(pkey, expectedDerSz),
5743057430
TEST_SUCCESS);
5743157431
#endif
@@ -63135,6 +63135,43 @@ static int test_TLSX_CA_NAMES_bad_extension(void)
6313563135
return EXPECT_RESULT();
6313663136
}
6313763137

63138+
#if defined(WOLFSSL_DTLS) && !defined(WOLFSSL_NO_TLS12) && \
63139+
defined(HAVE_IO_TESTS_DEPENDENCIES)
63140+
static void test_dtls_1_0_hvr_downgrade_ctx_ready(WOLFSSL_CTX* ctx)
63141+
{
63142+
AssertIntEQ(wolfSSL_CTX_SetMinVersion(ctx, WOLFSSL_DTLSV1_2),
63143+
WOLFSSL_SUCCESS);
63144+
}
63145+
63146+
static int test_dtls_1_0_hvr_downgrade(void)
63147+
{
63148+
EXPECT_DECLS;
63149+
callback_functions func_cb_client;
63150+
callback_functions func_cb_server;
63151+
63152+
XMEMSET(&func_cb_client, 0, sizeof(callback_functions));
63153+
XMEMSET(&func_cb_server, 0, sizeof(callback_functions));
63154+
63155+
func_cb_client.doUdp = func_cb_server.doUdp = 1;
63156+
func_cb_server.method = wolfDTLSv1_2_server_method;
63157+
func_cb_client.method = wolfDTLS_client_method;
63158+
func_cb_client.ctx_ready = test_dtls_1_0_hvr_downgrade_ctx_ready;
63159+
63160+
test_wolfSSL_client_server_nofail(&func_cb_client, &func_cb_server);
63161+
63162+
ExpectIntEQ(func_cb_client.return_code, TEST_SUCCESS);
63163+
ExpectIntEQ(func_cb_server.return_code, TEST_SUCCESS);
63164+
63165+
return EXPECT_RESULT();
63166+
}
63167+
#else
63168+
static int test_dtls_1_0_hvr_downgrade(void)
63169+
{
63170+
EXPECT_DECLS;
63171+
return EXPECT_RESULT();
63172+
}
63173+
#endif
63174+
6313863175
/*----------------------------------------------------------------------------*
6313963176
| Main
6314063177
*----------------------------------------------------------------------------*/
@@ -64387,6 +64424,7 @@ TEST_CASE testCases[] = {
6438764424
TEST_DECL(test_wolfSSL_SCR_after_resumption),
6438864425
TEST_DECL(test_dtls_no_extensions),
6438964426
TEST_DECL(test_TLSX_CA_NAMES_bad_extension),
64427+
TEST_DECL(test_dtls_1_0_hvr_downgrade),
6439064428
/* This test needs to stay at the end to clean up any caches allocated. */
6439164429
TEST_DECL(test_wolfSSL_Cleanup)
6439264430
};

0 commit comments

Comments
 (0)