[openssl] master update

Matt Caswell matt at openssl.org
Thu May 20 09:01:04 UTC 2021


The branch master has been updated
       via  e0113b79f2f6fd9dcdfb6bbd1bc77cb41a44b5de (commit)
      from  4edb29b77e0298e2e524a403214ce3455db6a69b (commit)


- Log -----------------------------------------------------------------
commit e0113b79f2f6fd9dcdfb6bbd1bc77cb41a44b5de
Author: Pauli <pauli at openssl.org>
Date:   Tue May 18 18:45:31 2021 +1000

    app: add a -store_loaders option to list.
    
    Fixes #15307
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    Reviewed-by: Tomas Mraz <tomas at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/15323)

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

Summary of changes:
 apps/list.c                  | 65 +++++++++++++++++++++++++++++++++++++++++++-
 doc/man1/openssl-list.pod.in |  5 ++++
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/apps/list.c b/apps/list.c
index b0a1b6a0c5..6ffc36b9e2 100644
--- a/apps/list.c
+++ b/apps/list.c
@@ -18,6 +18,7 @@
 #include <openssl/kdf.h>
 #include <openssl/encoder.h>
 #include <openssl/decoder.h>
+#include <openssl/store.h>
 #include <openssl/core_names.h>
 #include <openssl/rand.h>
 #include "apps.h"
@@ -1186,6 +1187,60 @@ static void list_pkey_meth(void)
     list_kems();
 }
 
+DEFINE_STACK_OF(OSSL_STORE_LOADER)
+static int store_cmp(const OSSL_STORE_LOADER * const *a,
+                     const OSSL_STORE_LOADER * const *b)
+{
+    int ret = OSSL_STORE_LOADER_number(*a) - OSSL_STORE_LOADER_number(*b);
+
+    if (ret == 0)
+        ret = strcmp(OSSL_PROVIDER_name(OSSL_STORE_LOADER_provider(*a)),
+                     OSSL_PROVIDER_name(OSSL_STORE_LOADER_provider(*b)));
+
+    return ret;
+}
+
+static void collect_store_loaders(OSSL_STORE_LOADER *store, void *stack)
+{
+    STACK_OF(OSSL_STORE_LOADER) *store_stack = stack;
+
+    if (sk_OSSL_STORE_LOADER_push(store_stack, store) > 0)
+        OSSL_STORE_LOADER_up_ref(store);
+}
+
+static void list_store_loaders(void)
+{
+    STACK_OF(OSSL_STORE_LOADER) *stores = sk_OSSL_STORE_LOADER_new(store_cmp);
+    int i;
+
+    if (stores == NULL) {
+        BIO_printf(bio_err, "ERROR: Memory allocation\n");
+        return;
+    }
+    BIO_printf(bio_out, "Provided STORE LOADERs:\n");
+    OSSL_STORE_LOADER_do_all_provided(NULL, collect_store_loaders, stores);
+    sk_OSSL_STORE_LOADER_sort(stores);
+    for (i = 0; i < sk_OSSL_STORE_LOADER_num(stores); i++) {
+        const OSSL_STORE_LOADER *m = sk_OSSL_STORE_LOADER_value(stores, i);
+        STACK_OF(OPENSSL_CSTRING) *names = NULL;
+
+        if (select_name != NULL && !OSSL_STORE_LOADER_is_a(m, select_name))
+            continue;
+
+        names = sk_OPENSSL_CSTRING_new(name_cmp);
+        if (names != NULL && OSSL_STORE_LOADER_names_do_all(m, collect_names,
+                                                            names)) {
+            BIO_printf(bio_out, "  ");
+            print_names(bio_out, names);
+
+            BIO_printf(bio_out, " @ %s\n",
+                       OSSL_PROVIDER_name(OSSL_STORE_LOADER_provider(m)));
+        }
+        sk_OPENSSL_CSTRING_free(names);
+    }
+    sk_OSSL_STORE_LOADER_pop_free(stores, OSSL_STORE_LOADER_free);
+}
+
 DEFINE_STACK_OF(OSSL_PROVIDER)
 static int provider_cmp(const OSSL_PROVIDER * const *a,
                         const OSSL_PROVIDER * const *b)
@@ -1423,7 +1478,7 @@ typedef enum HELPLIST_CHOICE {
     OPT_KDF_ALGORITHMS, OPT_RANDOM_INSTANCES, OPT_RANDOM_GENERATORS,
     OPT_ENCODERS, OPT_DECODERS, OPT_KEYMANAGERS, OPT_KEYEXCHANGE_ALGORITHMS,
     OPT_KEM_ALGORITHMS, OPT_SIGNATURE_ALGORITHMS, OPT_ASYM_CIPHER_ALGORITHMS,
-    OPT_PROVIDER_INFO,
+    OPT_STORE_LOADERS, OPT_PROVIDER_INFO,
     OPT_OBJECTS, OPT_SELECT_NAME,
 #ifndef OPENSSL_NO_DEPRECATED_3_0
     OPT_ENGINES, 
@@ -1477,6 +1532,8 @@ const OPTIONS list_options[] = {
      "List of public key algorithms"},
     {"public-key-methods", OPT_PK_METHOD, '-',
      "List of public key methods"},
+    {"store-loaders", OPT_STORE_LOADERS, '-',
+     "List of store loaders"},
     {"providers", OPT_PROVIDER_INFO, '-',
      "List of provider information"},
 #ifndef OPENSSL_NO_DEPRECATED_3_0
@@ -1517,6 +1574,7 @@ int list_main(int argc, char **argv)
         unsigned int asym_cipher_algorithms:1;
         unsigned int pk_algorithms:1;
         unsigned int pk_method:1;
+        unsigned int store_loaders:1;
         unsigned int provider_info:1;
 #ifndef OPENSSL_NO_DEPRECATED_3_0
         unsigned int engines:1;
@@ -1596,6 +1654,9 @@ opthelp:
         case OPT_PK_METHOD:
             todo.pk_method = 1;
             break;
+        case OPT_STORE_LOADERS:
+            todo.store_loaders = 1;
+            break;
         case OPT_PROVIDER_INFO:
             todo.provider_info = 1;
             break;
@@ -1667,6 +1728,8 @@ opthelp:
         list_pkey();
     if (todo.pk_method)
         list_pkey_meth();
+    if (todo.store_loaders)
+        list_store_loaders();
     if (todo.provider_info)
         list_provider_info();
 #ifndef OPENSSL_NO_DEPRECATED_3_0
diff --git a/doc/man1/openssl-list.pod.in b/doc/man1/openssl-list.pod.in
index 7ece8c3031..03ffb32806 100644
--- a/doc/man1/openssl-list.pod.in
+++ b/doc/man1/openssl-list.pod.in
@@ -35,6 +35,7 @@ B<openssl list>
 [B<-asymcipher-algorithms>]
 [B<-public-key-algorithms>]
 [B<-public-key-methods>]
+[B<-store-loaders>]
 [B<-providers>]
 {- output_off() if $disabled{"deprecated-3.0"}; ""
 -}[B<-engines>]
@@ -162,6 +163,10 @@ Display a list of signature algorithms.
 
 Display a list of asymmetric cipher algorithms.
 
+=item B<-store-loaders>
+
+Display a list of store loaders.
+
 =item B<-providers>
 
 Display a list of all loaded providers with their names, version and status.


More information about the openssl-commits mailing list