]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove flag_couldbechild
authorMatt Caswell <matt@openssl.org>
Mon, 21 Jun 2021 10:06:12 +0000 (11:06 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 24 Jun 2021 13:48:14 +0000 (14:48 +0100)
Now that a provider is no longer put into the store until after it has
been activated we don't need flag_couldbechild any more. This flag was
used to indicate whether a provider was eligible for conversion into a
child provider or not. This was only really interesting for predefined
providers that were automatically created.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15854)

crypto/provider_child.c
crypto/provider_core.c
include/internal/provider.h

index e808eafe24d1a69487b2ad30d53e720f858fa35f..cabf3ba19df93380868ab84eadaa77da5c7713c7 100644 (file)
@@ -133,13 +133,11 @@ static int provider_create_child_cb(const OSSL_CORE_HANDLE *prov, void *cbdata)
         ossl_provider_free(cprov);
 
         /*
-         * The provider already exists. It could be an unused built-in, or a
-         * previously created child, or it could have been explicitly loaded. If
-         * explicitly loaded it cannot be converted to a child and we ignore it
-         * - i.e. we don't start treating it like a child.
+         * The provider already exists. It could be a previously created child,
+         * or it could have been explicitly loaded. If explicitly loaded we
+         * ignore it - i.e. we don't start treating it like a child.
          */
-        if (!ossl_provider_convert_to_child(cprov, prov,
-                                            ossl_child_provider_init))
+        if (!ossl_provider_activate_child(cprov, prov, ossl_child_provider_init))
             goto err;
     } else {
         /*
index 393aa006ca47116d4ad04956ed9a0e0c6d0e207f..62fab92028d1270ae2c148a387695bdde43d3580 100644 (file)
@@ -55,9 +55,6 @@ struct ossl_provider_st {
     unsigned int flag_initialized:1;
     unsigned int flag_activated:1;
     unsigned int flag_fallback:1; /* Can be used as fallback */
-#ifndef FIPS_MODULE
-    unsigned int flag_couldbechild:1;
-#endif
 
     /* Getting and setting the flags require synchronization */
     CRYPTO_RWLOCK *flag_lock;
@@ -407,9 +404,6 @@ static OSSL_PROVIDER *provider_new(const char *name,
 
     prov->refcnt = 1; /* 1 One reference to be returned */
     prov->init_function = init_function;
-#ifndef FIPS_MODULE
-    prov->flag_couldbechild = 1;
-#endif
 
     return prov;
 }
@@ -796,9 +790,6 @@ static int provider_init(OSSL_PROVIDER *prov, int flag_lock)
     }
     prov->provctx = tmp_provctx;
     prov->dispatch = provider_dispatch;
-#ifndef FIPS_MODULE
-    prov->flag_couldbechild = 0;
-#endif
 
     for (; provider_dispatch->function_id != 0; provider_dispatch++) {
         switch (provider_dispatch->function_id) {
@@ -1478,9 +1469,9 @@ int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle)
     return 1;
 }
 
-int ossl_provider_convert_to_child(OSSL_PROVIDER *prov,
-                                   const OSSL_CORE_HANDLE *handle,
-                                   OSSL_provider_init_fn *init_function)
+int ossl_provider_activate_child(OSSL_PROVIDER *prov,
+                                 const OSSL_CORE_HANDLE *handle,
+                                 OSSL_provider_init_fn *init_function)
 {
     int flush = 0;
 
@@ -1491,14 +1482,9 @@ int ossl_provider_convert_to_child(OSSL_PROVIDER *prov,
         return 0;
     }
     /*
-     * The provider could be in one of three states: (1) Already a child,
-     * (2) Not a child (but eligible to be one), or (3) Not a child (not
-     * eligible to be one).
+     * The provider could be in one of two states: (1) Already a child,
+     * (2) Not a child (not eligible to be one).
      */
-    if (prov->flag_couldbechild) {
-        ossl_provider_set_child(prov, handle);
-        prov->init_function = init_function;
-    }
     if (prov->ischild && provider_activate(prov, 0, 0)) {
         flush = 1;
         prov->store->use_fallbacks = 0;
@@ -1511,9 +1497,9 @@ int ossl_provider_convert_to_child(OSSL_PROVIDER *prov,
         provider_flush_store_cache(prov);
 
     /*
-     * We report success whether or not the provider was eligible for conversion
-     * to a child. If its not elgibile then it has already been loaded as a non
-     * child provider and we should keep it like that.
+     * We report success whether or not the provider was a child. If its not
+     * a child then it has been explicitly loaded as a non child provider and
+     * we should keep it like that.
      */
     return 1;
 }
index 127ea2d2c576b03d25fb4aa6a93b8e63eaf7cd0c..45ad1a5b00b4a30e3a2e41d2d84233eef99a9639 100644 (file)
@@ -44,9 +44,9 @@ int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name,
 
 int ossl_provider_is_child(const OSSL_PROVIDER *prov);
 int ossl_provider_set_child(OSSL_PROVIDER *prov, const OSSL_CORE_HANDLE *handle);
-int ossl_provider_convert_to_child(OSSL_PROVIDER *prov,
-                                   const OSSL_CORE_HANDLE *handle,
-                                   OSSL_provider_init_fn *init_function);
+int ossl_provider_activate_child(OSSL_PROVIDER *prov,
+                                 const OSSL_CORE_HANDLE *handle,
+                                 OSSL_provider_init_fn *init_function);
 const OSSL_CORE_HANDLE *ossl_provider_get_parent(OSSL_PROVIDER *prov);
 int ossl_provider_up_ref_parent(OSSL_PROVIDER *prov, int activate);
 int ossl_provider_free_parent(OSSL_PROVIDER *prov, int deactivate);