STORE: add ENGINE information to loaders
authorRichard Levitte <levitte@openssl.org>
Sun, 11 Dec 2016 06:02:06 +0000 (07:02 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 29 Jun 2017 09:55:32 +0000 (11:55 +0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3542)

crypto/store/loader_file.c
crypto/store/store_locl.h
crypto/store/store_register.c
include/openssl/store.h
util/libcrypto.num

index 27af752..446f60c 100644 (file)
@@ -1041,6 +1041,7 @@ static int file_close(OSSL_STORE_LOADER_CTX *ctx)
 static OSSL_STORE_LOADER file_loader =
     {
         "file",
+        NULL,
         file_open,
         NULL,
         file_load,
index 5797a36..a954c57 100644 (file)
@@ -72,6 +72,7 @@ OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme);
 /* loader stuff */
 struct ossl_store_loader_st {
     const char *scheme;
+    ENGINE *engine;
     OSSL_STORE_open_fn open;
     OSSL_STORE_ctrl_fn ctrl;
     OSSL_STORE_load_fn load;
index a138edc..bde190e 100644 (file)
@@ -28,7 +28,7 @@ DEFINE_RUN_ONCE_STATIC(do_registry_init)
  *  Functions for manipulating OSSL_STORE_LOADERs
  */
 
-OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(const char *scheme)
+OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme)
 {
     OSSL_STORE_LOADER *res = OPENSSL_zalloc(sizeof(*res));
 
@@ -49,10 +49,16 @@ OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(const char *scheme)
         return NULL;
     }
 
+    res->engine = e;
     res->scheme = scheme;
     return res;
 }
 
+const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader)
+{
+    return loader->engine;
+}
+
 const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader)
 {
     return loader->scheme;
@@ -257,3 +263,16 @@ void ossl_store_destroy_loaders_int(void)
     CRYPTO_THREAD_lock_free(registry_lock);
     registry_lock = NULL;
 }
+
+/*
+ *  Functions to list OSSL_STORE loaders
+ */
+
+IMPLEMENT_LHASH_DOALL_ARG_CONST(OSSL_STORE_LOADER, void);
+int OSSL_STORE_do_all_loaders(void (*do_function) (const OSSL_STORE_LOADER
+                                                   *loader, void *do_arg),
+                              void *do_arg)
+{
+    lh_OSSL_STORE_LOADER_doall_void(loader_register, do_function, do_arg);
+    return 1;
+}
index 35f62ec..d3947df 100644 (file)
@@ -159,7 +159,8 @@ void OSSL_STORE_INFO_free(OSSL_STORE_INFO *info);
  */
 
 typedef struct ossl_store_loader_st OSSL_STORE_LOADER;
-OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(const char *scheme);
+OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);
+const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader);
 const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader);
 /* struct ossl_store_loader_ctx_st is defined differently by each loader */
 typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;
@@ -193,6 +194,14 @@ void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader);
 int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);
 OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);
 
+/*-
+ *  Functions to list STORE loaders
+ *  -------------------------------
+ */
+int OSSL_STORE_do_all_loaders(void (*do_function) (const OSSL_STORE_LOADER
+                                                   *loader, void *do_arg),
+                              void *do_arg);
+
 
 /*
  * Error strings
index 3c651ed..d734461 100644 (file)
@@ -4340,3 +4340,5 @@ OSSL_STORE_ctrl                         4282      1_1_1   EXIST::FUNCTION:
 OSSL_STORE_INFO_get0_NAME_description   4283   1_1_1   EXIST::FUNCTION:
 OSSL_STORE_INFO_set0_NAME_description   4284   1_1_1   EXIST::FUNCTION:
 OSSL_STORE_INFO_get1_NAME_description   4285   1_1_1   EXIST::FUNCTION:
+OSSL_STORE_do_all_loaders               4286   1_1_1   EXIST::FUNCTION:
+OSSL_STORE_LOADER_get0_engine           4287   1_1_1   EXIST::FUNCTION: