]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Run 70-test_tls13cookie.t with dtls
authorFrederik Wedel-Heinen <frederik.wedel-heinen@dencrypt.dk>
Wed, 29 May 2024 13:29:49 +0000 (15:29 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 2 Oct 2025 12:45:14 +0000 (14:45 +0200)
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24525)

test/recipes/70-test_tls13cookie.t

index e1c65f2fa4d15483eab70ea02d34a31e949ee134..90077d4dddea6b3ef0a2094ae0889a1c75196027 100644 (file)
@@ -26,49 +26,81 @@ plan skip_all => "$test_name needs the module feature enabled"
 plan skip_all => "$test_name needs the sock feature enabled"
     if disabled("sock");
 
-plan skip_all => "$test_name needs TLS1.3 enabled"
-    if disabled("tls1_3") || (disabled("ec") && disabled("dh"));
+plan skip_all => "$test_name needs EC and DH enabled"
+    if disabled("ec") && disabled("dh");
+
+my $testcount = 2;
+
+plan tests => 2 * $testcount;
+
+SKIP: {
+    skip "TLS 1.3 is disabled", $testcount if disabled("tls1_3");
+    # Run tests with TLS
+    run_tests(0);
+}
+
+SKIP: {
+    skip "DTLS 1.3 is disabled", $testcount if disabled("dtls1_3");
+    skip "DTLSProxy does not work on Windows", $testcount if $^O =~ /^(MSWin32)$/;
+    run_tests(1);
+}
 
 use constant {
     COOKIE_ONLY => 0,
     COOKIE_AND_KEY_SHARE => 1
 };
 
-my $proxy = TLSProxy::Proxy->new(
-    undef,
-    cmdstr(app(["openssl"]), display => 1),
-    srctop_file("apps", "server.pem"),
-    (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
-);
-
 my $cookieseen = 0;
 my $testtype;
 
-#Test 1: Inserting a cookie into an HRR should see it echoed in the ClientHello
-#        (when a key share is required)
-$testtype = COOKIE_AND_KEY_SHARE;
-$proxy->filter(\&cookie_filter);
-if (disabled("ecx")) {
-    $proxy->clientflags("-curves ffdhe3072:ffdhe2048");
-    $proxy->serverflags("-curves ffdhe2048");
-} else {
-    $proxy->clientflags("-curves P-256:X25519");
-    $proxy->serverflags("-curves X25519");
-}
-$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
-plan tests => 2;
-ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
+sub run_tests
+{
+    my $run_test_as_dtls = shift;
+    my $proxy_start_success = 0;
+    my $proxy;
+    if ($run_test_as_dtls == 1) {
+        $proxy = TLSProxy::Proxy->new_dtls(
+            undef,
+            cmdstr(app([ "openssl" ]), display => 1),
+            srctop_file("apps", "server.pem"),
+            (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
+        );
+    }
+    else {
+        $proxy = TLSProxy::Proxy->new(
+            undef,
+            cmdstr(app([ "openssl" ]), display => 1),
+            srctop_file("apps", "server.pem"),
+            (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
+        );
+    }
 
-#Test 2: Inserting a cookie into an HRR should see it echoed in the ClientHello
-#        (without a key share required)
-SKIP: {
-    skip "ECX disabled", 1, if (disabled("ecx"));
-    $testtype = COOKIE_ONLY;
-    $proxy->clear();
-    $proxy->serverflags("-curves X25519");
-    $proxy->clientflags("-curves X25519:secp256r1");
-    $proxy->start();
+    #Test 1: Inserting a cookie into an HRR should see it echoed in the ClientHello
+    #        (when a key share is required)
+    $testtype = COOKIE_AND_KEY_SHARE;
+    $proxy->filter(\&cookie_filter);
+    if (disabled("ecx")) {
+        $proxy->clientflags("-curves ffdhe3072:ffdhe2048");
+        $proxy->serverflags("-curves ffdhe2048");
+    } else {
+        $proxy->clientflags("-curves P-256:X25519");
+        $proxy->serverflags("-curves X25519");
+    }
+    $proxy_start_success = $proxy->start();
+    skip "TLSProxy did not start correctly", $testcount if $proxy_start_success == 0;
     ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
+
+    #Test 2: Inserting a cookie into an HRR should see it echoed in the ClientHello
+    #        (without a key share required)
+    SKIP: {
+        skip "ECX disabled", 1, if (disabled("ecx"));
+        $testtype = COOKIE_ONLY;
+        $proxy->clear();
+        $proxy->serverflags("-curves X25519");
+        $proxy->clientflags("-curves X25519:secp256r1");
+        $proxy->start();
+        ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen");
+    }
 }
 
 sub cookie_filter