Add SCTP testing to 07-dtls-protocol-version.conf
[openssl.git] / test / ssl-tests / protocol_version.pm
index cc39c757c4a066ccf4e5b3064ac4d791317ffc09..ceb5ae0eccb4cb5a126aa8bd97d68ebe3c803fcd 100644 (file)
@@ -17,7 +17,7 @@ use warnings;
 use List::Util qw/max min/;
 
 use OpenSSL::Test;
-use OpenSSL::Test::Utils qw/anydisabled alldisabled/;
+use OpenSSL::Test::Utils qw/anydisabled alldisabled disabled/;
 setup("no_test_here");
 
 my @tls_protocols = ("SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3");
@@ -96,31 +96,35 @@ sub generate_version_tests {
 
     my @tests = ();
 
-    foreach my $c_min (0..$#min_protocols) {
-        my $c_max_min = $c_min == 0 ? 0 : $c_min - 1;
-        foreach my $c_max ($c_max_min..$#max_protocols) {
-            foreach my $s_min (0..$#min_protocols) {
-                my $s_max_min = $s_min == 0 ? 0 : $s_min - 1;
-                foreach my $s_max ($s_max_min..$#max_protocols) {
-                    my ($result, $protocol) =
-                        expected_result($c_min, $c_max, $s_min, $s_max,
-                                        $min_enabled, $max_enabled, \@protocols);
-                    push @tests, {
-                        "name" => "version-negotiation",
-                        "client" => {
-                            "MinProtocol" => $min_protocols[$c_min],
-                            "MaxProtocol" => $max_protocols[$c_max],
-                        },
-                        "server" => {
-                            "MinProtocol" => $min_protocols[$s_min],
-                            "MaxProtocol" => $max_protocols[$s_max],
-                        },
-                        "test" => {
-                            "ExpectedResult" => $result,
-                            "ExpectedProtocol" => $protocol,
-                            "Method" => $method,
-                        }
-                    };
+    for (my $sctp = 0; $sctp < ($dtls && !disabled("sctp") ? 2 : 1); $sctp++) {
+        foreach my $c_min (0..$#min_protocols) {
+            my $c_max_min = $c_min == 0 ? 0 : $c_min - 1;
+            foreach my $c_max ($c_max_min..$#max_protocols) {
+                foreach my $s_min (0..$#min_protocols) {
+                    my $s_max_min = $s_min == 0 ? 0 : $s_min - 1;
+                    foreach my $s_max ($s_max_min..$#max_protocols) {
+                        my ($result, $protocol) =
+                            expected_result($c_min, $c_max, $s_min, $s_max,
+                                            $min_enabled, $max_enabled,
+                                            \@protocols);
+                        push @tests, {
+                            "name" => "version-negotiation",
+                            "client" => {
+                                "MinProtocol" => $min_protocols[$c_min],
+                                "MaxProtocol" => $max_protocols[$c_max],
+                            },
+                            "server" => {
+                                "MinProtocol" => $min_protocols[$s_min],
+                                "MaxProtocol" => $max_protocols[$s_max],
+                            },
+                            "test" => {
+                                "ExpectedResult" => $result,
+                                "ExpectedProtocol" => $protocol,
+                                "Method" => $method,
+                            }
+                        };
+                        $tests[-1]{"test"}{"UseSCTP"} = "Yes" if $sctp;
+                    }
                 }
             }
         }
@@ -203,6 +207,25 @@ sub generate_resumption_tests {
         }
     }
 
+    if (!disabled("tls1_3") && !$dtls) {
+        push @client_tests, {
+            "name" => "resumption-with-hrr",
+            "client" => {
+            },
+            "server" => {
+                "Curves" => "P-256"
+            },
+            "resume_client" => {
+            },
+            "test" => {
+                "ExpectedProtocol" => "TLSv1.3",
+                "Method" => "TLS",
+                "HandshakeMode" => "Resume",
+                "ResumptionExpected" => "Yes",
+            }
+        };
+    }
+
     return (@server_tests, @client_tests);
 }
 
@@ -225,9 +248,7 @@ sub expected_result {
 
     if ($c_min > $c_max) {
         # Client should fail to even send a hello.
-        # This results in an internal error since the server will be
-        # waiting for input that never arrives.
-        return ("InternalError", undef);
+        return ("ClientFail", undef);
     } elsif ($s_min > $s_max) {
         # Server has no protocols, should always fail.
         return ("ServerFail", undef);