]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Move OPENSSL_add_builtin back into provider.c
authorMatt Caswell <matt@openssl.org>
Tue, 22 Jun 2021 11:07:48 +0000 (12:07 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 24 Jun 2021 13:48:15 +0000 (14:48 +0100)
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)

crypto/provider.c
crypto/provider_core.c

index 6b5b7beefec4fdfb8129656d5bab1efc5e4efe6a..c8db329837c0332818d67e41fe2e5c87467fb2b9 100644 (file)
@@ -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);
index 35d54721802f401a2a3494afebfee664e0f3ea45..1878ffab7c5104e3df88882858a91f041015b2a5 100644 (file)
@@ -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)
 {