diff options
-rw-r--r-- | src/lib/libcrypto/Makefile | 13 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 25 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.namespace | 25 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso.h | 382 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 355 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_err.c | 106 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_lib.c | 474 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_null.c | 75 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_openssl.c | 76 | ||||
-rw-r--r-- | src/lib/libcrypto/err/err_all.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/hidden/openssl/dso.h | 54 | ||||
-rw-r--r-- | src/lib/libcrypto/opensslfeatures.h | 4 |
12 files changed, 5 insertions, 1588 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index abcd91d0ef..9067c5673e 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.144 2023/07/28 09:42:44 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.145 2023/07/28 09:46:36 tb Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
@@ -25,7 +25,7 @@ CFLAGS+= -DLIBRESSL_NAMESPACE -DLIBRESSL_CRYPTO_NAMESPACE | |||
25 | 25 | ||
26 | 26 | ||
27 | .if !defined(NOPIC) | 27 | .if !defined(NOPIC) |
28 | CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN | 28 | CFLAGS+= -DHAVE_FUNOPEN |
29 | .endif | 29 | .endif |
30 | 30 | ||
31 | # Hardware engines | 31 | # Hardware engines |
@@ -318,13 +318,6 @@ SRCS+= dsa_ossl.c | |||
318 | SRCS+= dsa_pmeth.c | 318 | SRCS+= dsa_pmeth.c |
319 | SRCS+= dsa_prn.c | 319 | SRCS+= dsa_prn.c |
320 | 320 | ||
321 | # dso/ | ||
322 | SRCS+= dso_dlfcn.c | ||
323 | SRCS+= dso_err.c | ||
324 | SRCS+= dso_lib.c | ||
325 | SRCS+= dso_null.c | ||
326 | SRCS+= dso_openssl.c | ||
327 | |||
328 | # ec/ | 321 | # ec/ |
329 | SRCS+= ec_ameth.c | 322 | SRCS+= ec_ameth.c |
330 | SRCS+= ec_asn1.c | 323 | SRCS+= ec_asn1.c |
@@ -713,7 +706,6 @@ SRCS+= x_all.c | |||
713 | ${LCRYPTO_SRC}/des \ | 706 | ${LCRYPTO_SRC}/des \ |
714 | ${LCRYPTO_SRC}/dh \ | 707 | ${LCRYPTO_SRC}/dh \ |
715 | ${LCRYPTO_SRC}/dsa \ | 708 | ${LCRYPTO_SRC}/dsa \ |
716 | ${LCRYPTO_SRC}/dso \ | ||
717 | ${LCRYPTO_SRC}/ec \ | 709 | ${LCRYPTO_SRC}/ec \ |
718 | ${LCRYPTO_SRC}/ecdh \ | 710 | ${LCRYPTO_SRC}/ecdh \ |
719 | ${LCRYPTO_SRC}/ecdsa \ | 711 | ${LCRYPTO_SRC}/ecdsa \ |
@@ -774,7 +766,6 @@ HDRS=\ | |||
774 | ${LCRYPTO_SRC}/des/des.h \ | 766 | ${LCRYPTO_SRC}/des/des.h \ |
775 | ${LCRYPTO_SRC}/dh/dh.h \ | 767 | ${LCRYPTO_SRC}/dh/dh.h \ |
776 | ${LCRYPTO_SRC}/dsa/dsa.h \ | 768 | ${LCRYPTO_SRC}/dsa/dsa.h \ |
777 | ${LCRYPTO_SRC}/dso/dso.h \ | ||
778 | ${LCRYPTO_SRC}/ec/ec.h \ | 769 | ${LCRYPTO_SRC}/ec/ec.h \ |
779 | ${LCRYPTO_SRC}/ecdh/ecdh.h \ | 770 | ${LCRYPTO_SRC}/ecdh/ecdh.h \ |
780 | ${LCRYPTO_SRC}/ecdsa/ecdsa.h \ | 771 | ${LCRYPTO_SRC}/ecdsa/ecdsa.h \ |
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index b6ee286c6f..8b35d5ca44 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -979,30 +979,6 @@ DSAparams_dup | |||
979 | DSAparams_it | 979 | DSAparams_it |
980 | DSAparams_print | 980 | DSAparams_print |
981 | DSAparams_print_fp | 981 | DSAparams_print_fp |
982 | DSO_METHOD_dlfcn | ||
983 | DSO_METHOD_null | ||
984 | DSO_METHOD_openssl | ||
985 | DSO_bind_func | ||
986 | DSO_bind_var | ||
987 | DSO_convert_filename | ||
988 | DSO_ctrl | ||
989 | DSO_flags | ||
990 | DSO_free | ||
991 | DSO_get_default_method | ||
992 | DSO_get_filename | ||
993 | DSO_get_loaded_filename | ||
994 | DSO_get_method | ||
995 | DSO_global_lookup | ||
996 | DSO_load | ||
997 | DSO_merge | ||
998 | DSO_new | ||
999 | DSO_new_method | ||
1000 | DSO_pathbyaddr | ||
1001 | DSO_set_default_method | ||
1002 | DSO_set_filename | ||
1003 | DSO_set_method | ||
1004 | DSO_set_name_converter | ||
1005 | DSO_up_ref | ||
1006 | ECDH_compute_key | 982 | ECDH_compute_key |
1007 | ECDH_size | 983 | ECDH_size |
1008 | ECDSA_SIG_free | 984 | ECDSA_SIG_free |
@@ -1309,7 +1285,6 @@ ERR_load_CONF_strings | |||
1309 | ERR_load_CRYPTO_strings | 1285 | ERR_load_CRYPTO_strings |
1310 | ERR_load_DH_strings | 1286 | ERR_load_DH_strings |
1311 | ERR_load_DSA_strings | 1287 | ERR_load_DSA_strings |
1312 | ERR_load_DSO_strings | ||
1313 | ERR_load_EC_strings | 1288 | ERR_load_EC_strings |
1314 | ERR_load_ENGINE_strings | 1289 | ERR_load_ENGINE_strings |
1315 | ERR_load_ERR_strings | 1290 | ERR_load_ERR_strings |
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace index 57727a186e..adaac43146 100644 --- a/src/lib/libcrypto/Symbols.namespace +++ b/src/lib/libcrypto/Symbols.namespace | |||
@@ -1776,31 +1776,6 @@ _libre_lh_node_usage_stats_bio | |||
1776 | _libre_SM3_Init | 1776 | _libre_SM3_Init |
1777 | _libre_SM3_Update | 1777 | _libre_SM3_Update |
1778 | _libre_SM3_Final | 1778 | _libre_SM3_Final |
1779 | _libre_DSO_new | ||
1780 | _libre_DSO_new_method | ||
1781 | _libre_DSO_free | ||
1782 | _libre_DSO_flags | ||
1783 | _libre_DSO_up_ref | ||
1784 | _libre_DSO_ctrl | ||
1785 | _libre_DSO_set_name_converter | ||
1786 | _libre_DSO_get_filename | ||
1787 | _libre_DSO_set_filename | ||
1788 | _libre_DSO_convert_filename | ||
1789 | _libre_DSO_merge | ||
1790 | _libre_DSO_get_loaded_filename | ||
1791 | _libre_DSO_set_default_method | ||
1792 | _libre_DSO_get_default_method | ||
1793 | _libre_DSO_get_method | ||
1794 | _libre_DSO_set_method | ||
1795 | _libre_DSO_load | ||
1796 | _libre_DSO_bind_var | ||
1797 | _libre_DSO_bind_func | ||
1798 | _libre_DSO_METHOD_openssl | ||
1799 | _libre_DSO_METHOD_null | ||
1800 | _libre_DSO_METHOD_dlfcn | ||
1801 | _libre_DSO_pathbyaddr | ||
1802 | _libre_DSO_global_lookup | ||
1803 | _libre_ERR_load_DSO_strings | ||
1804 | _libre_CT_POLICY_EVAL_CTX_new | 1779 | _libre_CT_POLICY_EVAL_CTX_new |
1805 | _libre_CT_POLICY_EVAL_CTX_free | 1780 | _libre_CT_POLICY_EVAL_CTX_free |
1806 | _libre_CT_POLICY_EVAL_CTX_get0_cert | 1781 | _libre_CT_POLICY_EVAL_CTX_get0_cert |
diff --git a/src/lib/libcrypto/dso/dso.h b/src/lib/libcrypto/dso/dso.h deleted file mode 100644 index c3963a8e01..0000000000 --- a/src/lib/libcrypto/dso/dso.h +++ /dev/null | |||
@@ -1,382 +0,0 @@ | |||
1 | /* $OpenBSD: dso.h,v 1.14 2022/12/26 07:18:51 jmc Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_DSO_H | ||
60 | #define HEADER_DSO_H | ||
61 | |||
62 | #include <openssl/crypto.h> | ||
63 | |||
64 | #ifdef __cplusplus | ||
65 | extern "C" { | ||
66 | #endif | ||
67 | |||
68 | /* These values are used as commands to DSO_ctrl() */ | ||
69 | #define DSO_CTRL_GET_FLAGS 1 | ||
70 | #define DSO_CTRL_SET_FLAGS 2 | ||
71 | #define DSO_CTRL_OR_FLAGS 3 | ||
72 | |||
73 | /* By default, DSO_load() will translate the provided filename into a form | ||
74 | * typical for the platform (more specifically the DSO_METHOD) using the | ||
75 | * dso_name_converter function of the method. Eg. win32 will transform "blah" | ||
76 | * into "blah.dll", and dlfcn will transform it into "libblah.so". The | ||
77 | * behaviour can be overridden by setting the name_converter callback in the DSO | ||
78 | * object (using DSO_set_name_converter()). This callback could even utilise | ||
79 | * the DSO_METHOD's converter too if it only wants to override behaviour for | ||
80 | * one or two possible DSO methods. However, the following flag can be set in a | ||
81 | * DSO to prevent *any* native name-translation at all - eg. if the caller has | ||
82 | * prompted the user for a path to a driver library so the filename should be | ||
83 | * interpreted as-is. */ | ||
84 | #define DSO_FLAG_NO_NAME_TRANSLATION 0x01 | ||
85 | /* An extra flag to give if only the extension should be added as | ||
86 | * translation. This is obviously only of importance on Unix and | ||
87 | * other operating systems where the translation also may prefix | ||
88 | * the name with something, like 'lib', and ignored everywhere else. | ||
89 | * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used | ||
90 | * at the same time. */ | ||
91 | #define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 | ||
92 | |||
93 | /* The following flag controls the translation of symbol names to upper | ||
94 | * case. This is currently only being implemented for OpenVMS. | ||
95 | */ | ||
96 | #define DSO_FLAG_UPCASE_SYMBOL 0x10 | ||
97 | |||
98 | /* This flag loads the library with public symbols. | ||
99 | * Meaning: The exported symbols of this library are public | ||
100 | * to all libraries loaded after this library. | ||
101 | * At the moment only implemented in unix. | ||
102 | */ | ||
103 | #define DSO_FLAG_GLOBAL_SYMBOLS 0x20 | ||
104 | |||
105 | |||
106 | typedef void (*DSO_FUNC_TYPE)(void); | ||
107 | |||
108 | typedef struct dso_st DSO; | ||
109 | |||
110 | /* The function prototype used for method functions (or caller-provided | ||
111 | * callbacks) that transform filenames. They are passed a DSO structure pointer | ||
112 | * (or NULL if they are to be used independently of a DSO object) and a | ||
113 | * filename to transform. They should either return NULL (if there is an error | ||
114 | * condition) or a newly allocated string containing the transformed form that | ||
115 | * the caller will need to free with free() when done. */ | ||
116 | typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); | ||
117 | /* The function prototype used for method functions (or caller-provided | ||
118 | * callbacks) that merge two file specifications. They are passed a | ||
119 | * DSO structure pointer (or NULL if they are to be used independently of | ||
120 | * a DSO object) and two file specifications to merge. They should | ||
121 | * either return NULL (if there is an error condition) or a newly allocated | ||
122 | * string containing the result of merging that the caller will need | ||
123 | * to free with free() when done. | ||
124 | * Here, merging means that bits and pieces are taken from each of the | ||
125 | * file specifications and added together in whatever fashion that is | ||
126 | * sensible for the DSO method in question. The only rule that really | ||
127 | * applies is that if the two specification contain pieces of the same | ||
128 | * type, the copy from the first string takes priority. One could see | ||
129 | * it as the first specification is the one given by the user and the | ||
130 | * second being a bunch of defaults to add on if they're missing in the | ||
131 | * first. */ | ||
132 | typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); | ||
133 | |||
134 | typedef struct dso_meth_st { | ||
135 | const char *name; | ||
136 | /* Loads a shared library, NB: new DSO_METHODs must ensure that a | ||
137 | * successful load populates the loaded_filename field, and likewise a | ||
138 | * successful unload frees and NULLs it out. */ | ||
139 | int (*dso_load)(DSO *dso); | ||
140 | /* Unloads a shared library */ | ||
141 | int (*dso_unload)(DSO *dso); | ||
142 | /* Binds a variable */ | ||
143 | void *(*dso_bind_var)(DSO *dso, const char *symname); | ||
144 | /* Binds a function - assumes a return type of DSO_FUNC_TYPE. | ||
145 | * This should be cast to the real function prototype by the | ||
146 | * caller. Platforms that don't have compatible representations | ||
147 | * for different prototypes (this is possible within ANSI C) | ||
148 | * are highly unlikely to have shared libraries at all, let | ||
149 | * alone a DSO_METHOD implemented for them. */ | ||
150 | DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); | ||
151 | |||
152 | /* The generic (yuck) "ctrl()" function. NB: Negative return | ||
153 | * values (rather than zero) indicate errors. */ | ||
154 | long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); | ||
155 | /* The default DSO_METHOD-specific function for converting filenames to | ||
156 | * a canonical native form. */ | ||
157 | DSO_NAME_CONVERTER_FUNC dso_name_converter; | ||
158 | /* The default DSO_METHOD-specific function for converting filenames to | ||
159 | * a canonical native form. */ | ||
160 | DSO_MERGER_FUNC dso_merger; | ||
161 | |||
162 | /* [De]Initialisation handlers. */ | ||
163 | int (*init)(DSO *dso); | ||
164 | int (*finish)(DSO *dso); | ||
165 | |||
166 | /* Return pathname of the module containing location */ | ||
167 | int (*pathbyaddr)(void *addr, char *path, int sz); | ||
168 | /* Perform global symbol lookup, i.e. among *all* modules */ | ||
169 | void *(*globallookup)(const char *symname); | ||
170 | } DSO_METHOD; | ||
171 | |||
172 | /**********************************************************************/ | ||
173 | /* The low-level handle type used to refer to a loaded shared library */ | ||
174 | |||
175 | struct dso_st { | ||
176 | DSO_METHOD *meth; | ||
177 | /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS | ||
178 | * doesn't use anything but will need to cache the filename | ||
179 | * for use in the dso_bind handler. All in all, let each | ||
180 | * method control its own destiny. "Handles" and such go in | ||
181 | * a STACK. */ | ||
182 | STACK_OF(void) *meth_data; | ||
183 | int references; | ||
184 | int flags; | ||
185 | /* For use by applications etc ... use this for your bits'n'pieces, | ||
186 | * don't touch meth_data! */ | ||
187 | CRYPTO_EX_DATA ex_data; | ||
188 | /* If this callback function pointer is set to non-NULL, then it will | ||
189 | * be used in DSO_load() in place of meth->dso_name_converter. NB: This | ||
190 | * should normally set using DSO_set_name_converter(). */ | ||
191 | DSO_NAME_CONVERTER_FUNC name_converter; | ||
192 | /* If this callback function pointer is set to non-NULL, then it will | ||
193 | * be used in DSO_load() in place of meth->dso_merger. NB: This | ||
194 | * should normally set using DSO_set_merger(). */ | ||
195 | DSO_MERGER_FUNC merger; | ||
196 | /* This is populated with (a copy of) the platform-independant | ||
197 | * filename used for this DSO. */ | ||
198 | char *filename; | ||
199 | /* This is populated with (a copy of) the translated filename by which | ||
200 | * the DSO was actually loaded. It is NULL iff the DSO is not currently | ||
201 | * loaded. NB: This is here because the filename translation process | ||
202 | * may involve a callback being invoked more than once not only to | ||
203 | * convert to a platform-specific form, but also to try different | ||
204 | * filenames in the process of trying to perform a load. As such, this | ||
205 | * variable can be used to indicate (a) whether this DSO structure | ||
206 | * corresponds to a loaded library or not, and (b) the filename with | ||
207 | * which it was actually loaded. */ | ||
208 | char *loaded_filename; | ||
209 | }; | ||
210 | |||
211 | |||
212 | DSO * DSO_new(void); | ||
213 | DSO * DSO_new_method(DSO_METHOD *method); | ||
214 | int DSO_free(DSO *dso); | ||
215 | int DSO_flags(DSO *dso); | ||
216 | int DSO_up_ref(DSO *dso); | ||
217 | long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); | ||
218 | |||
219 | /* This function sets the DSO's name_converter callback. If it is non-NULL, | ||
220 | * then it will be used instead of the associated DSO_METHOD's function. If | ||
221 | * oldcb is non-NULL then it is set to the function pointer value being | ||
222 | * replaced. Return value is non-zero for success. */ | ||
223 | int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, | ||
224 | DSO_NAME_CONVERTER_FUNC *oldcb); | ||
225 | /* These functions can be used to get/set the platform-independant filename | ||
226 | * used for a DSO. NB: set will fail if the DSO is already loaded. */ | ||
227 | const char *DSO_get_filename(DSO *dso); | ||
228 | int DSO_set_filename(DSO *dso, const char *filename); | ||
229 | /* This function will invoke the DSO's name_converter callback to translate a | ||
230 | * filename, or if the callback isn't set it will instead use the DSO_METHOD's | ||
231 | * converter. If "filename" is NULL, the "filename" in the DSO itself will be | ||
232 | * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is | ||
233 | * simply duplicated. NB: This function is usually called from within a | ||
234 | * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that | ||
235 | * caller-created DSO_METHODs can do the same thing. A non-NULL return value | ||
236 | * will need to be free()'d. */ | ||
237 | char *DSO_convert_filename(DSO *dso, const char *filename); | ||
238 | /* This function will invoke the DSO's merger callback to merge two file | ||
239 | * specifications, or if the callback isn't set it will instead use the | ||
240 | * DSO_METHOD's merger. A non-NULL return value will need to be | ||
241 | * free()'d. */ | ||
242 | char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); | ||
243 | /* If the DSO is currently loaded, this returns the filename that it was loaded | ||
244 | * under, otherwise it returns NULL. So it is also useful as a test as to | ||
245 | * whether the DSO is currently loaded. NB: This will not necessarily return | ||
246 | * the same value as DSO_convert_filename(dso, dso->filename), because the | ||
247 | * DSO_METHOD's load function may have tried a variety of filenames (with | ||
248 | * and/or without the aid of the converters) before settling on the one it | ||
249 | * actually loaded. */ | ||
250 | const char *DSO_get_loaded_filename(DSO *dso); | ||
251 | |||
252 | void DSO_set_default_method(DSO_METHOD *meth); | ||
253 | DSO_METHOD *DSO_get_default_method(void); | ||
254 | DSO_METHOD *DSO_get_method(DSO *dso); | ||
255 | DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); | ||
256 | |||
257 | /* The all-singing all-dancing load function, you normally pass NULL | ||
258 | * for the first and third parameters. Use DSO_up and DSO_free for | ||
259 | * subsequent reference count handling. Any flags passed in will be set | ||
260 | * in the constructed DSO after its init() function but before the | ||
261 | * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ | ||
262 | DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); | ||
263 | |||
264 | /* This function binds to a variable inside a shared library. */ | ||
265 | void *DSO_bind_var(DSO *dso, const char *symname); | ||
266 | |||
267 | /* This function binds to a function inside a shared library. */ | ||
268 | DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); | ||
269 | |||
270 | /* This method is the default, but will beg, borrow, or steal whatever | ||
271 | * method should be the default on any particular platform (including | ||
272 | * DSO_METH_null() if necessary). */ | ||
273 | DSO_METHOD *DSO_METHOD_openssl(void); | ||
274 | |||
275 | /* This method is defined for all platforms - if a platform has no | ||
276 | * DSO support then this will be the only method! */ | ||
277 | DSO_METHOD *DSO_METHOD_null(void); | ||
278 | |||
279 | /* If DSO_DLFCN is defined, the standard dlfcn.h-style functions | ||
280 | * (dlopen, dlclose, dlsym, etc) will be used and incorporated into | ||
281 | * this method. If not, this method will return NULL. */ | ||
282 | DSO_METHOD *DSO_METHOD_dlfcn(void); | ||
283 | |||
284 | /* This function writes null-terminated pathname of DSO module | ||
285 | * containing 'addr' into 'sz' large caller-provided 'path' and | ||
286 | * returns the number of characters [including trailing zero] | ||
287 | * written to it. If 'sz' is 0 or negative, 'path' is ignored and | ||
288 | * required amount of characters [including trailing zero] to | ||
289 | * accommodate pathname is returned. If 'addr' is NULL, then | ||
290 | * pathname of cryptolib itself is returned. Negative or zero | ||
291 | * return value denotes error. | ||
292 | */ | ||
293 | int DSO_pathbyaddr(void *addr, char *path, int sz); | ||
294 | |||
295 | /* This function should be used with caution! It looks up symbols in | ||
296 | * *all* loaded modules and if module gets unloaded by somebody else | ||
297 | * attempt to dereference the pointer is doomed to have fatal | ||
298 | * consequences. Primary usage for this function is to probe *core* | ||
299 | * system functionality, e.g. check if getnameinfo(3) is available | ||
300 | * at run-time without bothering about OS-specific details such as | ||
301 | * libc.so.versioning or where does it actually reside: in libc | ||
302 | * itself or libsocket. */ | ||
303 | void *DSO_global_lookup(const char *name); | ||
304 | |||
305 | void ERR_load_DSO_strings(void); | ||
306 | |||
307 | /* Error codes for the DSO functions. */ | ||
308 | |||
309 | /* Function codes. */ | ||
310 | #define DSO_F_BEOS_BIND_FUNC 144 | ||
311 | #define DSO_F_BEOS_BIND_VAR 145 | ||
312 | #define DSO_F_BEOS_LOAD 146 | ||
313 | #define DSO_F_BEOS_NAME_CONVERTER 147 | ||
314 | #define DSO_F_BEOS_UNLOAD 148 | ||
315 | #define DSO_F_DLFCN_BIND_FUNC 100 | ||
316 | #define DSO_F_DLFCN_BIND_VAR 101 | ||
317 | #define DSO_F_DLFCN_LOAD 102 | ||
318 | #define DSO_F_DLFCN_MERGER 130 | ||
319 | #define DSO_F_DLFCN_NAME_CONVERTER 123 | ||
320 | #define DSO_F_DLFCN_UNLOAD 103 | ||
321 | #define DSO_F_DL_BIND_FUNC 104 | ||
322 | #define DSO_F_DL_BIND_VAR 105 | ||
323 | #define DSO_F_DL_LOAD 106 | ||
324 | #define DSO_F_DL_MERGER 131 | ||
325 | #define DSO_F_DL_NAME_CONVERTER 124 | ||
326 | #define DSO_F_DL_UNLOAD 107 | ||
327 | #define DSO_F_DSO_BIND_FUNC 108 | ||
328 | #define DSO_F_DSO_BIND_VAR 109 | ||
329 | #define DSO_F_DSO_CONVERT_FILENAME 126 | ||
330 | #define DSO_F_DSO_CTRL 110 | ||
331 | #define DSO_F_DSO_FREE 111 | ||
332 | #define DSO_F_DSO_GET_FILENAME 127 | ||
333 | #define DSO_F_DSO_GET_LOADED_FILENAME 128 | ||
334 | #define DSO_F_DSO_GLOBAL_LOOKUP 139 | ||
335 | #define DSO_F_DSO_LOAD 112 | ||
336 | #define DSO_F_DSO_MERGE 132 | ||
337 | #define DSO_F_DSO_NEW_METHOD 113 | ||
338 | #define DSO_F_DSO_PATHBYADDR 140 | ||
339 | #define DSO_F_DSO_SET_FILENAME 129 | ||
340 | #define DSO_F_DSO_SET_NAME_CONVERTER 122 | ||
341 | #define DSO_F_DSO_UP_REF 114 | ||
342 | #define DSO_F_GLOBAL_LOOKUP_FUNC 138 | ||
343 | #define DSO_F_PATHBYADDR 137 | ||
344 | #define DSO_F_VMS_BIND_SYM 115 | ||
345 | #define DSO_F_VMS_LOAD 116 | ||
346 | #define DSO_F_VMS_MERGER 133 | ||
347 | #define DSO_F_VMS_UNLOAD 117 | ||
348 | #define DSO_F_WIN32_BIND_FUNC 118 | ||
349 | #define DSO_F_WIN32_BIND_VAR 119 | ||
350 | #define DSO_F_WIN32_GLOBALLOOKUP 142 | ||
351 | #define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143 | ||
352 | #define DSO_F_WIN32_JOINER 135 | ||
353 | #define DSO_F_WIN32_LOAD 120 | ||
354 | #define DSO_F_WIN32_MERGER 134 | ||
355 | #define DSO_F_WIN32_NAME_CONVERTER 125 | ||
356 | #define DSO_F_WIN32_PATHBYADDR 141 | ||
357 | #define DSO_F_WIN32_SPLITTER 136 | ||
358 | #define DSO_F_WIN32_UNLOAD 121 | ||
359 | |||
360 | /* Reason codes. */ | ||
361 | #define DSO_R_CTRL_FAILED 100 | ||
362 | #define DSO_R_DSO_ALREADY_LOADED 110 | ||
363 | #define DSO_R_EMPTY_FILE_STRUCTURE 113 | ||
364 | #define DSO_R_FAILURE 114 | ||
365 | #define DSO_R_FILENAME_TOO_BIG 101 | ||
366 | #define DSO_R_FINISH_FAILED 102 | ||
367 | #define DSO_R_INCORRECT_FILE_SYNTAX 115 | ||
368 | #define DSO_R_LOAD_FAILED 103 | ||
369 | #define DSO_R_NAME_TRANSLATION_FAILED 109 | ||
370 | #define DSO_R_NO_FILENAME 111 | ||
371 | #define DSO_R_NO_FILE_SPECIFICATION 116 | ||
372 | #define DSO_R_NULL_HANDLE 104 | ||
373 | #define DSO_R_SET_FILENAME_FAILED 112 | ||
374 | #define DSO_R_STACK_ERROR 105 | ||
375 | #define DSO_R_SYM_FAILURE 106 | ||
376 | #define DSO_R_UNLOAD_FAILED 107 | ||
377 | #define DSO_R_UNSUPPORTED 108 | ||
378 | |||
379 | #ifdef __cplusplus | ||
380 | } | ||
381 | #endif | ||
382 | #endif | ||
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c deleted file mode 100644 index 77c19aa27e..0000000000 --- a/src/lib/libcrypto/dso/dso_dlfcn.c +++ /dev/null | |||
@@ -1,355 +0,0 @@ | |||
1 | /* $OpenBSD: dso_dlfcn.c,v 1.30 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <string.h> | ||
61 | |||
62 | #include <openssl/dso.h> | ||
63 | #include <openssl/err.h> | ||
64 | |||
65 | #ifndef DSO_DLFCN | ||
66 | DSO_METHOD * | ||
67 | DSO_METHOD_dlfcn(void) | ||
68 | { | ||
69 | return NULL; | ||
70 | } | ||
71 | LCRYPTO_ALIAS(DSO_METHOD_dlfcn); | ||
72 | #else | ||
73 | |||
74 | #ifdef HAVE_DLFCN_H | ||
75 | # include <dlfcn.h> | ||
76 | # define HAVE_DLINFO 1 | ||
77 | #endif | ||
78 | |||
79 | /* Part of the hack in "dlfcn_load" ... */ | ||
80 | #define DSO_MAX_TRANSLATED_SIZE 256 | ||
81 | |||
82 | static int dlfcn_load(DSO *dso); | ||
83 | static int dlfcn_unload(DSO *dso); | ||
84 | static void *dlfcn_bind_var(DSO *dso, const char *symname); | ||
85 | static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname); | ||
86 | static char *dlfcn_name_converter(DSO *dso, const char *filename); | ||
87 | static char *dlfcn_merger(DSO *dso, const char *filespec1, | ||
88 | const char *filespec2); | ||
89 | static int dlfcn_pathbyaddr(void *addr, char *path, int sz); | ||
90 | static void *dlfcn_globallookup(const char *name); | ||
91 | |||
92 | static DSO_METHOD dso_meth_dlfcn = { | ||
93 | .name = "OpenSSL 'dlfcn' shared library method", | ||
94 | .dso_load = dlfcn_load, | ||
95 | .dso_unload = dlfcn_unload, | ||
96 | .dso_bind_var = dlfcn_bind_var, | ||
97 | .dso_bind_func = dlfcn_bind_func, | ||
98 | .dso_name_converter = dlfcn_name_converter, | ||
99 | .dso_merger = dlfcn_merger, | ||
100 | .pathbyaddr = dlfcn_pathbyaddr, | ||
101 | .globallookup = dlfcn_globallookup | ||
102 | }; | ||
103 | |||
104 | DSO_METHOD * | ||
105 | DSO_METHOD_dlfcn(void) | ||
106 | { | ||
107 | return (&dso_meth_dlfcn); | ||
108 | } | ||
109 | LCRYPTO_ALIAS(DSO_METHOD_dlfcn); | ||
110 | |||
111 | /* For this DSO_METHOD, our meth_data STACK will contain; | ||
112 | * (i) the handle (void*) returned from dlopen(). | ||
113 | */ | ||
114 | |||
115 | static int | ||
116 | dlfcn_load(DSO *dso) | ||
117 | { | ||
118 | void *ptr = NULL; | ||
119 | /* See applicable comments in dso_dl.c */ | ||
120 | char *filename = DSO_convert_filename(dso, NULL); | ||
121 | int flags = RTLD_LAZY; | ||
122 | |||
123 | if (filename == NULL) { | ||
124 | DSOerror(DSO_R_NO_FILENAME); | ||
125 | goto err; | ||
126 | } | ||
127 | |||
128 | if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) | ||
129 | flags |= RTLD_GLOBAL; | ||
130 | ptr = dlopen(filename, flags); | ||
131 | if (ptr == NULL) { | ||
132 | DSOerror(DSO_R_LOAD_FAILED); | ||
133 | ERR_asprintf_error_data("filename(%s): %s", filename, | ||
134 | dlerror()); | ||
135 | goto err; | ||
136 | } | ||
137 | if (!sk_void_push(dso->meth_data, (char *)ptr)) { | ||
138 | DSOerror(DSO_R_STACK_ERROR); | ||
139 | goto err; | ||
140 | } | ||
141 | /* Success */ | ||
142 | dso->loaded_filename = filename; | ||
143 | return (1); | ||
144 | |||
145 | err: | ||
146 | /* Cleanup! */ | ||
147 | free(filename); | ||
148 | if (ptr != NULL) | ||
149 | dlclose(ptr); | ||
150 | return (0); | ||
151 | } | ||
152 | |||
153 | static int | ||
154 | dlfcn_unload(DSO *dso) | ||
155 | { | ||
156 | void *ptr; | ||
157 | if (dso == NULL) { | ||
158 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
159 | return (0); | ||
160 | } | ||
161 | if (sk_void_num(dso->meth_data) < 1) | ||
162 | return (1); | ||
163 | ptr = sk_void_pop(dso->meth_data); | ||
164 | if (ptr == NULL) { | ||
165 | DSOerror(DSO_R_NULL_HANDLE); | ||
166 | /* Should push the value back onto the stack in | ||
167 | * case of a retry. */ | ||
168 | sk_void_push(dso->meth_data, ptr); | ||
169 | return (0); | ||
170 | } | ||
171 | /* For now I'm not aware of any errors associated with dlclose() */ | ||
172 | dlclose(ptr); | ||
173 | return (1); | ||
174 | } | ||
175 | |||
176 | static void * | ||
177 | dlfcn_bind_var(DSO *dso, const char *symname) | ||
178 | { | ||
179 | void *ptr, *sym; | ||
180 | |||
181 | if ((dso == NULL) || (symname == NULL)) { | ||
182 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
183 | return (NULL); | ||
184 | } | ||
185 | if (sk_void_num(dso->meth_data) < 1) { | ||
186 | DSOerror(DSO_R_STACK_ERROR); | ||
187 | return (NULL); | ||
188 | } | ||
189 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); | ||
190 | if (ptr == NULL) { | ||
191 | DSOerror(DSO_R_NULL_HANDLE); | ||
192 | return (NULL); | ||
193 | } | ||
194 | sym = dlsym(ptr, symname); | ||
195 | if (sym == NULL) { | ||
196 | DSOerror(DSO_R_SYM_FAILURE); | ||
197 | ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); | ||
198 | return (NULL); | ||
199 | } | ||
200 | return (sym); | ||
201 | } | ||
202 | |||
203 | static DSO_FUNC_TYPE | ||
204 | dlfcn_bind_func(DSO *dso, const char *symname) | ||
205 | { | ||
206 | void *ptr; | ||
207 | union { | ||
208 | DSO_FUNC_TYPE sym; | ||
209 | void *dlret; | ||
210 | } u; | ||
211 | |||
212 | if ((dso == NULL) || (symname == NULL)) { | ||
213 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
214 | return (NULL); | ||
215 | } | ||
216 | if (sk_void_num(dso->meth_data) < 1) { | ||
217 | DSOerror(DSO_R_STACK_ERROR); | ||
218 | return (NULL); | ||
219 | } | ||
220 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); | ||
221 | if (ptr == NULL) { | ||
222 | DSOerror(DSO_R_NULL_HANDLE); | ||
223 | return (NULL); | ||
224 | } | ||
225 | u.dlret = dlsym(ptr, symname); | ||
226 | if (u.dlret == NULL) { | ||
227 | DSOerror(DSO_R_SYM_FAILURE); | ||
228 | ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); | ||
229 | return (NULL); | ||
230 | } | ||
231 | return u.sym; | ||
232 | } | ||
233 | |||
234 | static char * | ||
235 | dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2) | ||
236 | { | ||
237 | char *merged; | ||
238 | |||
239 | if (!filespec1 && !filespec2) { | ||
240 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
241 | return (NULL); | ||
242 | } | ||
243 | /* If the first file specification is a rooted path, it rules. | ||
244 | same goes if the second file specification is missing. */ | ||
245 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { | ||
246 | merged = strdup(filespec1); | ||
247 | if (!merged) { | ||
248 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
249 | return (NULL); | ||
250 | } | ||
251 | } | ||
252 | /* If the first file specification is missing, the second one rules. */ | ||
253 | else if (!filespec1) { | ||
254 | merged = strdup(filespec2); | ||
255 | if (!merged) { | ||
256 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
257 | return (NULL); | ||
258 | } | ||
259 | } else | ||
260 | /* This part isn't as trivial as it looks. It assumes that | ||
261 | the second file specification really is a directory, and | ||
262 | makes no checks whatsoever. Therefore, the result becomes | ||
263 | the concatenation of filespec2 followed by a slash followed | ||
264 | by filespec1. */ | ||
265 | { | ||
266 | size_t spec2len, len; | ||
267 | |||
268 | spec2len = strlen(filespec2); | ||
269 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); | ||
270 | |||
271 | if (filespec2 && filespec2[spec2len - 1] == '/') { | ||
272 | spec2len--; | ||
273 | len--; | ||
274 | } | ||
275 | merged = malloc(len + 2); | ||
276 | if (!merged) { | ||
277 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
278 | return (NULL); | ||
279 | } | ||
280 | strlcpy(merged, filespec2, len + 2); | ||
281 | merged[spec2len] = '/'; | ||
282 | strlcpy(&merged[spec2len + 1], filespec1, len + 1 - spec2len); | ||
283 | } | ||
284 | return (merged); | ||
285 | } | ||
286 | |||
287 | #define DSO_ext ".so" | ||
288 | #define DSO_extlen 3 | ||
289 | |||
290 | static char * | ||
291 | dlfcn_name_converter(DSO *dso, const char *filename) | ||
292 | { | ||
293 | char *translated; | ||
294 | int ret; | ||
295 | |||
296 | if (strchr(filename, '/') == NULL) { | ||
297 | /* Bare name, so convert to "%s.so" or "lib%s.so" */ | ||
298 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) | ||
299 | ret = asprintf(&translated, "lib%s" DSO_ext, filename); | ||
300 | else | ||
301 | ret = asprintf(&translated, "%s" DSO_ext, filename); | ||
302 | if (ret == -1) | ||
303 | translated = NULL; | ||
304 | } else { | ||
305 | /* Full path, so just duplicate it */ | ||
306 | translated = strdup(filename); | ||
307 | } | ||
308 | |||
309 | if (translated == NULL) | ||
310 | DSOerror(DSO_R_NAME_TRANSLATION_FAILED); | ||
311 | return (translated); | ||
312 | } | ||
313 | |||
314 | static int | ||
315 | dlfcn_pathbyaddr(void *addr, char *path, int sz) | ||
316 | { | ||
317 | Dl_info dli; | ||
318 | int len; | ||
319 | |||
320 | if (addr == NULL) { | ||
321 | union{ | ||
322 | int(*f)(void*, char*, int); | ||
323 | void *p; | ||
324 | } t = { dlfcn_pathbyaddr }; | ||
325 | addr = t.p; | ||
326 | } | ||
327 | |||
328 | if (dladdr(addr, &dli)) { | ||
329 | len = (int)strlen(dli.dli_fname); | ||
330 | if (sz <= 0) | ||
331 | return len + 1; | ||
332 | if (len >= sz) | ||
333 | len = sz - 1; | ||
334 | memcpy(path, dli.dli_fname, len); | ||
335 | path[len++] = 0; | ||
336 | return len; | ||
337 | } | ||
338 | |||
339 | ERR_asprintf_error_data("dlfcn_pathbyaddr(): %s", dlerror()); | ||
340 | return -1; | ||
341 | } | ||
342 | |||
343 | static void * | ||
344 | dlfcn_globallookup(const char *name) | ||
345 | { | ||
346 | void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY); | ||
347 | |||
348 | if (handle) { | ||
349 | ret = dlsym(handle, name); | ||
350 | dlclose(handle); | ||
351 | } | ||
352 | |||
353 | return ret; | ||
354 | } | ||
355 | #endif /* DSO_DLFCN */ | ||
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c deleted file mode 100644 index 9dec8a66b7..0000000000 --- a/src/lib/libcrypto/dso/dso_err.c +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | /* $OpenBSD: dso_err.c,v 1.11 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* ==================================================================== | ||
3 | * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in | ||
14 | * the documentation and/or other materials provided with the | ||
15 | * distribution. | ||
16 | * | ||
17 | * 3. All advertising materials mentioning features or use of this | ||
18 | * software must display the following acknowledgment: | ||
19 | * "This product includes software developed by the OpenSSL Project | ||
20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
21 | * | ||
22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
23 | * endorse or promote products derived from this software without | ||
24 | * prior written permission. For written permission, please contact | ||
25 | * openssl-core@OpenSSL.org. | ||
26 | * | ||
27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
28 | * nor may "OpenSSL" appear in their names without prior written | ||
29 | * permission of the OpenSSL Project. | ||
30 | * | ||
31 | * 6. Redistributions of any form whatsoever must retain the following | ||
32 | * acknowledgment: | ||
33 | * "This product includes software developed by the OpenSSL Project | ||
34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
35 | * | ||
36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
48 | * ==================================================================== | ||
49 | * | ||
50 | * This product includes cryptographic software written by Eric Young | ||
51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
52 | * Hudson (tjh@cryptsoft.com). | ||
53 | * | ||
54 | */ | ||
55 | |||
56 | #include <stdio.h> | ||
57 | |||
58 | #include <openssl/opensslconf.h> | ||
59 | |||
60 | #include <openssl/err.h> | ||
61 | #include <openssl/dso.h> | ||
62 | |||
63 | #ifndef OPENSSL_NO_ERR | ||
64 | |||
65 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSO,func,0) | ||
66 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason) | ||
67 | |||
68 | static ERR_STRING_DATA DSO_str_functs[]= { | ||
69 | {ERR_FUNC(0xfff), "CRYPTO_internal"}, | ||
70 | {0, NULL} | ||
71 | }; | ||
72 | |||
73 | static ERR_STRING_DATA DSO_str_reasons[]= { | ||
74 | {ERR_REASON(DSO_R_CTRL_FAILED) , "control command failed"}, | ||
75 | {ERR_REASON(DSO_R_DSO_ALREADY_LOADED) , "dso already loaded"}, | ||
76 | {ERR_REASON(DSO_R_EMPTY_FILE_STRUCTURE) , "empty file structure"}, | ||
77 | {ERR_REASON(DSO_R_FAILURE) , "failure"}, | ||
78 | {ERR_REASON(DSO_R_FILENAME_TOO_BIG) , "filename too big"}, | ||
79 | {ERR_REASON(DSO_R_FINISH_FAILED) , "cleanup method function failed"}, | ||
80 | {ERR_REASON(DSO_R_INCORRECT_FILE_SYNTAX) , "incorrect file syntax"}, | ||
81 | {ERR_REASON(DSO_R_LOAD_FAILED) , "could not load the shared library"}, | ||
82 | {ERR_REASON(DSO_R_NAME_TRANSLATION_FAILED), "name translation failed"}, | ||
83 | {ERR_REASON(DSO_R_NO_FILENAME) , "no filename"}, | ||
84 | {ERR_REASON(DSO_R_NO_FILE_SPECIFICATION) , "no file specification"}, | ||
85 | {ERR_REASON(DSO_R_NULL_HANDLE) , "a null shared library handle was used"}, | ||
86 | {ERR_REASON(DSO_R_SET_FILENAME_FAILED) , "set filename failed"}, | ||
87 | {ERR_REASON(DSO_R_STACK_ERROR) , "the meth_data stack is corrupt"}, | ||
88 | {ERR_REASON(DSO_R_SYM_FAILURE) , "could not bind to the requested symbol name"}, | ||
89 | {ERR_REASON(DSO_R_UNLOAD_FAILED) , "could not unload the shared library"}, | ||
90 | {ERR_REASON(DSO_R_UNSUPPORTED) , "functionality not supported"}, | ||
91 | {0, NULL} | ||
92 | }; | ||
93 | |||
94 | #endif | ||
95 | |||
96 | void | ||
97 | ERR_load_DSO_strings(void) | ||
98 | { | ||
99 | #ifndef OPENSSL_NO_ERR | ||
100 | if (ERR_func_error_string(DSO_str_functs[0].error) == NULL) { | ||
101 | ERR_load_strings(0, DSO_str_functs); | ||
102 | ERR_load_strings(0, DSO_str_reasons); | ||
103 | } | ||
104 | #endif | ||
105 | } | ||
106 | LCRYPTO_ALIAS(ERR_load_DSO_strings); | ||
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c deleted file mode 100644 index ca762f68dc..0000000000 --- a/src/lib/libcrypto/dso/dso_lib.c +++ /dev/null | |||
@@ -1,474 +0,0 @@ | |||
1 | /* $OpenBSD: dso_lib.c,v 1.21 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <string.h> | ||
61 | |||
62 | #include <openssl/crypto.h> | ||
63 | #include <openssl/dso.h> | ||
64 | #include <openssl/err.h> | ||
65 | |||
66 | static DSO_METHOD *default_DSO_meth = NULL; | ||
67 | |||
68 | DSO * | ||
69 | DSO_new(void) | ||
70 | { | ||
71 | return (DSO_new_method(NULL)); | ||
72 | } | ||
73 | LCRYPTO_ALIAS(DSO_new); | ||
74 | |||
75 | void | ||
76 | DSO_set_default_method(DSO_METHOD *meth) | ||
77 | { | ||
78 | default_DSO_meth = meth; | ||
79 | } | ||
80 | LCRYPTO_ALIAS(DSO_set_default_method); | ||
81 | |||
82 | DSO_METHOD * | ||
83 | DSO_get_default_method(void) | ||
84 | { | ||
85 | return (default_DSO_meth); | ||
86 | } | ||
87 | LCRYPTO_ALIAS(DSO_get_default_method); | ||
88 | |||
89 | DSO_METHOD * | ||
90 | DSO_get_method(DSO *dso) | ||
91 | { | ||
92 | return (dso->meth); | ||
93 | } | ||
94 | LCRYPTO_ALIAS(DSO_get_method); | ||
95 | |||
96 | DSO_METHOD * | ||
97 | DSO_set_method(DSO *dso, DSO_METHOD *meth) | ||
98 | { | ||
99 | DSO_METHOD *mtmp; | ||
100 | |||
101 | mtmp = dso->meth; | ||
102 | dso->meth = meth; | ||
103 | return (mtmp); | ||
104 | } | ||
105 | LCRYPTO_ALIAS(DSO_set_method); | ||
106 | |||
107 | DSO * | ||
108 | DSO_new_method(DSO_METHOD *meth) | ||
109 | { | ||
110 | DSO *ret; | ||
111 | |||
112 | if (default_DSO_meth == NULL) | ||
113 | /* We default to DSO_METH_openssl() which in turn defaults | ||
114 | * to stealing the "best available" method. Will fallback | ||
115 | * to DSO_METH_null() in the worst case. */ | ||
116 | default_DSO_meth = DSO_METHOD_openssl(); | ||
117 | ret = calloc(1, sizeof(DSO)); | ||
118 | if (ret == NULL) { | ||
119 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
120 | return (NULL); | ||
121 | } | ||
122 | ret->meth_data = sk_void_new_null(); | ||
123 | if (ret->meth_data == NULL) { | ||
124 | /* sk_new doesn't generate any errors so we do */ | ||
125 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
126 | free(ret); | ||
127 | return (NULL); | ||
128 | } | ||
129 | if (meth == NULL) | ||
130 | ret->meth = default_DSO_meth; | ||
131 | else | ||
132 | ret->meth = meth; | ||
133 | ret->references = 1; | ||
134 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { | ||
135 | free(ret); | ||
136 | ret = NULL; | ||
137 | } | ||
138 | return (ret); | ||
139 | } | ||
140 | LCRYPTO_ALIAS(DSO_new_method); | ||
141 | |||
142 | int | ||
143 | DSO_free(DSO *dso) | ||
144 | { | ||
145 | int i; | ||
146 | |||
147 | if (dso == NULL) { | ||
148 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
149 | return (0); | ||
150 | } | ||
151 | |||
152 | i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO); | ||
153 | if (i > 0) | ||
154 | return (1); | ||
155 | |||
156 | if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) { | ||
157 | DSOerror(DSO_R_UNLOAD_FAILED); | ||
158 | return (0); | ||
159 | } | ||
160 | |||
161 | if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) { | ||
162 | DSOerror(DSO_R_FINISH_FAILED); | ||
163 | return (0); | ||
164 | } | ||
165 | |||
166 | sk_void_free(dso->meth_data); | ||
167 | free(dso->filename); | ||
168 | free(dso->loaded_filename); | ||
169 | free(dso); | ||
170 | return (1); | ||
171 | } | ||
172 | LCRYPTO_ALIAS(DSO_free); | ||
173 | |||
174 | int | ||
175 | DSO_flags(DSO *dso) | ||
176 | { | ||
177 | return ((dso == NULL) ? 0 : dso->flags); | ||
178 | } | ||
179 | LCRYPTO_ALIAS(DSO_flags); | ||
180 | |||
181 | |||
182 | int | ||
183 | DSO_up_ref(DSO *dso) | ||
184 | { | ||
185 | int refs; | ||
186 | |||
187 | if (dso == NULL) { | ||
188 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
189 | return (0); | ||
190 | } | ||
191 | |||
192 | refs = CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); | ||
193 | return ((refs > 1) ? 1 : 0); | ||
194 | } | ||
195 | LCRYPTO_ALIAS(DSO_up_ref); | ||
196 | |||
197 | DSO * | ||
198 | DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) | ||
199 | { | ||
200 | DSO *ret; | ||
201 | int allocated = 0; | ||
202 | |||
203 | if (dso == NULL) { | ||
204 | ret = DSO_new_method(meth); | ||
205 | if (ret == NULL) { | ||
206 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
207 | goto err; | ||
208 | } | ||
209 | allocated = 1; | ||
210 | /* Pass the provided flags to the new DSO object */ | ||
211 | if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) { | ||
212 | DSOerror(DSO_R_CTRL_FAILED); | ||
213 | goto err; | ||
214 | } | ||
215 | } else | ||
216 | ret = dso; | ||
217 | /* Don't load if we're currently already loaded */ | ||
218 | if (ret->filename != NULL) { | ||
219 | DSOerror(DSO_R_DSO_ALREADY_LOADED); | ||
220 | goto err; | ||
221 | } | ||
222 | /* filename can only be NULL if we were passed a dso that already has | ||
223 | * one set. */ | ||
224 | if (filename != NULL) | ||
225 | if (!DSO_set_filename(ret, filename)) { | ||
226 | DSOerror(DSO_R_SET_FILENAME_FAILED); | ||
227 | goto err; | ||
228 | } | ||
229 | filename = ret->filename; | ||
230 | if (filename == NULL) { | ||
231 | DSOerror(DSO_R_NO_FILENAME); | ||
232 | goto err; | ||
233 | } | ||
234 | if (ret->meth->dso_load == NULL) { | ||
235 | DSOerror(DSO_R_UNSUPPORTED); | ||
236 | goto err; | ||
237 | } | ||
238 | if (!ret->meth->dso_load(ret)) { | ||
239 | DSOerror(DSO_R_LOAD_FAILED); | ||
240 | goto err; | ||
241 | } | ||
242 | /* Load succeeded */ | ||
243 | return (ret); | ||
244 | |||
245 | err: | ||
246 | if (allocated) | ||
247 | DSO_free(ret); | ||
248 | return (NULL); | ||
249 | } | ||
250 | LCRYPTO_ALIAS(DSO_load); | ||
251 | |||
252 | void * | ||
253 | DSO_bind_var(DSO *dso, const char *symname) | ||
254 | { | ||
255 | void *ret = NULL; | ||
256 | |||
257 | if ((dso == NULL) || (symname == NULL)) { | ||
258 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
259 | return (NULL); | ||
260 | } | ||
261 | if (dso->meth->dso_bind_var == NULL) { | ||
262 | DSOerror(DSO_R_UNSUPPORTED); | ||
263 | return (NULL); | ||
264 | } | ||
265 | if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) { | ||
266 | DSOerror(DSO_R_SYM_FAILURE); | ||
267 | return (NULL); | ||
268 | } | ||
269 | /* Success */ | ||
270 | return (ret); | ||
271 | } | ||
272 | LCRYPTO_ALIAS(DSO_bind_var); | ||
273 | |||
274 | DSO_FUNC_TYPE | ||
275 | DSO_bind_func(DSO *dso, const char *symname) | ||
276 | { | ||
277 | DSO_FUNC_TYPE ret = NULL; | ||
278 | |||
279 | if ((dso == NULL) || (symname == NULL)) { | ||
280 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
281 | return (NULL); | ||
282 | } | ||
283 | if (dso->meth->dso_bind_func == NULL) { | ||
284 | DSOerror(DSO_R_UNSUPPORTED); | ||
285 | return (NULL); | ||
286 | } | ||
287 | if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) { | ||
288 | DSOerror(DSO_R_SYM_FAILURE); | ||
289 | return (NULL); | ||
290 | } | ||
291 | /* Success */ | ||
292 | return (ret); | ||
293 | } | ||
294 | LCRYPTO_ALIAS(DSO_bind_func); | ||
295 | |||
296 | /* I don't really like these *_ctrl functions very much to be perfectly | ||
297 | * honest. For one thing, I think I have to return a negative value for | ||
298 | * any error because possible DSO_ctrl() commands may return values | ||
299 | * such as "size"s that can legitimately be zero (making the standard | ||
300 | * "if(DSO_cmd(...))" form that works almost everywhere else fail at | ||
301 | * odd times. I'd prefer "output" values to be passed by reference and | ||
302 | * the return value as success/failure like usual ... but we conform | ||
303 | * when we must... :-) */ | ||
304 | long | ||
305 | DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) | ||
306 | { | ||
307 | if (dso == NULL) { | ||
308 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
309 | return (-1); | ||
310 | } | ||
311 | /* We should intercept certain generic commands and only pass control | ||
312 | * to the method-specific ctrl() function if it's something we don't | ||
313 | * handle. */ | ||
314 | switch (cmd) { | ||
315 | case DSO_CTRL_GET_FLAGS: | ||
316 | return dso->flags; | ||
317 | case DSO_CTRL_SET_FLAGS: | ||
318 | dso->flags = (int)larg; | ||
319 | return (0); | ||
320 | case DSO_CTRL_OR_FLAGS: | ||
321 | dso->flags |= (int)larg; | ||
322 | return (0); | ||
323 | default: | ||
324 | break; | ||
325 | } | ||
326 | if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) { | ||
327 | DSOerror(DSO_R_UNSUPPORTED); | ||
328 | return (-1); | ||
329 | } | ||
330 | return (dso->meth->dso_ctrl(dso, cmd, larg, parg)); | ||
331 | } | ||
332 | LCRYPTO_ALIAS(DSO_ctrl); | ||
333 | |||
334 | int | ||
335 | DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, | ||
336 | DSO_NAME_CONVERTER_FUNC *oldcb) | ||
337 | { | ||
338 | if (dso == NULL) { | ||
339 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
340 | return (0); | ||
341 | } | ||
342 | if (oldcb) | ||
343 | *oldcb = dso->name_converter; | ||
344 | dso->name_converter = cb; | ||
345 | return (1); | ||
346 | } | ||
347 | LCRYPTO_ALIAS(DSO_set_name_converter); | ||
348 | |||
349 | const char * | ||
350 | DSO_get_filename(DSO *dso) | ||
351 | { | ||
352 | if (dso == NULL) { | ||
353 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
354 | return (NULL); | ||
355 | } | ||
356 | return (dso->filename); | ||
357 | } | ||
358 | LCRYPTO_ALIAS(DSO_get_filename); | ||
359 | |||
360 | int | ||
361 | DSO_set_filename(DSO *dso, const char *filename) | ||
362 | { | ||
363 | char *copied; | ||
364 | |||
365 | if ((dso == NULL) || (filename == NULL)) { | ||
366 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
367 | return (0); | ||
368 | } | ||
369 | if (dso->loaded_filename) { | ||
370 | DSOerror(DSO_R_DSO_ALREADY_LOADED); | ||
371 | return (0); | ||
372 | } | ||
373 | /* We'll duplicate filename */ | ||
374 | copied = strdup(filename); | ||
375 | if (copied == NULL) { | ||
376 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
377 | return (0); | ||
378 | } | ||
379 | free(dso->filename); | ||
380 | dso->filename = copied; | ||
381 | return (1); | ||
382 | } | ||
383 | LCRYPTO_ALIAS(DSO_set_filename); | ||
384 | |||
385 | char * | ||
386 | DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) | ||
387 | { | ||
388 | char *result = NULL; | ||
389 | |||
390 | if (dso == NULL || filespec1 == NULL) { | ||
391 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
392 | return (NULL); | ||
393 | } | ||
394 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { | ||
395 | if (dso->merger != NULL) | ||
396 | result = dso->merger(dso, filespec1, filespec2); | ||
397 | else if (dso->meth->dso_merger != NULL) | ||
398 | result = dso->meth->dso_merger(dso, | ||
399 | filespec1, filespec2); | ||
400 | } | ||
401 | return (result); | ||
402 | } | ||
403 | LCRYPTO_ALIAS(DSO_merge); | ||
404 | |||
405 | char * | ||
406 | DSO_convert_filename(DSO *dso, const char *filename) | ||
407 | { | ||
408 | char *result = NULL; | ||
409 | |||
410 | if (dso == NULL) { | ||
411 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
412 | return (NULL); | ||
413 | } | ||
414 | if (filename == NULL) | ||
415 | filename = dso->filename; | ||
416 | if (filename == NULL) { | ||
417 | DSOerror(DSO_R_NO_FILENAME); | ||
418 | return (NULL); | ||
419 | } | ||
420 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { | ||
421 | if (dso->name_converter != NULL) | ||
422 | result = dso->name_converter(dso, filename); | ||
423 | else if (dso->meth->dso_name_converter != NULL) | ||
424 | result = dso->meth->dso_name_converter(dso, filename); | ||
425 | } | ||
426 | if (result == NULL) { | ||
427 | result = strdup(filename); | ||
428 | if (result == NULL) { | ||
429 | DSOerror(ERR_R_MALLOC_FAILURE); | ||
430 | return (NULL); | ||
431 | } | ||
432 | } | ||
433 | return (result); | ||
434 | } | ||
435 | LCRYPTO_ALIAS(DSO_convert_filename); | ||
436 | |||
437 | const char * | ||
438 | DSO_get_loaded_filename(DSO *dso) | ||
439 | { | ||
440 | if (dso == NULL) { | ||
441 | DSOerror(ERR_R_PASSED_NULL_PARAMETER); | ||
442 | return (NULL); | ||
443 | } | ||
444 | return (dso->loaded_filename); | ||
445 | } | ||
446 | LCRYPTO_ALIAS(DSO_get_loaded_filename); | ||
447 | |||
448 | int | ||
449 | DSO_pathbyaddr(void *addr, char *path, int sz) | ||
450 | { | ||
451 | DSO_METHOD *meth = default_DSO_meth; | ||
452 | if (meth == NULL) | ||
453 | meth = DSO_METHOD_openssl(); | ||
454 | if (meth->pathbyaddr == NULL) { | ||
455 | DSOerror(DSO_R_UNSUPPORTED); | ||
456 | return -1; | ||
457 | } | ||
458 | return (*meth->pathbyaddr)(addr, path, sz); | ||
459 | } | ||
460 | LCRYPTO_ALIAS(DSO_pathbyaddr); | ||
461 | |||
462 | void * | ||
463 | DSO_global_lookup(const char *name) | ||
464 | { | ||
465 | DSO_METHOD *meth = default_DSO_meth; | ||
466 | if (meth == NULL) | ||
467 | meth = DSO_METHOD_openssl(); | ||
468 | if (meth->globallookup == NULL) { | ||
469 | DSOerror(DSO_R_UNSUPPORTED); | ||
470 | return NULL; | ||
471 | } | ||
472 | return (*meth->globallookup)(name); | ||
473 | } | ||
474 | LCRYPTO_ALIAS(DSO_global_lookup); | ||
diff --git a/src/lib/libcrypto/dso/dso_null.c b/src/lib/libcrypto/dso/dso_null.c deleted file mode 100644 index dfe6a84442..0000000000 --- a/src/lib/libcrypto/dso/dso_null.c +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /* $OpenBSD: dso_null.c,v 1.8 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | /* This "NULL" method is provided as the fallback for systems that have | ||
60 | * no appropriate support for "shared-libraries". */ | ||
61 | |||
62 | #include <stdio.h> | ||
63 | |||
64 | #include <openssl/dso.h> | ||
65 | |||
66 | static DSO_METHOD dso_meth_null = { | ||
67 | .name = "NULL shared library method" | ||
68 | }; | ||
69 | |||
70 | DSO_METHOD * | ||
71 | DSO_METHOD_null(void) | ||
72 | { | ||
73 | return (&dso_meth_null); | ||
74 | } | ||
75 | LCRYPTO_ALIAS(DSO_METHOD_null); | ||
diff --git a/src/lib/libcrypto/dso/dso_openssl.c b/src/lib/libcrypto/dso/dso_openssl.c deleted file mode 100644 index a639a5c7dc..0000000000 --- a/src/lib/libcrypto/dso/dso_openssl.c +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* $OpenBSD: dso_openssl.c,v 1.7 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
3 | * project 2000. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | * | ||
53 | * This product includes cryptographic software written by Eric Young | ||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
55 | * Hudson (tjh@cryptsoft.com). | ||
56 | * | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | |||
61 | #include <openssl/dso.h> | ||
62 | |||
63 | /* We just pinch the method from an appropriate "default" method. */ | ||
64 | |||
65 | DSO_METHOD * | ||
66 | DSO_METHOD_openssl(void) | ||
67 | { | ||
68 | #ifdef DEF_DSO_METHOD | ||
69 | return (DEF_DSO_METHOD()); | ||
70 | #elif defined(DSO_DLFCN) | ||
71 | return (DSO_METHOD_dlfcn()); | ||
72 | #else | ||
73 | return (DSO_METHOD_null()); | ||
74 | #endif | ||
75 | } | ||
76 | LCRYPTO_ALIAS(DSO_METHOD_openssl); | ||
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c index 01c58f39f6..2c8a273f17 100644 --- a/src/lib/libcrypto/err/err_all.c +++ b/src/lib/libcrypto/err/err_all.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: err_all.c,v 1.31 2023/07/28 09:19:59 tb Exp $ */ | 1 | /* $OpenBSD: err_all.c,v 1.32 2023/07/28 09:46:36 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -69,7 +69,6 @@ | |||
69 | #include <openssl/comp.h> | 69 | #include <openssl/comp.h> |
70 | #include <openssl/conf.h> | 70 | #include <openssl/conf.h> |
71 | #include <openssl/ct.h> | 71 | #include <openssl/ct.h> |
72 | #include <openssl/dso.h> | ||
73 | #include <openssl/err.h> | 72 | #include <openssl/err.h> |
74 | #include <openssl/evp.h> | 73 | #include <openssl/evp.h> |
75 | #include <openssl/kdf.h> | 74 | #include <openssl/kdf.h> |
@@ -128,7 +127,6 @@ ERR_load_crypto_strings_internal(void) | |||
128 | #ifndef OPENSSL_NO_DSA | 127 | #ifndef OPENSSL_NO_DSA |
129 | ERR_load_DSA_strings(); | 128 | ERR_load_DSA_strings(); |
130 | #endif | 129 | #endif |
131 | ERR_load_DSO_strings(); | ||
132 | #ifndef OPENSSL_NO_EC | 130 | #ifndef OPENSSL_NO_EC |
133 | ERR_load_EC_strings(); | 131 | ERR_load_EC_strings(); |
134 | #endif | 132 | #endif |
diff --git a/src/lib/libcrypto/hidden/openssl/dso.h b/src/lib/libcrypto/hidden/openssl/dso.h index a5e989c898..e69de29bb2 100644 --- a/src/lib/libcrypto/hidden/openssl/dso.h +++ b/src/lib/libcrypto/hidden/openssl/dso.h | |||
@@ -1,54 +0,0 @@ | |||
1 | /* $OpenBSD: dso.h,v 1.1 2023/07/08 07:22:58 beck Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #ifndef _LIBCRYPTO_DSO_H | ||
19 | #define _LIBCRYPTO_DSO_H | ||
20 | |||
21 | #ifndef _MSC_VER | ||
22 | #include_next <openssl/dso.h> | ||
23 | #else | ||
24 | #include "../include/openssl/dso.h" | ||
25 | #endif | ||
26 | #include "crypto_namespace.h" | ||
27 | |||
28 | LCRYPTO_USED(DSO_new); | ||
29 | LCRYPTO_USED(DSO_new_method); | ||
30 | LCRYPTO_USED(DSO_free); | ||
31 | LCRYPTO_USED(DSO_flags); | ||
32 | LCRYPTO_USED(DSO_up_ref); | ||
33 | LCRYPTO_USED(DSO_ctrl); | ||
34 | LCRYPTO_USED(DSO_set_name_converter); | ||
35 | LCRYPTO_USED(DSO_get_filename); | ||
36 | LCRYPTO_USED(DSO_set_filename); | ||
37 | LCRYPTO_USED(DSO_convert_filename); | ||
38 | LCRYPTO_USED(DSO_merge); | ||
39 | LCRYPTO_USED(DSO_get_loaded_filename); | ||
40 | LCRYPTO_USED(DSO_set_default_method); | ||
41 | LCRYPTO_USED(DSO_get_default_method); | ||
42 | LCRYPTO_USED(DSO_get_method); | ||
43 | LCRYPTO_USED(DSO_set_method); | ||
44 | LCRYPTO_USED(DSO_load); | ||
45 | LCRYPTO_USED(DSO_bind_var); | ||
46 | LCRYPTO_USED(DSO_bind_func); | ||
47 | LCRYPTO_USED(DSO_METHOD_openssl); | ||
48 | LCRYPTO_USED(DSO_METHOD_null); | ||
49 | LCRYPTO_USED(DSO_METHOD_dlfcn); | ||
50 | LCRYPTO_USED(DSO_pathbyaddr); | ||
51 | LCRYPTO_USED(DSO_global_lookup); | ||
52 | LCRYPTO_USED(ERR_load_DSO_strings); | ||
53 | |||
54 | #endif /* _LIBCRYPTO_DSO_H */ | ||
diff --git a/src/lib/libcrypto/opensslfeatures.h b/src/lib/libcrypto/opensslfeatures.h index 1e087f9c23..7b8d40e688 100644 --- a/src/lib/libcrypto/opensslfeatures.h +++ b/src/lib/libcrypto/opensslfeatures.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: opensslfeatures.h,v 1.39 2023/07/06 06:38:01 beck Exp $ */ | 1 | /* $OpenBSD: opensslfeatures.h,v 1.40 2023/07/28 09:46:36 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Feature flags for LibreSSL... so you can actually tell when things | 3 | * Feature flags for LibreSSL... so you can actually tell when things |
4 | * are enabled, rather than not being able to tell when things are | 4 | * are enabled, rather than not being able to tell when things are |
@@ -51,7 +51,7 @@ | |||
51 | /* #define OPENSSL_NO_DGRAM */ | 51 | /* #define OPENSSL_NO_DGRAM */ |
52 | /* #define OPENSSL_NO_DH */ | 52 | /* #define OPENSSL_NO_DH */ |
53 | /* #define OPENSSL_NO_DSA */ | 53 | /* #define OPENSSL_NO_DSA */ |
54 | /* #define OPENSSL_NO_DSO */ | 54 | #define OPENSSL_NO_DSO |
55 | /* #define OPENSSL_NO_DTLS */ | 55 | /* #define OPENSSL_NO_DTLS */ |
56 | #define OPENSSL_NO_DTLS1 | 56 | #define OPENSSL_NO_DTLS1 |
57 | #ifndef LIBRESSL_HAS_DTLS1_2 | 57 | #ifndef LIBRESSL_HAS_DTLS1_2 |