[openssl] master update

Dr. Paul Dale pauli at openssl.org
Tue Jul 6 00:55:44 UTC 2021


The branch master has been updated
       via  866376432bc403adbdb447830d0a33ffcd5fb0fa (commit)
      from  e54f0c9b2fe3dd2dcb5e8100e2c69e5b2f6eb681 (commit)


- Log -----------------------------------------------------------------
commit 866376432bc403adbdb447830d0a33ffcd5fb0fa
Author: Shane Lontis <shane.lontis at oracle.com>
Date:   Fri Jun 25 12:01:13 2021 +1000

    Add test for provider gettables
    
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    Reviewed-by: Paul Dale <pauli at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15970)

-----------------------------------------------------------------------

Summary of changes:
 test/provider_status_test.c            | 74 ++++++++++++++++++++++++++++++----
 test/recipes/30-test_provider_status.t | 29 ++++++++++---
 2 files changed, 90 insertions(+), 13 deletions(-)

diff --git a/test/provider_status_test.c b/test/provider_status_test.c
index fb52fa67f0..551277c8e0 100644
--- a/test/provider_status_test.c
+++ b/test/provider_status_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -103,6 +103,43 @@ static int self_test_on_load(const OSSL_PARAM params[], void *arg)
     return self_test_events(params, arg, "On Loading", 0);
 }
 
+static int get_provider_params(const OSSL_PROVIDER *prov)
+{
+    int ret = 0;
+    OSSL_PARAM params[5];
+    char *name, *version, *buildinfo;
+    int status;
+    const OSSL_PARAM *gettable, *p;
+
+    if (!TEST_ptr(gettable = OSSL_PROVIDER_gettable_params(prov))
+        || !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_NAME))
+        || !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_VERSION))
+        || !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_STATUS))
+        || !TEST_ptr(p = OSSL_PARAM_locate_const(gettable, OSSL_PROV_PARAM_BUILDINFO)))
+        goto end;
+
+    params[0] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_NAME, &name, 0);
+    params[1] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_VERSION,
+                                              &version, 0);
+    params[2] = OSSL_PARAM_construct_int(OSSL_PROV_PARAM_STATUS, &status);
+    params[3] = OSSL_PARAM_construct_utf8_ptr(OSSL_PROV_PARAM_BUILDINFO,
+                                              &buildinfo, 0);
+    params[4] = OSSL_PARAM_construct_end();
+    OSSL_PARAM_set_all_unmodified(params);
+    if (!TEST_true(OSSL_PROVIDER_get_params(prov, params)))
+        goto end;
+    if (!TEST_true(OSSL_PARAM_modified(params + 0))
+        || !TEST_true(OSSL_PARAM_modified(params + 1))
+        || !TEST_true(OSSL_PARAM_modified(params + 2))
+        || !TEST_true(OSSL_PARAM_modified(params + 3))
+        || !TEST_true(status == 1))
+        goto end;
+
+    ret = 1;
+end:
+    return ret;
+}
+
 static int test_provider_status(void)
 {
     int ret = 0;
@@ -113,6 +150,8 @@ static int test_provider_status(void)
 
     if (!TEST_ptr(prov = OSSL_PROVIDER_load(libctx, provider_name)))
         goto err;
+    if (!get_provider_params(prov))
+        goto err;
 
     /* Test that the provider status is ok */
     params[0] = OSSL_PARAM_construct_uint(OSSL_PROV_PARAM_STATUS, &status);
@@ -149,6 +188,18 @@ err:
     return ret;
 }
 
+static int test_provider_gettable_params(void)
+{
+    OSSL_PROVIDER *prov;
+    int ret;
+
+    if (!TEST_ptr(prov = OSSL_PROVIDER_load(libctx, provider_name)))
+        return 0;
+    ret = get_provider_params(prov);
+    OSSL_PROVIDER_unload(prov);
+    return ret;
+}
+
 int setup_tests(void)
 {
     OPTION_CHOICE o;
@@ -173,13 +224,22 @@ int setup_tests(void)
     libctx = OSSL_LIB_CTX_new();
     if (libctx == NULL)
         return 0;
-    self_test_args.count = 0;
-    OSSL_SELF_TEST_set_callback(libctx, self_test_on_load, &self_test_args);
 
-    if (!OSSL_LIB_CTX_load_config(libctx, config_file)) {
-        opt_printf_stderr("Failed to load config\n");
-        return 0;
+    if (strcmp(provider_name, "fips") == 0) {
+        self_test_args.count = 0;
+        OSSL_SELF_TEST_set_callback(libctx, self_test_on_load, &self_test_args);
+        if (!OSSL_LIB_CTX_load_config(libctx, config_file)) {
+            opt_printf_stderr("Failed to load config\n");
+            return 0;
+        }
+        ADD_TEST(test_provider_status);
+    } else {
+        ADD_TEST(test_provider_gettable_params);
     }
-    ADD_TEST(test_provider_status);
     return 1;
 }
+
+void cleanup_tests(void)
+{
+    OSSL_LIB_CTX_free(libctx);
+}
diff --git a/test/recipes/30-test_provider_status.t b/test/recipes/30-test_provider_status.t
index b3a239fb6a..2b2e242a5f 100644
--- a/test/recipes/30-test_provider_status.t
+++ b/test/recipes/30-test_provider_status.t
@@ -22,11 +22,28 @@ use lib bldtop_dir('.');
 
 my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
 
-plan skip_all => "provider_status is not supported by this test"
-    if $no_fips;
+plan tests => 5;
 
-plan tests => 1;
+ok(run(test(["provider_status_test", "-provider_name", "null"])),
+   "null provider test");
 
-ok(run(test(["provider_status_test", "-config", srctop_file("test","fips.cnf"),
-             "-provider_name", "fips"])),
-   "running provider_status_test");
+ok(run(test(["provider_status_test", "-provider_name", "base"])),
+   "base provider test");
+
+ok(run(test(["provider_status_test", "-provider_name", "default"])),
+   "default provider test");
+
+SKIP: {
+    skip "Skipping legacy test", 1
+        if disabled("legacy");
+    ok(run(test(["provider_status_test", "-provider_name", "legacy"])),
+       "legacy provider test");
+}
+
+SKIP: {
+    skip "Skipping fips test", 1
+        if $no_fips;
+    ok(run(test(["provider_status_test", "-config", srctop_file("test","fips.cnf"),
+                 "-provider_name", "fips"])),
+       "fips provider test");
+}


More information about the openssl-commits mailing list