From d5fbd5b4eda592fd43e8688f69f3bac4ca5dd2da Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 21 Jun 2021 11:06:12 +0100 Subject: Remove flag_couldbechild 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15854) --- crypto/provider_child.c | 10 ++++------ crypto/provider_core.c | 30 ++++++++---------------------- 2 files changed, 12 insertions(+), 28 deletions(-) (limited to 'crypto') diff --git a/crypto/provider_child.c b/crypto/provider_child.c index e808eafe24..cabf3ba19d 100644 --- a/crypto/provider_child.c +++ b/crypto/provider_child.c @@ -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 { /* diff --git a/crypto/provider_core.c b/crypto/provider_core.c index 393aa006ca..62fab92028 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -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; } -- cgit v1.2.3