70-test_sslmessages.t: Don't check EXT_SIG_ALGS if TLS 1.2 is disabled
[openssl.git] / test / recipes / 70-test_sslmessages.t
index 2476fb1..9221529 100755 (executable)
@@ -46,6 +46,9 @@ my $proxy = TLSProxy::Proxy->new(
     [TLSProxy::Message::MT_CERTIFICATE,
         checkhandshake::ALL_HANDSHAKES
         & ~checkhandshake::RESUME_HANDSHAKE],
     [TLSProxy::Message::MT_CERTIFICATE,
         checkhandshake::ALL_HANDSHAKES
         & ~checkhandshake::RESUME_HANDSHAKE],
+    (disabled("ec") ? () :
+                      [TLSProxy::Message::MT_SERVER_KEY_EXCHANGE,
+                          checkhandshake::EC_HANDSHAKE]),
     [TLSProxy::Message::MT_CERTIFICATE_STATUS,
         checkhandshake::OCSP_HANDSHAKE],
     #ServerKeyExchange handshakes not currently supported by TLSProxy
     [TLSProxy::Message::MT_CERTIFICATE_STATUS,
         checkhandshake::OCSP_HANDSHAKE],
     #ServerKeyExchange handshakes not currently supported by TLSProxy
@@ -94,12 +97,17 @@ my $proxy = TLSProxy::Proxy->new(
         checkhandshake::SERVER_NAME_CLI_EXTENSION],
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_STATUS_REQUEST,
         checkhandshake::STATUS_REQUEST_CLI_EXTENSION],
         checkhandshake::SERVER_NAME_CLI_EXTENSION],
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_STATUS_REQUEST,
         checkhandshake::STATUS_REQUEST_CLI_EXTENSION],
-    [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SUPPORTED_GROUPS,
-        checkhandshake::DEFAULT_EXTENSIONS],
-    [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_EC_POINT_FORMATS,
-        checkhandshake::DEFAULT_EXTENSIONS],
-    [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SIG_ALGS,
-        checkhandshake::DEFAULT_EXTENSIONS],
+    (disabled("ec") ? () :
+                      [TLSProxy::Message::MT_CLIENT_HELLO,
+                       TLSProxy::Message::EXT_SUPPORTED_GROUPS,
+                       checkhandshake::DEFAULT_EXTENSIONS]),
+    (disabled("ec") ? () :
+                      [TLSProxy::Message::MT_CLIENT_HELLO,
+                       TLSProxy::Message::EXT_EC_POINT_FORMATS,
+                       checkhandshake::DEFAULT_EXTENSIONS]),
+    (disabled("tls1_2") ? () :
+     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SIG_ALGS,
+         checkhandshake::DEFAULT_EXTENSIONS]),
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ALPN,
         checkhandshake::ALPN_CLI_EXTENSION],
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SCT,
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ALPN,
         checkhandshake::ALPN_CLI_EXTENSION],
     [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SCT,
@@ -135,6 +143,8 @@ my $proxy = TLSProxy::Proxy->new(
         checkhandshake::SCT_SRV_EXTENSION],
     [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_NPN,
         checkhandshake::NPN_SRV_EXTENSION],
         checkhandshake::SCT_SRV_EXTENSION],
     [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_NPN,
         checkhandshake::NPN_SRV_EXTENSION],
+    [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_EC_POINT_FORMATS,
+        checkhandshake::EC_POINT_FORMAT_SRV_EXTENSION],
     [0,0,0]
 );
 
     [0,0,0]
 );
 
@@ -143,7 +153,7 @@ my $proxy = TLSProxy::Proxy->new(
 $proxy->serverconnects(2);
 $proxy->clientflags("-no_tls1_3 -sess_out ".$session);
 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
 $proxy->serverconnects(2);
 $proxy->clientflags("-no_tls1_3 -sess_out ".$session);
 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
-plan tests => 20;
+plan tests => 21;
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
                "Default handshake test");
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
                "Default handshake test");
@@ -163,9 +173,9 @@ $proxy->clear();
 $proxy->clientflags("-no_tls1_3 -status");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
 $proxy->clientflags("-no_tls1_3 -status");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::STATUS_REQUEST_CLI_EXTENSION,
-              "status_request handshake test (client)");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::STATUS_REQUEST_CLI_EXTENSION,
+               "status_request handshake test (client)");
 
 #Test 4: A status_request handshake (server support only)
 $proxy->clear();
 
 #Test 4: A status_request handshake (server support only)
 $proxy->clear();
@@ -175,7 +185,7 @@ $proxy->serverflags("-status_file "
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
-              "status_request handshake test (server)");
+               "status_request handshake test (server)");
 
 #Test 5: A status_request handshake (client and server)
 $proxy->clear();
 
 #Test 5: A status_request handshake (client and server)
 $proxy->clear();
@@ -184,10 +194,10 @@ $proxy->serverflags("-status_file "
                     .srctop_file("test", "recipes", "ocsp-response.der"));
 $proxy->start();
 checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
                     .srctop_file("test", "recipes", "ocsp-response.der"));
 $proxy->start();
 checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
-              | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
-              "status_request handshake test");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
+               | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
+               "status_request handshake test");
 
 #Test 6: A client auth handshake
 $proxy->clear();
 
 #Test 6: A client auth handshake
 $proxy->clear();
@@ -214,7 +224,7 @@ $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS
                | checkhandshake::SERVER_NAME_CLI_EXTENSION,
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS
                | checkhandshake::SERVER_NAME_CLI_EXTENSION,
-              "Server name handshake test (client)");
+               "Server name handshake test (client)");
 
 #Test 9: Server name handshake (server support only)
 $proxy->clear();
 
 #Test 9: Server name handshake (server support only)
 $proxy->clear();
@@ -223,7 +233,7 @@ $proxy->serverflags("-servername testhost");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
-              "Server name handshake test (server)");
+               "Server name handshake test (server)");
 
 #Test 10: Server name handshake (client and server)
 $proxy->clear();
 
 #Test 10: Server name handshake (client and server)
 $proxy->clear();
@@ -231,10 +241,10 @@ $proxy->clientflags("-no_tls1_3 -servername testhost");
 $proxy->serverflags("-servername testhost");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
 $proxy->serverflags("-servername testhost");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::SERVER_NAME_CLI_EXTENSION
-              | checkhandshake::SERVER_NAME_SRV_EXTENSION,
-              "Server name handshake test");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::SERVER_NAME_CLI_EXTENSION
+               | checkhandshake::SERVER_NAME_SRV_EXTENSION,
+               "Server name handshake test");
 
 #Test 11: ALPN handshake (client request only)
 $proxy->clear();
 
 #Test 11: ALPN handshake (client request only)
 $proxy->clear();
@@ -243,7 +253,7 @@ $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS
                | checkhandshake::ALPN_CLI_EXTENSION,
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS
                | checkhandshake::ALPN_CLI_EXTENSION,
-              "ALPN handshake test (client)");
+               "ALPN handshake test (client)");
 
 #Test 12: ALPN handshake (server support only)
 $proxy->clear();
 
 #Test 12: ALPN handshake (server support only)
 $proxy->clear();
@@ -252,7 +262,7 @@ $proxy->serverflags("-alpn test");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                checkhandshake::DEFAULT_EXTENSIONS,
-              "ALPN handshake test (server)");
+               "ALPN handshake test (server)");
 
 #Test 13: ALPN handshake (client and server)
 $proxy->clear();
 
 #Test 13: ALPN handshake (client and server)
 $proxy->clear();
@@ -260,24 +270,29 @@ $proxy->clientflags("-no_tls1_3 -alpn test");
 $proxy->serverflags("-alpn test");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
 $proxy->serverflags("-alpn test");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::ALPN_CLI_EXTENSION
-              | checkhandshake::ALPN_SRV_EXTENSION,
-              "ALPN handshake test");
-
-#Test 14: SCT handshake (client request only)
-$proxy->clear();
-#Note: -ct also sends status_request
-$proxy->clientflags("-no_tls1_3 -ct");
-$proxy->serverflags("-status_file "
-                    .srctop_file("test", "recipes", "ocsp-response.der"));
-$proxy->start();
-checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::SCT_CLI_EXTENSION
-              | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
-              | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
-              "SCT handshake test (client)");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::ALPN_CLI_EXTENSION
+               | checkhandshake::ALPN_SRV_EXTENSION,
+               "ALPN handshake test");
+
+SKIP: {
+    skip "No CT and/or EC support in this OpenSSL build", 1
+        if disabled("ct") || disabled("ec");
+
+    #Test 14: SCT handshake (client request only)
+    $proxy->clear();
+    #Note: -ct also sends status_request
+    $proxy->clientflags("-no_tls1_3 -ct");
+    $proxy->serverflags("-status_file "
+                        .srctop_file("test", "recipes", "ocsp-response.der"));
+    $proxy->start();
+    checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
+                   checkhandshake::DEFAULT_EXTENSIONS
+                   | checkhandshake::SCT_CLI_EXTENSION
+                   | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
+                   | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
+                   "SCT handshake test (client)");
+}
 
 #Test 15: SCT handshake (server support only)
 $proxy->clear();
 
 #Test 15: SCT handshake (server support only)
 $proxy->clear();
@@ -287,26 +302,31 @@ $proxy->serverflags("-status_file "
                     .srctop_file("test", "recipes", "ocsp-response.der"));
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
                     .srctop_file("test", "recipes", "ocsp-response.der"));
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS,
-              "SCT handshake test (server)");
-
-#Test 16: SCT handshake (client and server)
-#There is no built-in server side support for this so we are actually also
-#testing custom extensions here
-$proxy->clear();
-#Note: -ct also sends status_request
-$proxy->clientflags("-no_tls1_3 -ct");
-$proxy->serverflags("-status_file "
-                    .srctop_file("test", "recipes", "ocsp-response.der")
-                    ." -serverinfo ".srctop_file("test", "serverinfo.pem"));
-$proxy->start();
-checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::SCT_CLI_EXTENSION
-              | checkhandshake::SCT_SRV_EXTENSION
-              | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
-              | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
-              "SCT handshake test");
+               checkhandshake::DEFAULT_EXTENSIONS,
+               "SCT handshake test (server)");
+
+SKIP: {
+    skip "No CT and/or EC support in this OpenSSL build", 1
+        if disabled("ct") || disabled("ec");
+
+    #Test 16: SCT handshake (client and server)
+    #There is no built-in server side support for this so we are actually also
+    #testing custom extensions here
+    $proxy->clear();
+    #Note: -ct also sends status_request
+    $proxy->clientflags("-no_tls1_3 -ct");
+    $proxy->serverflags("-status_file "
+                        .srctop_file("test", "recipes", "ocsp-response.der")
+                        ." -serverinfo ".srctop_file("test", "serverinfo.pem"));
+    $proxy->start();
+    checkhandshake($proxy, checkhandshake::OCSP_HANDSHAKE,
+                   checkhandshake::DEFAULT_EXTENSIONS
+                   | checkhandshake::SCT_CLI_EXTENSION
+                   | checkhandshake::SCT_SRV_EXTENSION
+                   | checkhandshake::STATUS_REQUEST_CLI_EXTENSION
+                   | checkhandshake::STATUS_REQUEST_SRV_EXTENSION,
+                   "SCT handshake test");
+}
 
 
 #Test 17: NPN handshake (client request only)
 
 
 #Test 17: NPN handshake (client request only)
@@ -333,10 +353,10 @@ $proxy->clientflags("-no_tls1_3 -nextprotoneg test");
 $proxy->serverflags("-nextprotoneg test");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::NPN_HANDSHAKE,
 $proxy->serverflags("-nextprotoneg test");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::NPN_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::NPN_CLI_EXTENSION
-              | checkhandshake::NPN_SRV_EXTENSION,
-              "NPN handshake test");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::NPN_CLI_EXTENSION
+               | checkhandshake::NPN_SRV_EXTENSION,
+               "NPN handshake test");
 
 #Test 20: SRP extension
 #Note: We are not actually going to perform an SRP handshake (TLSProxy does not
 
 #Test 20: SRP extension
 #Note: We are not actually going to perform an SRP handshake (TLSProxy does not
@@ -347,6 +367,19 @@ $proxy->clear();
 $proxy->clientflags("-no_tls1_3 -srpuser user -srppass pass:pass");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
 $proxy->clientflags("-no_tls1_3 -srpuser user -srppass pass:pass");
 $proxy->start();
 checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
-              checkhandshake::DEFAULT_EXTENSIONS
-              | checkhandshake::SRP_CLI_EXTENSION,
-              "SRP extension test");
+               checkhandshake::DEFAULT_EXTENSIONS
+               | checkhandshake::SRP_CLI_EXTENSION,
+               "SRP extension test");
+
+#Test 21: EC handshake
+SKIP: {
+    skip "No EC support in this OpenSSL build", 1 if disabled("ec");
+    $proxy->clear();
+    $proxy->clientflags("-no_tls1_3");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->start();
+    checkhandshake($proxy, checkhandshake::EC_HANDSHAKE,
+                   checkhandshake::DEFAULT_EXTENSIONS
+                   | checkhandshake::EC_POINT_FORMAT_SRV_EXTENSION,
+                   "EC handshake test");
+}