test: update ssl_new tests in line with pedantic FIPS policy
authorPauli <pauli@openssl.org>
Tue, 18 Apr 2023 04:41:17 +0000 (14:41 +1000)
committerHugo Landau <hlandau@openssl.org>
Fri, 21 Apr 2023 16:01:38 +0000 (17:01 +0100)
Add a new option to the `test' section of SSL test data structure.
This contains a space separated list of version checks, all of which must
pass.

Note that the version checks are as they as because:

- 3.1.0 doesn't have mandatory EMS support, so it can run the old tests.
- 3.1.1 (& later) will have mandatory EMS support, so they can't run them.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20762)

test/helpers/ssl_test_ctx.c
test/helpers/ssl_test_ctx.h
test/ssl-tests/30-extended-master-secret.cnf
test/ssl-tests/30-extended-master-secret.cnf.in
test/ssl_test.c

index 1919481b02ab3de9a3ca7be177acdd89372fc6be..c7777f8f075167020ff1dc864ad975eb91dba930 100644 (file)
@@ -652,6 +652,9 @@ IMPLEMENT_SSL_TEST_BOOL_OPTION(SSL_TEST_CLIENT_CONF, client, enable_pha)
 IMPLEMENT_SSL_TEST_BOOL_OPTION(SSL_TEST_SERVER_CONF, server, force_pha)
 IMPLEMENT_SSL_TEST_BOOL_OPTION(SSL_TEST_CLIENT_CONF, client, no_extms_on_reneg)
 
+/* FIPS provider version limiting */
+IMPLEMENT_SSL_TEST_STRING_OPTION(SSL_TEST_CTX, test, fips_version)
+
 /* Known test options and their corresponding parse methods. */
 
 /* Top-level options. */
@@ -692,6 +695,7 @@ static const ssl_test_ctx_option ssl_test_ctx_options[] = {
     { "EnableServerSCTPLabelBug", &parse_test_enable_server_sctp_label_bug },
     { "ExpectedCipher", &parse_test_expected_cipher },
     { "ExpectedSessionTicketAppData", &parse_test_expected_session_ticket_app_data },
+    { "FIPSversion", &parse_test_fips_version },
 };
 
 /* Nested client options. */
@@ -781,6 +785,7 @@ void SSL_TEST_CTX_free(SSL_TEST_CTX *ctx)
     sk_X509_NAME_pop_free(ctx->expected_server_ca_names, X509_NAME_free);
     sk_X509_NAME_pop_free(ctx->expected_client_ca_names, X509_NAME_free);
     OPENSSL_free(ctx->expected_cipher);
+    OPENSSL_free(ctx->fips_version);
     OPENSSL_free(ctx);
 }
 
index 4baf657f6da1b1c3aaf061d4d510b6882544f558..982d15a5c30a42596785c81cd1e8576425a83154 100644 (file)
@@ -231,6 +231,9 @@ typedef struct {
     char *expected_session_ticket_app_data;
 
     OSSL_LIB_CTX *libctx;
+
+    /* FIPS version string to check for compatibility */
+    char *fips_version;
 } SSL_TEST_CTX;
 
 const char *ssl_test_result_name(ssl_test_result_t result);
index 9dae431d21f5e2fc11bbc14786410496739f726d..6c118a54ca816e3b08adbfb43ad3fe703ba373d7 100644 (file)
@@ -32,6 +32,7 @@ VerifyMode = Peer
 
 [test-0]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
 # ===========================================================
@@ -57,6 +58,7 @@ VerifyMode = Peer
 
 [test-1]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
 # ===========================================================
@@ -83,6 +85,7 @@ VerifyMode = Peer
 
 [test-2]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
 # ===========================================================
@@ -122,6 +125,7 @@ VerifyMode = Peer
 
 [test-3]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 HandshakeMode = Resume
 
 
@@ -148,6 +152,7 @@ VerifyMode = Peer
 
 [test-4]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
 # ===========================================================
@@ -173,6 +178,7 @@ VerifyMode = Peer
 
 [test-5]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
 # ===========================================================
@@ -199,5 +205,6 @@ VerifyMode = Peer
 
 [test-6]
 ExpectedResult = Success
+FIPSversion = <=3.1.0
 
 
index 281718e6b5501bb52c57e9cbd455a9e96dad3e4f..40f4df3308462006d60ab42786a971c0be353b48 100644 (file)
@@ -27,6 +27,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -40,6 +41,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -54,6 +56,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -75,6 +78,7 @@ my @tests_tls1_2 = (
         test   => {
          "HandshakeMode" => "Resume",
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -88,6 +92,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -101,6 +106,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
     {
@@ -115,6 +121,7 @@ my @tests_tls1_2 = (
         },
         test   => {
           "ExpectedResult" => "Success",
+          "FIPSversion" => "<=3.1.0",
         },
     },
 );
index eac86ccecf6e5174c351a10342f7fffe1bb230c8..2795909820bd6a257fc86444dcb5b87694685abc 100644 (file)
@@ -409,6 +409,13 @@ static int test_handshake(int idx)
     if (!TEST_ptr(test_ctx))
         goto err;
 
+    /* Verify that the FIPS provider supports this test */
+    if (test_ctx->fips_version != NULL
+                && !fips_provider_version_match(libctx, test_ctx->fips_version)) {
+            ret = TEST_skip("FIPS provider unable to run this test");
+            goto err;
+    }
+
 #ifndef OPENSSL_NO_DTLS
     if (test_ctx->method == SSL_TEST_METHOD_DTLS) {
         server_ctx = SSL_CTX_new_ex(libctx, NULL, DTLS_server_method());