From 9bdb0c3185a3985a1b78bb9b93c75de5bb06c966 Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 28 Jul 2023 09:46:36 +0000 Subject: [PATCH] Drop DSO and define OPENSSL_NO_DSO DSO and in particular dlopen() was used for dynamic engines, which we removed a long time ago and for dynamic conf modules, which we removed only very recently. Now remove this dangerous interface. ok jsing --- lib/libcrypto/Makefile | 13 +- lib/libcrypto/Symbols.list | 25 -- lib/libcrypto/Symbols.namespace | 25 -- lib/libcrypto/dso/dso.h | 382 ----------------------- lib/libcrypto/dso/dso_dlfcn.c | 355 --------------------- lib/libcrypto/dso/dso_err.c | 106 ------- lib/libcrypto/dso/dso_lib.c | 474 ----------------------------- lib/libcrypto/dso/dso_null.c | 75 ----- lib/libcrypto/dso/dso_openssl.c | 76 ----- lib/libcrypto/err/err_all.c | 4 +- lib/libcrypto/hidden/openssl/dso.h | 54 ---- lib/libcrypto/opensslfeatures.h | 4 +- 12 files changed, 5 insertions(+), 1588 deletions(-) delete mode 100644 lib/libcrypto/dso/dso.h delete mode 100644 lib/libcrypto/dso/dso_dlfcn.c delete mode 100644 lib/libcrypto/dso/dso_err.c delete mode 100644 lib/libcrypto/dso/dso_lib.c delete mode 100644 lib/libcrypto/dso/dso_null.c delete mode 100644 lib/libcrypto/dso/dso_openssl.c diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index abcd91d0efe..9067c5673e3 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.144 2023/07/28 09:42:44 tb Exp $ +# $OpenBSD: Makefile,v 1.145 2023/07/28 09:46:36 tb Exp $ LIB= crypto LIBREBUILD=y @@ -25,7 +25,7 @@ CFLAGS+= -DLIBRESSL_NAMESPACE -DLIBRESSL_CRYPTO_NAMESPACE .if !defined(NOPIC) -CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN +CFLAGS+= -DHAVE_FUNOPEN .endif # Hardware engines @@ -318,13 +318,6 @@ SRCS+= dsa_ossl.c SRCS+= dsa_pmeth.c SRCS+= dsa_prn.c -# dso/ -SRCS+= dso_dlfcn.c -SRCS+= dso_err.c -SRCS+= dso_lib.c -SRCS+= dso_null.c -SRCS+= dso_openssl.c - # ec/ SRCS+= ec_ameth.c SRCS+= ec_asn1.c @@ -713,7 +706,6 @@ SRCS+= x_all.c ${LCRYPTO_SRC}/des \ ${LCRYPTO_SRC}/dh \ ${LCRYPTO_SRC}/dsa \ - ${LCRYPTO_SRC}/dso \ ${LCRYPTO_SRC}/ec \ ${LCRYPTO_SRC}/ecdh \ ${LCRYPTO_SRC}/ecdsa \ @@ -774,7 +766,6 @@ HDRS=\ ${LCRYPTO_SRC}/des/des.h \ ${LCRYPTO_SRC}/dh/dh.h \ ${LCRYPTO_SRC}/dsa/dsa.h \ - ${LCRYPTO_SRC}/dso/dso.h \ ${LCRYPTO_SRC}/ec/ec.h \ ${LCRYPTO_SRC}/ecdh/ecdh.h \ ${LCRYPTO_SRC}/ecdsa/ecdsa.h \ diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index b6ee286c6f3..8b35d5ca44d 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -979,30 +979,6 @@ DSAparams_dup DSAparams_it DSAparams_print DSAparams_print_fp -DSO_METHOD_dlfcn -DSO_METHOD_null -DSO_METHOD_openssl -DSO_bind_func -DSO_bind_var -DSO_convert_filename -DSO_ctrl -DSO_flags -DSO_free -DSO_get_default_method -DSO_get_filename -DSO_get_loaded_filename -DSO_get_method -DSO_global_lookup -DSO_load -DSO_merge -DSO_new -DSO_new_method -DSO_pathbyaddr -DSO_set_default_method -DSO_set_filename -DSO_set_method -DSO_set_name_converter -DSO_up_ref ECDH_compute_key ECDH_size ECDSA_SIG_free @@ -1309,7 +1285,6 @@ ERR_load_CONF_strings ERR_load_CRYPTO_strings ERR_load_DH_strings ERR_load_DSA_strings -ERR_load_DSO_strings ERR_load_EC_strings ERR_load_ENGINE_strings ERR_load_ERR_strings diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 57727a186ee..adaac43146f 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -1776,31 +1776,6 @@ _libre_lh_node_usage_stats_bio _libre_SM3_Init _libre_SM3_Update _libre_SM3_Final -_libre_DSO_new -_libre_DSO_new_method -_libre_DSO_free -_libre_DSO_flags -_libre_DSO_up_ref -_libre_DSO_ctrl -_libre_DSO_set_name_converter -_libre_DSO_get_filename -_libre_DSO_set_filename -_libre_DSO_convert_filename -_libre_DSO_merge -_libre_DSO_get_loaded_filename -_libre_DSO_set_default_method -_libre_DSO_get_default_method -_libre_DSO_get_method -_libre_DSO_set_method -_libre_DSO_load -_libre_DSO_bind_var -_libre_DSO_bind_func -_libre_DSO_METHOD_openssl -_libre_DSO_METHOD_null -_libre_DSO_METHOD_dlfcn -_libre_DSO_pathbyaddr -_libre_DSO_global_lookup -_libre_ERR_load_DSO_strings _libre_CT_POLICY_EVAL_CTX_new _libre_CT_POLICY_EVAL_CTX_free _libre_CT_POLICY_EVAL_CTX_get0_cert diff --git a/lib/libcrypto/dso/dso.h b/lib/libcrypto/dso/dso.h deleted file mode 100644 index c3963a8e01d..00000000000 --- a/lib/libcrypto/dso/dso.h +++ /dev/null @@ -1,382 +0,0 @@ -/* $OpenBSD: dso.h,v 1.14 2022/12/26 07:18:51 jmc Exp $ */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#ifndef HEADER_DSO_H -#define HEADER_DSO_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* These values are used as commands to DSO_ctrl() */ -#define DSO_CTRL_GET_FLAGS 1 -#define DSO_CTRL_SET_FLAGS 2 -#define DSO_CTRL_OR_FLAGS 3 - -/* By default, DSO_load() will translate the provided filename into a form - * typical for the platform (more specifically the DSO_METHOD) using the - * dso_name_converter function of the method. Eg. win32 will transform "blah" - * into "blah.dll", and dlfcn will transform it into "libblah.so". The - * behaviour can be overridden by setting the name_converter callback in the DSO - * object (using DSO_set_name_converter()). This callback could even utilise - * the DSO_METHOD's converter too if it only wants to override behaviour for - * one or two possible DSO methods. However, the following flag can be set in a - * DSO to prevent *any* native name-translation at all - eg. if the caller has - * prompted the user for a path to a driver library so the filename should be - * interpreted as-is. */ -#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 -/* An extra flag to give if only the extension should be added as - * translation. This is obviously only of importance on Unix and - * other operating systems where the translation also may prefix - * the name with something, like 'lib', and ignored everywhere else. - * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used - * at the same time. */ -#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 - -/* The following flag controls the translation of symbol names to upper - * case. This is currently only being implemented for OpenVMS. - */ -#define DSO_FLAG_UPCASE_SYMBOL 0x10 - -/* This flag loads the library with public symbols. - * Meaning: The exported symbols of this library are public - * to all libraries loaded after this library. - * At the moment only implemented in unix. - */ -#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 - - -typedef void (*DSO_FUNC_TYPE)(void); - -typedef struct dso_st DSO; - -/* The function prototype used for method functions (or caller-provided - * callbacks) that transform filenames. They are passed a DSO structure pointer - * (or NULL if they are to be used independently of a DSO object) and a - * filename to transform. They should either return NULL (if there is an error - * condition) or a newly allocated string containing the transformed form that - * the caller will need to free with free() when done. */ -typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); -/* The function prototype used for method functions (or caller-provided - * callbacks) that merge two file specifications. They are passed a - * DSO structure pointer (or NULL if they are to be used independently of - * a DSO object) and two file specifications to merge. They should - * either return NULL (if there is an error condition) or a newly allocated - * string containing the result of merging that the caller will need - * to free with free() when done. - * Here, merging means that bits and pieces are taken from each of the - * file specifications and added together in whatever fashion that is - * sensible for the DSO method in question. The only rule that really - * applies is that if the two specification contain pieces of the same - * type, the copy from the first string takes priority. One could see - * it as the first specification is the one given by the user and the - * second being a bunch of defaults to add on if they're missing in the - * first. */ -typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); - -typedef struct dso_meth_st { - const char *name; - /* Loads a shared library, NB: new DSO_METHODs must ensure that a - * successful load populates the loaded_filename field, and likewise a - * successful unload frees and NULLs it out. */ - int (*dso_load)(DSO *dso); - /* Unloads a shared library */ - int (*dso_unload)(DSO *dso); - /* Binds a variable */ - void *(*dso_bind_var)(DSO *dso, const char *symname); - /* Binds a function - assumes a return type of DSO_FUNC_TYPE. - * This should be cast to the real function prototype by the - * caller. Platforms that don't have compatible representations - * for different prototypes (this is possible within ANSI C) - * are highly unlikely to have shared libraries at all, let - * alone a DSO_METHOD implemented for them. */ - DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); - - /* The generic (yuck) "ctrl()" function. NB: Negative return - * values (rather than zero) indicate errors. */ - long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); - /* The default DSO_METHOD-specific function for converting filenames to - * a canonical native form. */ - DSO_NAME_CONVERTER_FUNC dso_name_converter; - /* The default DSO_METHOD-specific function for converting filenames to - * a canonical native form. */ - DSO_MERGER_FUNC dso_merger; - - /* [De]Initialisation handlers. */ - int (*init)(DSO *dso); - int (*finish)(DSO *dso); - - /* Return pathname of the module containing location */ - int (*pathbyaddr)(void *addr, char *path, int sz); - /* Perform global symbol lookup, i.e. among *all* modules */ - void *(*globallookup)(const char *symname); -} DSO_METHOD; - -/**********************************************************************/ -/* The low-level handle type used to refer to a loaded shared library */ - -struct dso_st { - DSO_METHOD *meth; - /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS - * doesn't use anything but will need to cache the filename - * for use in the dso_bind handler. All in all, let each - * method control its own destiny. "Handles" and such go in - * a STACK. */ - STACK_OF(void) *meth_data; - int references; - int flags; - /* For use by applications etc ... use this for your bits'n'pieces, - * don't touch meth_data! */ - CRYPTO_EX_DATA ex_data; - /* If this callback function pointer is set to non-NULL, then it will - * be used in DSO_load() in place of meth->dso_name_converter. NB: This - * should normally set using DSO_set_name_converter(). */ - DSO_NAME_CONVERTER_FUNC name_converter; - /* If this callback function pointer is set to non-NULL, then it will - * be used in DSO_load() in place of meth->dso_merger. NB: This - * should normally set using DSO_set_merger(). */ - DSO_MERGER_FUNC merger; - /* This is populated with (a copy of) the platform-independant - * filename used for this DSO. */ - char *filename; - /* This is populated with (a copy of) the translated filename by which - * the DSO was actually loaded. It is NULL iff the DSO is not currently - * loaded. NB: This is here because the filename translation process - * may involve a callback being invoked more than once not only to - * convert to a platform-specific form, but also to try different - * filenames in the process of trying to perform a load. As such, this - * variable can be used to indicate (a) whether this DSO structure - * corresponds to a loaded library or not, and (b) the filename with - * which it was actually loaded. */ - char *loaded_filename; -}; - - -DSO * DSO_new(void); -DSO * DSO_new_method(DSO_METHOD *method); -int DSO_free(DSO *dso); -int DSO_flags(DSO *dso); -int DSO_up_ref(DSO *dso); -long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); - -/* This function sets the DSO's name_converter callback. If it is non-NULL, - * then it will be used instead of the associated DSO_METHOD's function. If - * oldcb is non-NULL then it is set to the function pointer value being - * replaced. Return value is non-zero for success. */ -int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, - DSO_NAME_CONVERTER_FUNC *oldcb); -/* These functions can be used to get/set the platform-independant filename - * used for a DSO. NB: set will fail if the DSO is already loaded. */ -const char *DSO_get_filename(DSO *dso); -int DSO_set_filename(DSO *dso, const char *filename); -/* This function will invoke the DSO's name_converter callback to translate a - * filename, or if the callback isn't set it will instead use the DSO_METHOD's - * converter. If "filename" is NULL, the "filename" in the DSO itself will be - * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is - * simply duplicated. NB: This function is usually called from within a - * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that - * caller-created DSO_METHODs can do the same thing. A non-NULL return value - * will need to be free()'d. */ -char *DSO_convert_filename(DSO *dso, const char *filename); -/* This function will invoke the DSO's merger callback to merge two file - * specifications, or if the callback isn't set it will instead use the - * DSO_METHOD's merger. A non-NULL return value will need to be - * free()'d. */ -char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); -/* If the DSO is currently loaded, this returns the filename that it was loaded - * under, otherwise it returns NULL. So it is also useful as a test as to - * whether the DSO is currently loaded. NB: This will not necessarily return - * the same value as DSO_convert_filename(dso, dso->filename), because the - * DSO_METHOD's load function may have tried a variety of filenames (with - * and/or without the aid of the converters) before settling on the one it - * actually loaded. */ -const char *DSO_get_loaded_filename(DSO *dso); - -void DSO_set_default_method(DSO_METHOD *meth); -DSO_METHOD *DSO_get_default_method(void); -DSO_METHOD *DSO_get_method(DSO *dso); -DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); - -/* The all-singing all-dancing load function, you normally pass NULL - * for the first and third parameters. Use DSO_up and DSO_free for - * subsequent reference count handling. Any flags passed in will be set - * in the constructed DSO after its init() function but before the - * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ -DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); - -/* This function binds to a variable inside a shared library. */ -void *DSO_bind_var(DSO *dso, const char *symname); - -/* This function binds to a function inside a shared library. */ -DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); - -/* This method is the default, but will beg, borrow, or steal whatever - * method should be the default on any particular platform (including - * DSO_METH_null() if necessary). */ -DSO_METHOD *DSO_METHOD_openssl(void); - -/* This method is defined for all platforms - if a platform has no - * DSO support then this will be the only method! */ -DSO_METHOD *DSO_METHOD_null(void); - -/* If DSO_DLFCN is defined, the standard dlfcn.h-style functions - * (dlopen, dlclose, dlsym, etc) will be used and incorporated into - * this method. If not, this method will return NULL. */ -DSO_METHOD *DSO_METHOD_dlfcn(void); - -/* This function writes null-terminated pathname of DSO module - * containing 'addr' into 'sz' large caller-provided 'path' and - * returns the number of characters [including trailing zero] - * written to it. If 'sz' is 0 or negative, 'path' is ignored and - * required amount of characters [including trailing zero] to - * accommodate pathname is returned. If 'addr' is NULL, then - * pathname of cryptolib itself is returned. Negative or zero - * return value denotes error. - */ -int DSO_pathbyaddr(void *addr, char *path, int sz); - -/* This function should be used with caution! It looks up symbols in - * *all* loaded modules and if module gets unloaded by somebody else - * attempt to dereference the pointer is doomed to have fatal - * consequences. Primary usage for this function is to probe *core* - * system functionality, e.g. check if getnameinfo(3) is available - * at run-time without bothering about OS-specific details such as - * libc.so.versioning or where does it actually reside: in libc - * itself or libsocket. */ -void *DSO_global_lookup(const char *name); - -void ERR_load_DSO_strings(void); - -/* Error codes for the DSO functions. */ - -/* Function codes. */ -#define DSO_F_BEOS_BIND_FUNC 144 -#define DSO_F_BEOS_BIND_VAR 145 -#define DSO_F_BEOS_LOAD 146 -#define DSO_F_BEOS_NAME_CONVERTER 147 -#define DSO_F_BEOS_UNLOAD 148 -#define DSO_F_DLFCN_BIND_FUNC 100 -#define DSO_F_DLFCN_BIND_VAR 101 -#define DSO_F_DLFCN_LOAD 102 -#define DSO_F_DLFCN_MERGER 130 -#define DSO_F_DLFCN_NAME_CONVERTER 123 -#define DSO_F_DLFCN_UNLOAD 103 -#define DSO_F_DL_BIND_FUNC 104 -#define DSO_F_DL_BIND_VAR 105 -#define DSO_F_DL_LOAD 106 -#define DSO_F_DL_MERGER 131 -#define DSO_F_DL_NAME_CONVERTER 124 -#define DSO_F_DL_UNLOAD 107 -#define DSO_F_DSO_BIND_FUNC 108 -#define DSO_F_DSO_BIND_VAR 109 -#define DSO_F_DSO_CONVERT_FILENAME 126 -#define DSO_F_DSO_CTRL 110 -#define DSO_F_DSO_FREE 111 -#define DSO_F_DSO_GET_FILENAME 127 -#define DSO_F_DSO_GET_LOADED_FILENAME 128 -#define DSO_F_DSO_GLOBAL_LOOKUP 139 -#define DSO_F_DSO_LOAD 112 -#define DSO_F_DSO_MERGE 132 -#define DSO_F_DSO_NEW_METHOD 113 -#define DSO_F_DSO_PATHBYADDR 140 -#define DSO_F_DSO_SET_FILENAME 129 -#define DSO_F_DSO_SET_NAME_CONVERTER 122 -#define DSO_F_DSO_UP_REF 114 -#define DSO_F_GLOBAL_LOOKUP_FUNC 138 -#define DSO_F_PATHBYADDR 137 -#define DSO_F_VMS_BIND_SYM 115 -#define DSO_F_VMS_LOAD 116 -#define DSO_F_VMS_MERGER 133 -#define DSO_F_VMS_UNLOAD 117 -#define DSO_F_WIN32_BIND_FUNC 118 -#define DSO_F_WIN32_BIND_VAR 119 -#define DSO_F_WIN32_GLOBALLOOKUP 142 -#define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143 -#define DSO_F_WIN32_JOINER 135 -#define DSO_F_WIN32_LOAD 120 -#define DSO_F_WIN32_MERGER 134 -#define DSO_F_WIN32_NAME_CONVERTER 125 -#define DSO_F_WIN32_PATHBYADDR 141 -#define DSO_F_WIN32_SPLITTER 136 -#define DSO_F_WIN32_UNLOAD 121 - -/* Reason codes. */ -#define DSO_R_CTRL_FAILED 100 -#define DSO_R_DSO_ALREADY_LOADED 110 -#define DSO_R_EMPTY_FILE_STRUCTURE 113 -#define DSO_R_FAILURE 114 -#define DSO_R_FILENAME_TOO_BIG 101 -#define DSO_R_FINISH_FAILED 102 -#define DSO_R_INCORRECT_FILE_SYNTAX 115 -#define DSO_R_LOAD_FAILED 103 -#define DSO_R_NAME_TRANSLATION_FAILED 109 -#define DSO_R_NO_FILENAME 111 -#define DSO_R_NO_FILE_SPECIFICATION 116 -#define DSO_R_NULL_HANDLE 104 -#define DSO_R_SET_FILENAME_FAILED 112 -#define DSO_R_STACK_ERROR 105 -#define DSO_R_SYM_FAILURE 106 -#define DSO_R_UNLOAD_FAILED 107 -#define DSO_R_UNSUPPORTED 108 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libcrypto/dso/dso_dlfcn.c b/lib/libcrypto/dso/dso_dlfcn.c deleted file mode 100644 index 77c19aa27ea..00000000000 --- a/lib/libcrypto/dso/dso_dlfcn.c +++ /dev/null @@ -1,355 +0,0 @@ -/* $OpenBSD: dso_dlfcn.c,v 1.30 2023/07/08 07:22:58 beck Exp $ */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include -#include - -#include -#include - -#ifndef DSO_DLFCN -DSO_METHOD * -DSO_METHOD_dlfcn(void) -{ - return NULL; -} -LCRYPTO_ALIAS(DSO_METHOD_dlfcn); -#else - -#ifdef HAVE_DLFCN_H -# include -# define HAVE_DLINFO 1 -#endif - -/* Part of the hack in "dlfcn_load" ... */ -#define DSO_MAX_TRANSLATED_SIZE 256 - -static int dlfcn_load(DSO *dso); -static int dlfcn_unload(DSO *dso); -static void *dlfcn_bind_var(DSO *dso, const char *symname); -static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname); -static char *dlfcn_name_converter(DSO *dso, const char *filename); -static char *dlfcn_merger(DSO *dso, const char *filespec1, - const char *filespec2); -static int dlfcn_pathbyaddr(void *addr, char *path, int sz); -static void *dlfcn_globallookup(const char *name); - -static DSO_METHOD dso_meth_dlfcn = { - .name = "OpenSSL 'dlfcn' shared library method", - .dso_load = dlfcn_load, - .dso_unload = dlfcn_unload, - .dso_bind_var = dlfcn_bind_var, - .dso_bind_func = dlfcn_bind_func, - .dso_name_converter = dlfcn_name_converter, - .dso_merger = dlfcn_merger, - .pathbyaddr = dlfcn_pathbyaddr, - .globallookup = dlfcn_globallookup -}; - -DSO_METHOD * -DSO_METHOD_dlfcn(void) -{ - return (&dso_meth_dlfcn); -} -LCRYPTO_ALIAS(DSO_METHOD_dlfcn); - -/* For this DSO_METHOD, our meth_data STACK will contain; - * (i) the handle (void*) returned from dlopen(). - */ - -static int -dlfcn_load(DSO *dso) -{ - void *ptr = NULL; - /* See applicable comments in dso_dl.c */ - char *filename = DSO_convert_filename(dso, NULL); - int flags = RTLD_LAZY; - - if (filename == NULL) { - DSOerror(DSO_R_NO_FILENAME); - goto err; - } - - if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) - flags |= RTLD_GLOBAL; - ptr = dlopen(filename, flags); - if (ptr == NULL) { - DSOerror(DSO_R_LOAD_FAILED); - ERR_asprintf_error_data("filename(%s): %s", filename, - dlerror()); - goto err; - } - if (!sk_void_push(dso->meth_data, (char *)ptr)) { - DSOerror(DSO_R_STACK_ERROR); - goto err; - } - /* Success */ - dso->loaded_filename = filename; - return (1); - -err: - /* Cleanup! */ - free(filename); - if (ptr != NULL) - dlclose(ptr); - return (0); -} - -static int -dlfcn_unload(DSO *dso) -{ - void *ptr; - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (0); - } - if (sk_void_num(dso->meth_data) < 1) - return (1); - ptr = sk_void_pop(dso->meth_data); - if (ptr == NULL) { - DSOerror(DSO_R_NULL_HANDLE); - /* Should push the value back onto the stack in - * case of a retry. */ - sk_void_push(dso->meth_data, ptr); - return (0); - } - /* For now I'm not aware of any errors associated with dlclose() */ - dlclose(ptr); - return (1); -} - -static void * -dlfcn_bind_var(DSO *dso, const char *symname) -{ - void *ptr, *sym; - - if ((dso == NULL) || (symname == NULL)) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if (sk_void_num(dso->meth_data) < 1) { - DSOerror(DSO_R_STACK_ERROR); - return (NULL); - } - ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); - if (ptr == NULL) { - DSOerror(DSO_R_NULL_HANDLE); - return (NULL); - } - sym = dlsym(ptr, symname); - if (sym == NULL) { - DSOerror(DSO_R_SYM_FAILURE); - ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); - return (NULL); - } - return (sym); -} - -static DSO_FUNC_TYPE -dlfcn_bind_func(DSO *dso, const char *symname) -{ - void *ptr; - union { - DSO_FUNC_TYPE sym; - void *dlret; - } u; - - if ((dso == NULL) || (symname == NULL)) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if (sk_void_num(dso->meth_data) < 1) { - DSOerror(DSO_R_STACK_ERROR); - return (NULL); - } - ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); - if (ptr == NULL) { - DSOerror(DSO_R_NULL_HANDLE); - return (NULL); - } - u.dlret = dlsym(ptr, symname); - if (u.dlret == NULL) { - DSOerror(DSO_R_SYM_FAILURE); - ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); - return (NULL); - } - return u.sym; -} - -static char * -dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2) -{ - char *merged; - - if (!filespec1 && !filespec2) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - /* If the first file specification is a rooted path, it rules. - same goes if the second file specification is missing. */ - if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { - merged = strdup(filespec1); - if (!merged) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } - } - /* If the first file specification is missing, the second one rules. */ - else if (!filespec1) { - merged = strdup(filespec2); - if (!merged) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } - } else - /* This part isn't as trivial as it looks. It assumes that - the second file specification really is a directory, and - makes no checks whatsoever. Therefore, the result becomes - the concatenation of filespec2 followed by a slash followed - by filespec1. */ - { - size_t spec2len, len; - - spec2len = strlen(filespec2); - len = spec2len + (filespec1 ? strlen(filespec1) : 0); - - if (filespec2 && filespec2[spec2len - 1] == '/') { - spec2len--; - len--; - } - merged = malloc(len + 2); - if (!merged) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } - strlcpy(merged, filespec2, len + 2); - merged[spec2len] = '/'; - strlcpy(&merged[spec2len + 1], filespec1, len + 1 - spec2len); - } - return (merged); -} - -#define DSO_ext ".so" -#define DSO_extlen 3 - -static char * -dlfcn_name_converter(DSO *dso, const char *filename) -{ - char *translated; - int ret; - - if (strchr(filename, '/') == NULL) { - /* Bare name, so convert to "%s.so" or "lib%s.so" */ - if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) - ret = asprintf(&translated, "lib%s" DSO_ext, filename); - else - ret = asprintf(&translated, "%s" DSO_ext, filename); - if (ret == -1) - translated = NULL; - } else { - /* Full path, so just duplicate it */ - translated = strdup(filename); - } - - if (translated == NULL) - DSOerror(DSO_R_NAME_TRANSLATION_FAILED); - return (translated); -} - -static int -dlfcn_pathbyaddr(void *addr, char *path, int sz) -{ - Dl_info dli; - int len; - - if (addr == NULL) { - union{ - int(*f)(void*, char*, int); - void *p; - } t = { dlfcn_pathbyaddr }; - addr = t.p; - } - - if (dladdr(addr, &dli)) { - len = (int)strlen(dli.dli_fname); - if (sz <= 0) - return len + 1; - if (len >= sz) - len = sz - 1; - memcpy(path, dli.dli_fname, len); - path[len++] = 0; - return len; - } - - ERR_asprintf_error_data("dlfcn_pathbyaddr(): %s", dlerror()); - return -1; -} - -static void * -dlfcn_globallookup(const char *name) -{ - void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY); - - if (handle) { - ret = dlsym(handle, name); - dlclose(handle); - } - - return ret; -} -#endif /* DSO_DLFCN */ diff --git a/lib/libcrypto/dso/dso_err.c b/lib/libcrypto/dso/dso_err.c deleted file mode 100644 index 9dec8a66b7b..00000000000 --- a/lib/libcrypto/dso/dso_err.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: dso_err.c,v 1.11 2023/07/08 07:22:58 beck Exp $ */ -/* ==================================================================== - * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#include - -#include -#include - -#ifndef OPENSSL_NO_ERR - -#define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSO,func,0) -#define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason) - -static ERR_STRING_DATA DSO_str_functs[]= { - {ERR_FUNC(0xfff), "CRYPTO_internal"}, - {0, NULL} -}; - -static ERR_STRING_DATA DSO_str_reasons[]= { - {ERR_REASON(DSO_R_CTRL_FAILED) , "control command failed"}, - {ERR_REASON(DSO_R_DSO_ALREADY_LOADED) , "dso already loaded"}, - {ERR_REASON(DSO_R_EMPTY_FILE_STRUCTURE) , "empty file structure"}, - {ERR_REASON(DSO_R_FAILURE) , "failure"}, - {ERR_REASON(DSO_R_FILENAME_TOO_BIG) , "filename too big"}, - {ERR_REASON(DSO_R_FINISH_FAILED) , "cleanup method function failed"}, - {ERR_REASON(DSO_R_INCORRECT_FILE_SYNTAX) , "incorrect file syntax"}, - {ERR_REASON(DSO_R_LOAD_FAILED) , "could not load the shared library"}, - {ERR_REASON(DSO_R_NAME_TRANSLATION_FAILED), "name translation failed"}, - {ERR_REASON(DSO_R_NO_FILENAME) , "no filename"}, - {ERR_REASON(DSO_R_NO_FILE_SPECIFICATION) , "no file specification"}, - {ERR_REASON(DSO_R_NULL_HANDLE) , "a null shared library handle was used"}, - {ERR_REASON(DSO_R_SET_FILENAME_FAILED) , "set filename failed"}, - {ERR_REASON(DSO_R_STACK_ERROR) , "the meth_data stack is corrupt"}, - {ERR_REASON(DSO_R_SYM_FAILURE) , "could not bind to the requested symbol name"}, - {ERR_REASON(DSO_R_UNLOAD_FAILED) , "could not unload the shared library"}, - {ERR_REASON(DSO_R_UNSUPPORTED) , "functionality not supported"}, - {0, NULL} -}; - -#endif - -void -ERR_load_DSO_strings(void) -{ -#ifndef OPENSSL_NO_ERR - if (ERR_func_error_string(DSO_str_functs[0].error) == NULL) { - ERR_load_strings(0, DSO_str_functs); - ERR_load_strings(0, DSO_str_reasons); - } -#endif -} -LCRYPTO_ALIAS(ERR_load_DSO_strings); diff --git a/lib/libcrypto/dso/dso_lib.c b/lib/libcrypto/dso/dso_lib.c deleted file mode 100644 index ca762f68dc0..00000000000 --- a/lib/libcrypto/dso/dso_lib.c +++ /dev/null @@ -1,474 +0,0 @@ -/* $OpenBSD: dso_lib.c,v 1.21 2023/07/08 07:22:58 beck Exp $ */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include -#include - -#include -#include -#include - -static DSO_METHOD *default_DSO_meth = NULL; - -DSO * -DSO_new(void) -{ - return (DSO_new_method(NULL)); -} -LCRYPTO_ALIAS(DSO_new); - -void -DSO_set_default_method(DSO_METHOD *meth) -{ - default_DSO_meth = meth; -} -LCRYPTO_ALIAS(DSO_set_default_method); - -DSO_METHOD * -DSO_get_default_method(void) -{ - return (default_DSO_meth); -} -LCRYPTO_ALIAS(DSO_get_default_method); - -DSO_METHOD * -DSO_get_method(DSO *dso) -{ - return (dso->meth); -} -LCRYPTO_ALIAS(DSO_get_method); - -DSO_METHOD * -DSO_set_method(DSO *dso, DSO_METHOD *meth) -{ - DSO_METHOD *mtmp; - - mtmp = dso->meth; - dso->meth = meth; - return (mtmp); -} -LCRYPTO_ALIAS(DSO_set_method); - -DSO * -DSO_new_method(DSO_METHOD *meth) -{ - DSO *ret; - - if (default_DSO_meth == NULL) - /* We default to DSO_METH_openssl() which in turn defaults - * to stealing the "best available" method. Will fallback - * to DSO_METH_null() in the worst case. */ - default_DSO_meth = DSO_METHOD_openssl(); - ret = calloc(1, sizeof(DSO)); - if (ret == NULL) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } - ret->meth_data = sk_void_new_null(); - if (ret->meth_data == NULL) { - /* sk_new doesn't generate any errors so we do */ - DSOerror(ERR_R_MALLOC_FAILURE); - free(ret); - return (NULL); - } - if (meth == NULL) - ret->meth = default_DSO_meth; - else - ret->meth = meth; - ret->references = 1; - if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { - free(ret); - ret = NULL; - } - return (ret); -} -LCRYPTO_ALIAS(DSO_new_method); - -int -DSO_free(DSO *dso) -{ - int i; - - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (0); - } - - i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO); - if (i > 0) - return (1); - - if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) { - DSOerror(DSO_R_UNLOAD_FAILED); - return (0); - } - - if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) { - DSOerror(DSO_R_FINISH_FAILED); - return (0); - } - - sk_void_free(dso->meth_data); - free(dso->filename); - free(dso->loaded_filename); - free(dso); - return (1); -} -LCRYPTO_ALIAS(DSO_free); - -int -DSO_flags(DSO *dso) -{ - return ((dso == NULL) ? 0 : dso->flags); -} -LCRYPTO_ALIAS(DSO_flags); - - -int -DSO_up_ref(DSO *dso) -{ - int refs; - - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (0); - } - - refs = CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); - return ((refs > 1) ? 1 : 0); -} -LCRYPTO_ALIAS(DSO_up_ref); - -DSO * -DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) -{ - DSO *ret; - int allocated = 0; - - if (dso == NULL) { - ret = DSO_new_method(meth); - if (ret == NULL) { - DSOerror(ERR_R_MALLOC_FAILURE); - goto err; - } - allocated = 1; - /* Pass the provided flags to the new DSO object */ - if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) { - DSOerror(DSO_R_CTRL_FAILED); - goto err; - } - } else - ret = dso; - /* Don't load if we're currently already loaded */ - if (ret->filename != NULL) { - DSOerror(DSO_R_DSO_ALREADY_LOADED); - goto err; - } - /* filename can only be NULL if we were passed a dso that already has - * one set. */ - if (filename != NULL) - if (!DSO_set_filename(ret, filename)) { - DSOerror(DSO_R_SET_FILENAME_FAILED); - goto err; - } - filename = ret->filename; - if (filename == NULL) { - DSOerror(DSO_R_NO_FILENAME); - goto err; - } - if (ret->meth->dso_load == NULL) { - DSOerror(DSO_R_UNSUPPORTED); - goto err; - } - if (!ret->meth->dso_load(ret)) { - DSOerror(DSO_R_LOAD_FAILED); - goto err; - } - /* Load succeeded */ - return (ret); - -err: - if (allocated) - DSO_free(ret); - return (NULL); -} -LCRYPTO_ALIAS(DSO_load); - -void * -DSO_bind_var(DSO *dso, const char *symname) -{ - void *ret = NULL; - - if ((dso == NULL) || (symname == NULL)) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if (dso->meth->dso_bind_var == NULL) { - DSOerror(DSO_R_UNSUPPORTED); - return (NULL); - } - if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) { - DSOerror(DSO_R_SYM_FAILURE); - return (NULL); - } - /* Success */ - return (ret); -} -LCRYPTO_ALIAS(DSO_bind_var); - -DSO_FUNC_TYPE -DSO_bind_func(DSO *dso, const char *symname) -{ - DSO_FUNC_TYPE ret = NULL; - - if ((dso == NULL) || (symname == NULL)) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if (dso->meth->dso_bind_func == NULL) { - DSOerror(DSO_R_UNSUPPORTED); - return (NULL); - } - if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) { - DSOerror(DSO_R_SYM_FAILURE); - return (NULL); - } - /* Success */ - return (ret); -} -LCRYPTO_ALIAS(DSO_bind_func); - -/* I don't really like these *_ctrl functions very much to be perfectly - * honest. For one thing, I think I have to return a negative value for - * any error because possible DSO_ctrl() commands may return values - * such as "size"s that can legitimately be zero (making the standard - * "if(DSO_cmd(...))" form that works almost everywhere else fail at - * odd times. I'd prefer "output" values to be passed by reference and - * the return value as success/failure like usual ... but we conform - * when we must... :-) */ -long -DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) -{ - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (-1); - } - /* We should intercept certain generic commands and only pass control - * to the method-specific ctrl() function if it's something we don't - * handle. */ - switch (cmd) { - case DSO_CTRL_GET_FLAGS: - return dso->flags; - case DSO_CTRL_SET_FLAGS: - dso->flags = (int)larg; - return (0); - case DSO_CTRL_OR_FLAGS: - dso->flags |= (int)larg; - return (0); - default: - break; - } - if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) { - DSOerror(DSO_R_UNSUPPORTED); - return (-1); - } - return (dso->meth->dso_ctrl(dso, cmd, larg, parg)); -} -LCRYPTO_ALIAS(DSO_ctrl); - -int -DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, - DSO_NAME_CONVERTER_FUNC *oldcb) -{ - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (0); - } - if (oldcb) - *oldcb = dso->name_converter; - dso->name_converter = cb; - return (1); -} -LCRYPTO_ALIAS(DSO_set_name_converter); - -const char * -DSO_get_filename(DSO *dso) -{ - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - return (dso->filename); -} -LCRYPTO_ALIAS(DSO_get_filename); - -int -DSO_set_filename(DSO *dso, const char *filename) -{ - char *copied; - - if ((dso == NULL) || (filename == NULL)) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (0); - } - if (dso->loaded_filename) { - DSOerror(DSO_R_DSO_ALREADY_LOADED); - return (0); - } - /* We'll duplicate filename */ - copied = strdup(filename); - if (copied == NULL) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (0); - } - free(dso->filename); - dso->filename = copied; - return (1); -} -LCRYPTO_ALIAS(DSO_set_filename); - -char * -DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) -{ - char *result = NULL; - - if (dso == NULL || filespec1 == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { - if (dso->merger != NULL) - result = dso->merger(dso, filespec1, filespec2); - else if (dso->meth->dso_merger != NULL) - result = dso->meth->dso_merger(dso, - filespec1, filespec2); - } - return (result); -} -LCRYPTO_ALIAS(DSO_merge); - -char * -DSO_convert_filename(DSO *dso, const char *filename) -{ - char *result = NULL; - - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - if (filename == NULL) - filename = dso->filename; - if (filename == NULL) { - DSOerror(DSO_R_NO_FILENAME); - return (NULL); - } - if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { - if (dso->name_converter != NULL) - result = dso->name_converter(dso, filename); - else if (dso->meth->dso_name_converter != NULL) - result = dso->meth->dso_name_converter(dso, filename); - } - if (result == NULL) { - result = strdup(filename); - if (result == NULL) { - DSOerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } - } - return (result); -} -LCRYPTO_ALIAS(DSO_convert_filename); - -const char * -DSO_get_loaded_filename(DSO *dso) -{ - if (dso == NULL) { - DSOerror(ERR_R_PASSED_NULL_PARAMETER); - return (NULL); - } - return (dso->loaded_filename); -} -LCRYPTO_ALIAS(DSO_get_loaded_filename); - -int -DSO_pathbyaddr(void *addr, char *path, int sz) -{ - DSO_METHOD *meth = default_DSO_meth; - if (meth == NULL) - meth = DSO_METHOD_openssl(); - if (meth->pathbyaddr == NULL) { - DSOerror(DSO_R_UNSUPPORTED); - return -1; - } - return (*meth->pathbyaddr)(addr, path, sz); -} -LCRYPTO_ALIAS(DSO_pathbyaddr); - -void * -DSO_global_lookup(const char *name) -{ - DSO_METHOD *meth = default_DSO_meth; - if (meth == NULL) - meth = DSO_METHOD_openssl(); - if (meth->globallookup == NULL) { - DSOerror(DSO_R_UNSUPPORTED); - return NULL; - } - return (*meth->globallookup)(name); -} -LCRYPTO_ALIAS(DSO_global_lookup); diff --git a/lib/libcrypto/dso/dso_null.c b/lib/libcrypto/dso/dso_null.c deleted file mode 100644 index dfe6a84442d..00000000000 --- a/lib/libcrypto/dso/dso_null.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: dso_null.c,v 1.8 2023/07/08 07:22:58 beck Exp $ */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -/* This "NULL" method is provided as the fallback for systems that have - * no appropriate support for "shared-libraries". */ - -#include - -#include - -static DSO_METHOD dso_meth_null = { - .name = "NULL shared library method" -}; - -DSO_METHOD * -DSO_METHOD_null(void) -{ - return (&dso_meth_null); -} -LCRYPTO_ALIAS(DSO_METHOD_null); diff --git a/lib/libcrypto/dso/dso_openssl.c b/lib/libcrypto/dso/dso_openssl.c deleted file mode 100644 index a639a5c7dc1..00000000000 --- a/lib/libcrypto/dso/dso_openssl.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: dso_openssl.c,v 1.7 2023/07/08 07:22:58 beck Exp $ */ -/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL - * project 2000. - */ -/* ==================================================================== - * Copyright (c) 2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#include - -/* We just pinch the method from an appropriate "default" method. */ - -DSO_METHOD * -DSO_METHOD_openssl(void) -{ -#ifdef DEF_DSO_METHOD - return (DEF_DSO_METHOD()); -#elif defined(DSO_DLFCN) - return (DSO_METHOD_dlfcn()); -#else - return (DSO_METHOD_null()); -#endif -} -LCRYPTO_ALIAS(DSO_METHOD_openssl); diff --git a/lib/libcrypto/err/err_all.c b/lib/libcrypto/err/err_all.c index 01c58f39f64..2c8a273f17e 100644 --- a/lib/libcrypto/err/err_all.c +++ b/lib/libcrypto/err/err_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err_all.c,v 1.31 2023/07/28 09:19:59 tb Exp $ */ +/* $OpenBSD: err_all.c,v 1.32 2023/07/28 09:46:36 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -128,7 +127,6 @@ ERR_load_crypto_strings_internal(void) #ifndef OPENSSL_NO_DSA ERR_load_DSA_strings(); #endif - ERR_load_DSO_strings(); #ifndef OPENSSL_NO_EC ERR_load_EC_strings(); #endif diff --git a/lib/libcrypto/hidden/openssl/dso.h b/lib/libcrypto/hidden/openssl/dso.h index a5e989c898d..e69de29bb2d 100644 --- a/lib/libcrypto/hidden/openssl/dso.h +++ b/lib/libcrypto/hidden/openssl/dso.h @@ -1,54 +0,0 @@ -/* $OpenBSD: dso.h,v 1.1 2023/07/08 07:22:58 beck Exp $ */ -/* - * Copyright (c) 2023 Bob Beck - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _LIBCRYPTO_DSO_H -#define _LIBCRYPTO_DSO_H - -#ifndef _MSC_VER -#include_next -#else -#include "../include/openssl/dso.h" -#endif -#include "crypto_namespace.h" - -LCRYPTO_USED(DSO_new); -LCRYPTO_USED(DSO_new_method); -LCRYPTO_USED(DSO_free); -LCRYPTO_USED(DSO_flags); -LCRYPTO_USED(DSO_up_ref); -LCRYPTO_USED(DSO_ctrl); -LCRYPTO_USED(DSO_set_name_converter); -LCRYPTO_USED(DSO_get_filename); -LCRYPTO_USED(DSO_set_filename); -LCRYPTO_USED(DSO_convert_filename); -LCRYPTO_USED(DSO_merge); -LCRYPTO_USED(DSO_get_loaded_filename); -LCRYPTO_USED(DSO_set_default_method); -LCRYPTO_USED(DSO_get_default_method); -LCRYPTO_USED(DSO_get_method); -LCRYPTO_USED(DSO_set_method); -LCRYPTO_USED(DSO_load); -LCRYPTO_USED(DSO_bind_var); -LCRYPTO_USED(DSO_bind_func); -LCRYPTO_USED(DSO_METHOD_openssl); -LCRYPTO_USED(DSO_METHOD_null); -LCRYPTO_USED(DSO_METHOD_dlfcn); -LCRYPTO_USED(DSO_pathbyaddr); -LCRYPTO_USED(DSO_global_lookup); -LCRYPTO_USED(ERR_load_DSO_strings); - -#endif /* _LIBCRYPTO_DSO_H */ diff --git a/lib/libcrypto/opensslfeatures.h b/lib/libcrypto/opensslfeatures.h index 1e087f9c239..7b8d40e688a 100644 --- a/lib/libcrypto/opensslfeatures.h +++ b/lib/libcrypto/opensslfeatures.h @@ -1,4 +1,4 @@ -/* $OpenBSD: opensslfeatures.h,v 1.39 2023/07/06 06:38:01 beck Exp $ */ +/* $OpenBSD: opensslfeatures.h,v 1.40 2023/07/28 09:46:36 tb Exp $ */ /* * Feature flags for LibreSSL... so you can actually tell when things * are enabled, rather than not being able to tell when things are @@ -51,7 +51,7 @@ /* #define OPENSSL_NO_DGRAM */ /* #define OPENSSL_NO_DH */ /* #define OPENSSL_NO_DSA */ -/* #define OPENSSL_NO_DSO */ +#define OPENSSL_NO_DSO /* #define OPENSSL_NO_DTLS */ #define OPENSSL_NO_DTLS1 #ifndef LIBRESSL_HAS_DTLS1_2 -- 2.20.1