diff options
author | Matt Caswell <matt@openssl.org> | 2021-06-22 12:07:48 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-06-24 14:48:15 +0100 |
commit | d382c4652570766fc7a9ccfc63e7a62aea3d5bcb (patch) | |
tree | 60b988e85a8c5286f556598e46b3a172d91487bd /crypto | |
parent | 29d46e09ce0e66b5dc8faecfa48d5f667217302e (diff) |
Move OPENSSL_add_builtin back into provider.c
An earlier stage of the refactor in the last few commits moved this
function out of provider.c because it needed access to the provider
structure internals. The final version however no longer needs this so
it is moved back again.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15854)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/provider.c | 25 | ||||
-rw-r--r-- | crypto/provider_core.c | 23 |
2 files changed, 25 insertions, 23 deletions
diff --git a/crypto/provider.c b/crypto/provider.c index 6b5b7beefe..c8db329837 100644 --- a/crypto/provider.c +++ b/crypto/provider.c @@ -7,11 +7,13 @@ * https://www.openssl.org/source/license.html */ +#include <string.h> #include <openssl/err.h> #include <openssl/cryptoerr.h> #include <openssl/provider.h> #include <openssl/core_names.h> #include "internal/provider.h" +#include "provider_local.h" OSSL_PROVIDER *OSSL_PROVIDER_try_load(OSSL_LIB_CTX *libctx, const char *name, int retain_fallbacks) @@ -103,6 +105,29 @@ int OSSL_PROVIDER_get_capabilities(const OSSL_PROVIDER *prov, return ossl_provider_get_capabilities(prov, capability, cb, arg); } +int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *libctx, const char *name, + OSSL_provider_init_fn *init_fn) +{ + OSSL_PROVIDER_INFO entry; + + if (name == NULL || init_fn == NULL) { + ERR_raise(ERR_LIB_CRYPTO, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + memset(&entry, 0, sizeof(entry)); + entry.name = OPENSSL_strdup(name); + if (entry.name == NULL) { + ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); + return 0; + } + entry.init = init_fn; + if (!ossl_provider_info_add_to_store(libctx, &entry)) { + ossl_provider_info_clear(&entry); + return 0; + } + return 1; +} + const char *OSSL_PROVIDER_get0_name(const OSSL_PROVIDER *prov) { return ossl_provider_name(prov); diff --git a/crypto/provider_core.c b/crypto/provider_core.c index 35d5472180..1878ffab7c 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -319,29 +319,6 @@ int ossl_provider_info_add_to_store(OSSL_LIB_CTX *libctx, return ret; } -int OSSL_PROVIDER_add_builtin(OSSL_LIB_CTX *libctx, const char *name, - OSSL_provider_init_fn *init_fn) -{ - OSSL_PROVIDER_INFO entry; - - if (name == NULL || init_fn == NULL) { - ERR_raise(ERR_LIB_CRYPTO, ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - memset(&entry, 0, sizeof(entry)); - entry.name = OPENSSL_strdup(name); - if (entry.name == NULL) { - ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); - return 0; - } - entry.init = init_fn; - if (!ossl_provider_info_add_to_store(libctx, &entry)) { - ossl_provider_info_clear(&entry); - return 0; - } - return 1; -} - OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name, int noconfig) { |