summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/err
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
committercvs2svn <admin@example.com>2025-04-14 17:32:06 +0000
commiteb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch)
treeedb6da6af7e865d488dc1a29309f1e1ec226e603 /src/lib/libcrypto/err
parent247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff)
downloadopenbsd-tb_20250414.tar.gz
openbsd-tb_20250414.tar.bz2
openbsd-tb_20250414.zip
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/lib/libcrypto/err')
-rw-r--r--src/lib/libcrypto/err/err.c1093
-rw-r--r--src/lib/libcrypto/err/err.h396
-rw-r--r--src/lib/libcrypto/err/err_all.c151
-rw-r--r--src/lib/libcrypto/err/err_local.h123
-rw-r--r--src/lib/libcrypto/err/err_prn.c119
5 files changed, 0 insertions, 1882 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c
deleted file mode 100644
index 25fbb03875..0000000000
--- a/src/lib/libcrypto/err/err.c
+++ /dev/null
@@ -1,1093 +0,0 @@
1/* $OpenBSD: err.c,v 1.75 2024/11/02 12:46:36 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <pthread.h>
113#include <stdarg.h>
114#include <stdio.h>
115#include <string.h>
116
117#include <openssl/opensslconf.h>
118
119#include <openssl/bio.h>
120#include <openssl/buffer.h>
121#include <openssl/crypto.h>
122#include <openssl/err.h>
123#include <openssl/lhash.h>
124
125DECLARE_LHASH_OF(ERR_STRING_DATA);
126DECLARE_LHASH_OF(ERR_STATE);
127
128typedef struct err_state_st {
129 pthread_t tid;
130 int err_flags[ERR_NUM_ERRORS];
131 unsigned long err_buffer[ERR_NUM_ERRORS];
132 char *err_data[ERR_NUM_ERRORS];
133 int err_data_flags[ERR_NUM_ERRORS];
134 const char *err_file[ERR_NUM_ERRORS];
135 int err_line[ERR_NUM_ERRORS];
136 int top, bottom;
137} ERR_STATE;
138
139#ifndef OPENSSL_NO_ERR
140static const ERR_STRING_DATA ERR_str_libraries[] = {
141 {ERR_PACK(ERR_LIB_NONE, 0, 0), "unknown library"},
142 {ERR_PACK(ERR_LIB_SYS, 0, 0), "system library"},
143 {ERR_PACK(ERR_LIB_BN, 0, 0), "bignum routines"},
144 {ERR_PACK(ERR_LIB_RSA, 0, 0), "rsa routines"},
145 {ERR_PACK(ERR_LIB_DH, 0, 0), "Diffie-Hellman routines"},
146 {ERR_PACK(ERR_LIB_EVP, 0, 0), "digital envelope routines"},
147 {ERR_PACK(ERR_LIB_BUF, 0, 0), "memory buffer routines"},
148 {ERR_PACK(ERR_LIB_OBJ, 0, 0), "object identifier routines"},
149 {ERR_PACK(ERR_LIB_PEM, 0, 0), "PEM routines"},
150 {ERR_PACK(ERR_LIB_DSA, 0, 0), "dsa routines"},
151 {ERR_PACK(ERR_LIB_X509, 0, 0), "x509 certificate routines"},
152 {ERR_PACK(ERR_LIB_ASN1, 0, 0), "asn1 encoding routines"},
153 {ERR_PACK(ERR_LIB_CONF, 0, 0), "configuration file routines"},
154 {ERR_PACK(ERR_LIB_CRYPTO, 0, 0), "common libcrypto routines"},
155 {ERR_PACK(ERR_LIB_EC, 0, 0), "elliptic curve routines"},
156 {ERR_PACK(ERR_LIB_SSL, 0, 0), "SSL routines"},
157 {ERR_PACK(ERR_LIB_BIO, 0, 0), "BIO routines"},
158 {ERR_PACK(ERR_LIB_PKCS7, 0, 0), "PKCS7 routines"},
159 {ERR_PACK(ERR_LIB_X509V3, 0, 0), "X509 V3 routines"},
160 {ERR_PACK(ERR_LIB_PKCS12, 0, 0), "PKCS12 routines"},
161 {ERR_PACK(ERR_LIB_RAND, 0, 0), "random number generator"},
162 {ERR_PACK(ERR_LIB_DSO, 0, 0), "DSO support routines"},
163 {ERR_PACK(ERR_LIB_TS, 0, 0), "time stamp routines"},
164 {ERR_PACK(ERR_LIB_ENGINE, 0, 0), "engine routines"},
165 {ERR_PACK(ERR_LIB_OCSP, 0, 0), "OCSP routines"},
166 {ERR_PACK(ERR_LIB_FIPS, 0, 0), "FIPS routines"},
167 {ERR_PACK(ERR_LIB_CMS, 0, 0), "CMS routines"},
168 {ERR_PACK(ERR_LIB_HMAC, 0, 0), "HMAC routines"},
169 {ERR_PACK(ERR_LIB_GOST, 0, 0), "GOST routines"},
170 {0, NULL},
171};
172
173static const ERR_STRING_DATA ERR_str_functs[] = {
174 {ERR_PACK(ERR_LIB_SYS, SYS_F_FOPEN, 0), "fopen"},
175 {ERR_PACK(ERR_LIB_SYS, SYS_F_CONNECT, 0), "connect"},
176 {ERR_PACK(ERR_LIB_SYS, SYS_F_GETSERVBYNAME, 0), "getservbyname"},
177 {ERR_PACK(ERR_LIB_SYS, SYS_F_SOCKET, 0), "socket"},
178 {ERR_PACK(ERR_LIB_SYS, SYS_F_IOCTLSOCKET, 0), "ioctl"},
179 {ERR_PACK(ERR_LIB_SYS, SYS_F_BIND, 0), "bind"},
180 {ERR_PACK(ERR_LIB_SYS, SYS_F_LISTEN, 0), "listen"},
181 {ERR_PACK(ERR_LIB_SYS, SYS_F_ACCEPT, 0), "accept"},
182 {ERR_PACK(ERR_LIB_SYS, SYS_F_OPENDIR, 0), "opendir"},
183 {ERR_PACK(ERR_LIB_SYS, SYS_F_FREAD, 0), "fread"},
184 {0, NULL},
185};
186
187static const ERR_STRING_DATA ERR_str_reasons[] = {
188 {ERR_R_SYS_LIB, "system lib"},
189 {ERR_R_BN_LIB, "BN lib"},
190 {ERR_R_RSA_LIB, "RSA lib"},
191 {ERR_R_DH_LIB, "DH lib"},
192 {ERR_R_EVP_LIB, "EVP lib"},
193 {ERR_R_BUF_LIB, "BUF lib"},
194 {ERR_R_OBJ_LIB, "OBJ lib"},
195 {ERR_R_PEM_LIB, "PEM lib"},
196 {ERR_R_DSA_LIB, "DSA lib"},
197 {ERR_R_X509_LIB, "X509 lib"},
198 {ERR_R_ASN1_LIB, "ASN1 lib"},
199 {ERR_R_CONF_LIB, "CONF lib"},
200 {ERR_R_CRYPTO_LIB, "CRYPTO lib"},
201 {ERR_R_EC_LIB, "EC lib"},
202 {ERR_R_SSL_LIB, "SSL lib"},
203 {ERR_R_BIO_LIB, "BIO lib"},
204 {ERR_R_PKCS7_LIB, "PKCS7 lib"},
205 {ERR_R_X509V3_LIB, "X509V3 lib"},
206 {ERR_R_PKCS12_LIB, "PKCS12 lib"},
207 {ERR_R_RAND_LIB, "RAND lib"},
208 {ERR_R_DSO_LIB, "DSO lib"},
209 {ERR_R_ENGINE_LIB, "ENGINE lib"},
210 {ERR_R_OCSP_LIB, "OCSP lib"},
211 {ERR_R_TS_LIB, "TS lib"},
212
213 {ERR_R_NESTED_ASN1_ERROR, "nested asn1 error"},
214 {ERR_R_BAD_ASN1_OBJECT_HEADER, "bad asn1 object header"},
215 {ERR_R_BAD_GET_ASN1_OBJECT_CALL, "bad get asn1 object call"},
216 {ERR_R_EXPECTING_AN_ASN1_SEQUENCE, "expecting an asn1 sequence"},
217 {ERR_R_ASN1_LENGTH_MISMATCH, "asn1 length mismatch"},
218 {ERR_R_MISSING_ASN1_EOS, "missing asn1 eos"},
219
220 {ERR_R_FATAL, "fatal"},
221 {ERR_R_MALLOC_FAILURE, "malloc failure"},
222 {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED, "called a function you should not call"},
223 {ERR_R_PASSED_NULL_PARAMETER, "passed a null parameter"},
224 {ERR_R_INTERNAL_ERROR, "internal error"},
225 {ERR_R_DISABLED, "called a function that was disabled at compile-time"},
226 {ERR_R_INIT_FAIL, "initialization failure"},
227
228 {0, NULL},
229};
230#endif
231
232static void ERR_STATE_free(ERR_STATE *s);
233
234/*
235 * The internal state used by "err_defaults" - as such, the setting, reading,
236 * creating, and deleting of this data should only be permitted via the
237 * "err_defaults" functions. This way, a linked module can completely defer all
238 * ERR state operation (together with requisite locking) to the implementations
239 * and state in the loading application.
240 */
241static LHASH_OF(ERR_STRING_DATA) *err_error_hash = NULL;
242static LHASH_OF(ERR_STATE) *err_thread_hash = NULL;
243static int err_thread_hash_references = 0;
244static int err_library_number = ERR_LIB_USER;
245
246static pthread_t err_init_thread;
247
248/*
249 * These are the callbacks provided to "lh_new()" when creating the LHASH tables
250 * internal to the "err_defaults" implementation.
251 */
252
253static unsigned long
254err_string_data_hash(const ERR_STRING_DATA *a)
255{
256 unsigned long ret, l;
257
258 l = a->error;
259 ret = l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
260 return (ret^ret % 19*13);
261}
262static IMPLEMENT_LHASH_HASH_FN(err_string_data, ERR_STRING_DATA)
263
264static int
265err_string_data_cmp(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b)
266{
267 return (int)(a->error - b->error);
268}
269static IMPLEMENT_LHASH_COMP_FN(err_string_data, ERR_STRING_DATA)
270
271static LHASH_OF(ERR_STRING_DATA) *
272err_get(int create)
273{
274 LHASH_OF(ERR_STRING_DATA) *ret = NULL;
275
276 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
277 if (!err_error_hash && create)
278 err_error_hash = lh_ERR_STRING_DATA_new();
279 if (err_error_hash)
280 ret = err_error_hash;
281 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
282
283 return ret;
284}
285
286static void
287err_del(void)
288{
289 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
290 if (err_error_hash) {
291 lh_ERR_STRING_DATA_free(err_error_hash);
292 err_error_hash = NULL;
293 }
294 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
295}
296
297static const ERR_STRING_DATA *
298err_get_item(const ERR_STRING_DATA *d)
299{
300 ERR_STRING_DATA *p;
301 LHASH_OF(ERR_STRING_DATA) *hash;
302
303 hash = err_get(0);
304 if (!hash)
305 return NULL;
306
307 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
308 p = lh_ERR_STRING_DATA_retrieve(hash, d);
309 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
310
311 return p;
312}
313
314static const ERR_STRING_DATA *
315err_set_item(const ERR_STRING_DATA *d)
316{
317 const ERR_STRING_DATA *p;
318 LHASH_OF(ERR_STRING_DATA) *hash;
319
320 hash = err_get(1);
321 if (!hash)
322 return NULL;
323
324 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
325 p = lh_ERR_STRING_DATA_insert(hash, (void *)d);
326 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
327
328 return p;
329}
330
331static const ERR_STRING_DATA *
332err_del_item(const ERR_STRING_DATA *d)
333{
334 ERR_STRING_DATA *p;
335 LHASH_OF(ERR_STRING_DATA) *hash;
336
337 hash = err_get(0);
338 if (!hash)
339 return NULL;
340
341 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
342 p = lh_ERR_STRING_DATA_delete(hash, d);
343 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
344
345 return p;
346}
347
348static unsigned long
349err_state_hash(const ERR_STATE *a)
350{
351 return 13 * (unsigned long)a->tid;
352}
353static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE)
354
355static int
356err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
357{
358 return pthread_equal(a->tid, b->tid) == 0;
359}
360static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE)
361
362static LHASH_OF(ERR_STATE) *
363err_thread_get(int create)
364{
365 LHASH_OF(ERR_STATE) *ret = NULL;
366
367 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
368 if (!err_thread_hash && create)
369 err_thread_hash = lh_ERR_STATE_new();
370 if (err_thread_hash) {
371 err_thread_hash_references++;
372 ret = err_thread_hash;
373 }
374 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
375 return ret;
376}
377
378static void
379err_thread_release(LHASH_OF(ERR_STATE) **hash)
380{
381 int i;
382
383 if (hash == NULL || *hash == NULL)
384 return;
385
386 i = CRYPTO_add(&err_thread_hash_references, -1, CRYPTO_LOCK_ERR);
387 if (i > 0)
388 return;
389
390 *hash = NULL;
391}
392
393static ERR_STATE *
394err_thread_get_item(const ERR_STATE *d)
395{
396 ERR_STATE *p;
397 LHASH_OF(ERR_STATE) *hash;
398
399 hash = err_thread_get(0);
400 if (!hash)
401 return NULL;
402
403 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
404 p = lh_ERR_STATE_retrieve(hash, d);
405 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
406
407 err_thread_release(&hash);
408 return p;
409}
410
411static ERR_STATE *
412err_thread_set_item(ERR_STATE *d)
413{
414 ERR_STATE *p;
415 LHASH_OF(ERR_STATE) *hash;
416
417 hash = err_thread_get(1);
418 if (!hash)
419 return NULL;
420
421 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
422 p = lh_ERR_STATE_insert(hash, d);
423 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
424
425 err_thread_release(&hash);
426 return p;
427}
428
429static void
430err_thread_del_item(const ERR_STATE *d)
431{
432 ERR_STATE *p;
433 LHASH_OF(ERR_STATE) *hash;
434
435 hash = err_thread_get(0);
436 if (!hash)
437 return;
438
439 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
440 p = lh_ERR_STATE_delete(hash, d);
441 /* make sure we don't leak memory */
442 if (err_thread_hash_references == 1 &&
443 err_thread_hash && lh_ERR_STATE_num_items(err_thread_hash) == 0) {
444 lh_ERR_STATE_free(err_thread_hash);
445 err_thread_hash = NULL;
446 }
447 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
448
449 err_thread_release(&hash);
450 if (p)
451 ERR_STATE_free(p);
452}
453
454static int
455err_get_next_lib(void)
456{
457 int ret;
458
459 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
460 ret = err_library_number++;
461 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
462
463 return ret;
464}
465
466
467#ifndef OPENSSL_NO_ERR
468#define NUM_SYS_STR_REASONS 127
469#define LEN_SYS_STR_REASON 32
470
471static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
472
473/*
474 * SYS_str_reasons is filled with copies of strerror() results at
475 * initialization. 'errno' values up to 127 should cover all usual errors,
476 * others will be displayed numerically by ERR_error_string. It is crucial that
477 * we have something for each reason code that occurs in ERR_str_reasons, or
478 * bogus reason strings will be returned for SYSerror(), which always gets an
479 * errno value and never one of those 'standard' reason codes.
480 */
481
482static void
483err_build_SYS_str_reasons(void)
484{
485 /* malloc cannot be used here, use static storage instead */
486 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
487 int save_errno;
488 int i;
489
490 /* strerror(3) will set errno to EINVAL when i is an unknown errno. */
491 save_errno = errno;
492 for (i = 1; i <= NUM_SYS_STR_REASONS; i++) {
493 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
494
495 str->error = (unsigned long)i;
496 if (str->string == NULL) {
497 char (*dest)[LEN_SYS_STR_REASON] =
498 &(strerror_tab[i - 1]);
499 const char *src = strerror(i);
500 if (src != NULL) {
501 strlcpy(*dest, src, sizeof *dest);
502 str->string = *dest;
503 }
504 }
505 if (str->string == NULL)
506 str->string = "unknown";
507 }
508 errno = save_errno;
509
510 /*
511 * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
512 * as required by ERR_load_strings.
513 */
514}
515#endif
516
517static void
518err_clear_data(ERR_STATE *s, int i)
519{
520 if ((s->err_data_flags[i] & ERR_TXT_MALLOCED) != 0)
521 free(s->err_data[i]);
522
523 s->err_data[i] = NULL;
524 s->err_data_flags[i] = 0;
525}
526
527static void
528err_clear(ERR_STATE *s, int i)
529{
530 s->err_flags[i] = 0;
531 s->err_buffer[i] = 0;
532 s->err_file[i] = NULL;
533 s->err_line[i] = -1;
534
535 err_clear_data(s, i);
536}
537
538static void
539ERR_STATE_free(ERR_STATE *s)
540{
541 int i;
542
543 if (s == NULL)
544 return;
545
546 for (i = 0; i < ERR_NUM_ERRORS; i++)
547 err_clear_data(s, i);
548
549 free(s);
550}
551
552static ERR_STATE *
553ERR_get_state(void)
554{
555 static ERR_STATE fallback;
556 ERR_STATE *ret, tmp, *tmpp = NULL;
557 int i;
558
559 tmp.tid = pthread_self();
560 ret = err_thread_get_item(&tmp);
561
562 /* ret == the error state, if NULL, make a new one */
563 if (ret == NULL) {
564 ret = malloc(sizeof(ERR_STATE));
565 if (ret == NULL)
566 return (&fallback);
567 ret->tid = pthread_self();
568 ret->top = 0;
569 ret->bottom = 0;
570 for (i = 0; i < ERR_NUM_ERRORS; i++) {
571 ret->err_data[i] = NULL;
572 ret->err_data_flags[i] = 0;
573 }
574 tmpp = err_thread_set_item(ret);
575 /* To check if insertion failed, do a get. */
576 if (err_thread_get_item(ret) != ret) {
577 ERR_STATE_free(ret); /* could not insert it */
578 return (&fallback);
579 }
580 /*
581 * If a race occurred in this function and we came second,
582 * tmpp is the first one that we just replaced.
583 */
584 if (tmpp)
585 ERR_STATE_free(tmpp);
586 }
587 return ret;
588}
589
590static void
591err_load_strings(int lib, ERR_STRING_DATA *str)
592{
593 while (str->error != 0) {
594 if (lib)
595 str->error |= ERR_PACK(lib, 0, 0);
596 err_set_item(str);
597 str++;
598 }
599}
600
601static void
602err_load_const_strings(const ERR_STRING_DATA *str)
603{
604 while (str->error != 0) {
605 err_set_item(str);
606 str++;
607 }
608}
609
610static unsigned long
611get_error_values(int inc, int top, const char **file, int *line,
612 const char **data, int *flags)
613{
614 int i = 0;
615 ERR_STATE *es;
616 unsigned long ret;
617
618 es = ERR_get_state();
619
620 if (inc && top) {
621 if (file)
622 *file = "";
623 if (line)
624 *line = 0;
625 if (data)
626 *data = "";
627 if (flags)
628 *flags = 0;
629
630 return ERR_R_INTERNAL_ERROR;
631 }
632
633 if (es->bottom == es->top)
634 return 0;
635 if (top)
636 i = es->top; /* last error */
637 else
638 i = (es->bottom + 1) % ERR_NUM_ERRORS; /* first error */
639
640 ret = es->err_buffer[i];
641 if (inc) {
642 es->bottom = i;
643 es->err_buffer[i] = 0;
644 }
645
646 if ((file != NULL) && (line != NULL)) {
647 if (es->err_file[i] == NULL) {
648 *file = "NA";
649 if (line != NULL)
650 *line = 0;
651 } else {
652 *file = es->err_file[i];
653 if (line != NULL)
654 *line = es->err_line[i];
655 }
656 }
657
658 if (data == NULL) {
659 if (inc) {
660 err_clear_data(es, i);
661 }
662 } else {
663 if (es->err_data[i] == NULL) {
664 *data = "";
665 if (flags != NULL)
666 *flags = 0;
667 } else {
668 *data = es->err_data[i];
669 if (flags != NULL)
670 *flags = es->err_data_flags[i];
671 }
672 }
673 return ret;
674}
675
676void
677ERR_load_ERR_strings_internal(void)
678{
679 err_init_thread = pthread_self();
680#ifndef OPENSSL_NO_ERR
681 err_load_const_strings(ERR_str_libraries);
682 err_load_const_strings(ERR_str_reasons);
683 err_load_const_strings(ERR_str_functs);
684 err_build_SYS_str_reasons();
685 err_load_strings(ERR_LIB_SYS, SYS_str_reasons);
686#endif
687}
688
689void
690ERR_load_ERR_strings(void)
691{
692 static pthread_once_t once = PTHREAD_ONCE_INIT;
693
694 if (pthread_equal(pthread_self(), err_init_thread))
695 return; /* don't recurse */
696
697 /* Prayer and clean living lets you ignore errors, OpenSSL style */
698 (void) OPENSSL_init_crypto(0, NULL);
699
700 (void) pthread_once(&once, ERR_load_ERR_strings_internal);
701}
702LCRYPTO_ALIAS(ERR_load_ERR_strings);
703
704void
705ERR_load_strings(int lib, ERR_STRING_DATA *str)
706{
707 ERR_load_ERR_strings();
708 err_load_strings(lib, str);
709}
710LCRYPTO_ALIAS(ERR_load_strings);
711
712void
713ERR_load_const_strings(const ERR_STRING_DATA *str)
714{
715 ERR_load_ERR_strings();
716 err_load_const_strings(str);
717}
718
719void
720ERR_unload_strings(int lib, ERR_STRING_DATA *str)
721{
722 /* Prayer and clean living lets you ignore errors, OpenSSL style */
723 (void) OPENSSL_init_crypto(0, NULL);
724
725 while (str->error) {
726 if (lib)
727 str->error |= ERR_PACK(lib, 0, 0);
728 err_del_item(str);
729 str++;
730 }
731}
732LCRYPTO_ALIAS(ERR_unload_strings);
733
734void
735ERR_free_strings(void)
736{
737 /* Prayer and clean living lets you ignore errors, OpenSSL style */
738 (void) OPENSSL_init_crypto(0, NULL);
739
740 err_del();
741}
742LCRYPTO_ALIAS(ERR_free_strings);
743
744int
745ERR_get_next_error_library(void)
746{
747 return err_get_next_lib();
748}
749LCRYPTO_ALIAS(ERR_get_next_error_library);
750
751void
752ERR_remove_thread_state(const CRYPTO_THREADID *id)
753{
754 ERR_STATE tmp;
755
756 OPENSSL_assert(id == NULL);
757 tmp.tid = pthread_self();
758
759 /*
760 * err_thread_del_item automatically destroys the LHASH if the number of
761 * items reaches zero.
762 */
763 err_thread_del_item(&tmp);
764}
765LCRYPTO_ALIAS(ERR_remove_thread_state);
766
767void
768ERR_remove_state(unsigned long pid)
769{
770 ERR_remove_thread_state(NULL);
771}
772LCRYPTO_ALIAS(ERR_remove_state);
773
774int
775ERR_set_mark(void)
776{
777 ERR_STATE *es;
778
779 es = ERR_get_state();
780
781 if (es->bottom == es->top)
782 return 0;
783 es->err_flags[es->top] |= ERR_FLAG_MARK;
784 return 1;
785}
786LCRYPTO_ALIAS(ERR_set_mark);
787
788int
789ERR_pop_to_mark(void)
790{
791 ERR_STATE *es;
792
793 es = ERR_get_state();
794
795 while (es->bottom != es->top &&
796 (es->err_flags[es->top] & ERR_FLAG_MARK) == 0) {
797 err_clear(es, es->top);
798 es->top -= 1;
799 if (es->top == -1)
800 es->top = ERR_NUM_ERRORS - 1;
801 }
802
803 if (es->bottom == es->top)
804 return 0;
805 es->err_flags[es->top]&=~ERR_FLAG_MARK;
806 return 1;
807}
808LCRYPTO_ALIAS(ERR_pop_to_mark);
809
810void
811ERR_clear_error(void)
812{
813 int i;
814 ERR_STATE *es;
815
816 es = ERR_get_state();
817
818 for (i = 0; i < ERR_NUM_ERRORS; i++)
819 err_clear(es, i);
820
821 es->top = es->bottom = 0;
822}
823LCRYPTO_ALIAS(ERR_clear_error);
824
825void
826err_clear_last_constant_time(int clear)
827{
828 ERR_STATE *es;
829 int top;
830
831 es = ERR_get_state();
832 if (es == NULL)
833 return;
834
835 top = es->top;
836
837 es->err_flags[top] &= ~(0 - clear);
838 es->err_buffer[top] &= ~(0UL - clear);
839 es->err_file[top] = (const char *)((uintptr_t)es->err_file[top] &
840 ~((uintptr_t)0 - clear));
841 es->err_line[top] |= 0 - clear;
842
843 es->top = (top + ERR_NUM_ERRORS - clear) % ERR_NUM_ERRORS;
844}
845
846void
847ERR_put_error(int lib, int func, int reason, const char *file, int line)
848{
849 ERR_STATE *es;
850 int save_errno = errno;
851
852 es = ERR_get_state();
853
854 es->top = (es->top + 1) % ERR_NUM_ERRORS;
855 if (es->top == es->bottom)
856 es->bottom = (es->bottom + 1) % ERR_NUM_ERRORS;
857 es->err_flags[es->top] = 0;
858 es->err_buffer[es->top] = ERR_PACK(lib, func, reason);
859 es->err_file[es->top] = file;
860 es->err_line[es->top] = line;
861 err_clear_data(es, es->top);
862 errno = save_errno;
863}
864LCRYPTO_ALIAS(ERR_put_error);
865
866void
867ERR_asprintf_error_data(char * format, ...)
868{
869 char *errbuf = NULL;
870 va_list ap;
871 int r;
872
873 va_start(ap, format);
874 r = vasprintf(&errbuf, format, ap);
875 va_end(ap);
876 if (r == -1)
877 ERR_set_error_data("malloc failed", ERR_TXT_STRING);
878 else
879 ERR_set_error_data(errbuf, ERR_TXT_MALLOCED|ERR_TXT_STRING);
880}
881LCRYPTO_ALIAS(ERR_asprintf_error_data);
882
883void
884ERR_set_error_data(char *data, int flags)
885{
886 ERR_STATE *es;
887 int i;
888
889 es = ERR_get_state();
890
891 i = es->top;
892 if (i == 0)
893 i = ERR_NUM_ERRORS - 1;
894
895 err_clear_data(es, i);
896 es->err_data[i] = data;
897 es->err_data_flags[i] = flags;
898}
899LCRYPTO_ALIAS(ERR_set_error_data);
900
901unsigned long
902ERR_get_error(void)
903{
904 return (get_error_values(1, 0, NULL, NULL, NULL, NULL));
905}
906LCRYPTO_ALIAS(ERR_get_error);
907
908unsigned long
909ERR_get_error_line(const char **file, int *line)
910{
911 return (get_error_values(1, 0, file, line, NULL, NULL));
912}
913LCRYPTO_ALIAS(ERR_get_error_line);
914
915unsigned long
916ERR_get_error_line_data(const char **file, int *line,
917 const char **data, int *flags)
918{
919 return (get_error_values(1, 0, file, line, data, flags));
920}
921LCRYPTO_ALIAS(ERR_get_error_line_data);
922
923unsigned long
924ERR_peek_error(void)
925{
926 return (get_error_values(0, 0, NULL, NULL, NULL, NULL));
927}
928LCRYPTO_ALIAS(ERR_peek_error);
929
930unsigned long
931ERR_peek_error_line(const char **file, int *line)
932{
933 return (get_error_values(0, 0, file, line, NULL, NULL));
934}
935LCRYPTO_ALIAS(ERR_peek_error_line);
936
937unsigned long
938ERR_peek_error_line_data(const char **file, int *line,
939 const char **data, int *flags)
940{
941 return (get_error_values(0, 0, file, line, data, flags));
942}
943LCRYPTO_ALIAS(ERR_peek_error_line_data);
944
945unsigned long
946ERR_peek_last_error(void)
947{
948 return (get_error_values(0, 1, NULL, NULL, NULL, NULL));
949}
950LCRYPTO_ALIAS(ERR_peek_last_error);
951
952unsigned long
953ERR_peek_last_error_line(const char **file, int *line)
954{
955 return (get_error_values(0, 1, file, line, NULL, NULL));
956}
957LCRYPTO_ALIAS(ERR_peek_last_error_line);
958
959unsigned long
960ERR_peek_last_error_line_data(const char **file, int *line,
961 const char **data, int *flags)
962{
963 return (get_error_values(0, 1, file, line, data, flags));
964}
965LCRYPTO_ALIAS(ERR_peek_last_error_line_data);
966
967const char *
968ERR_lib_error_string(unsigned long e)
969{
970 const ERR_STRING_DATA *p;
971 ERR_STRING_DATA d;
972 unsigned long l;
973
974 if (!OPENSSL_init_crypto(0, NULL))
975 return NULL;
976
977 l = ERR_GET_LIB(e);
978 d.error = ERR_PACK(l, 0, 0);
979 p = err_get_item(&d);
980 return ((p == NULL) ? NULL : p->string);
981}
982LCRYPTO_ALIAS(ERR_lib_error_string);
983
984const char *
985ERR_func_error_string(unsigned long e)
986{
987 const ERR_STRING_DATA *p;
988 ERR_STRING_DATA d;
989 unsigned long l, f;
990
991 l = ERR_GET_LIB(e);
992 f = ERR_GET_FUNC(e);
993 d.error = ERR_PACK(l, f, 0);
994 p = err_get_item(&d);
995 return ((p == NULL) ? NULL : p->string);
996}
997LCRYPTO_ALIAS(ERR_func_error_string);
998
999const char *
1000ERR_reason_error_string(unsigned long e)
1001{
1002 const ERR_STRING_DATA *p = NULL;
1003 ERR_STRING_DATA d;
1004 unsigned long l, r;
1005
1006 l = ERR_GET_LIB(e);
1007 r = ERR_GET_REASON(e);
1008 d.error = ERR_PACK(l, 0, r);
1009 p = err_get_item(&d);
1010 if (!p) {
1011 d.error = ERR_PACK(0, 0, r);
1012 p = err_get_item(&d);
1013 }
1014 return ((p == NULL) ? NULL : p->string);
1015}
1016LCRYPTO_ALIAS(ERR_reason_error_string);
1017
1018void
1019ERR_error_string_n(unsigned long e, char *buf, size_t len)
1020{
1021 char lsbuf[30], fsbuf[30], rsbuf[30];
1022 const char *ls, *fs, *rs;
1023 int l, f, r, ret;
1024
1025 l = ERR_GET_LIB(e);
1026 f = ERR_GET_FUNC(e);
1027 r = ERR_GET_REASON(e);
1028
1029 ls = ERR_lib_error_string(e);
1030 fs = ERR_func_error_string(e);
1031 rs = ERR_reason_error_string(e);
1032
1033 if (ls == NULL) {
1034 (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l);
1035 ls = lsbuf;
1036 }
1037 if (fs == NULL) {
1038 (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f);
1039 fs = fsbuf;
1040 }
1041 if (rs == NULL) {
1042 (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r);
1043 rs = rsbuf;
1044 }
1045
1046 ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs);
1047 if (ret == -1)
1048 return; /* can't happen, and can't do better if it does */
1049 if (ret >= len) {
1050 /*
1051 * output may be truncated; make sure we always have 5
1052 * colon-separated fields, i.e. 4 colons ...
1053 */
1054#define NUM_COLONS 4
1055 if (len > NUM_COLONS) /* ... if possible */
1056 {
1057 int i;
1058 char *s = buf;
1059
1060 for (i = 0; i < NUM_COLONS; i++) {
1061 char *colon = strchr(s, ':');
1062 if (colon == NULL ||
1063 colon > &buf[len - 1] - NUM_COLONS + i) {
1064 /* set colon no. i at last possible position
1065 * (buf[len-1] is the terminating 0)*/
1066 colon = &buf[len - 1] - NUM_COLONS + i;
1067 *colon = ':';
1068 }
1069 s = colon + 1;
1070 }
1071 }
1072 }
1073}
1074LCRYPTO_ALIAS(ERR_error_string_n);
1075
1076/*
1077 * ERR_error_string_n should be used instead for ret != NULL
1078 * as ERR_error_string cannot know how large the buffer is.
1079 *
1080 * BAD for multi-threading: uses a local buffer if ret == NULL.
1081 */
1082char *
1083ERR_error_string(unsigned long e, char *ret)
1084{
1085 static char buf[256];
1086
1087 if (ret == NULL)
1088 ret = buf;
1089 ERR_error_string_n(e, ret, 256);
1090
1091 return ret;
1092}
1093LCRYPTO_ALIAS(ERR_error_string);
diff --git a/src/lib/libcrypto/err/err.h b/src/lib/libcrypto/err/err.h
deleted file mode 100644
index fe6c34dd0a..0000000000
--- a/src/lib/libcrypto/err/err.h
+++ /dev/null
@@ -1,396 +0,0 @@
1/* $OpenBSD: err.h,v 1.36 2025/03/09 15:12:18 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#ifndef HEADER_ERR_H
113#define HEADER_ERR_H
114
115#include <openssl/opensslconf.h>
116
117#include <stdio.h>
118#include <stdlib.h>
119
120#include <openssl/ossl_typ.h>
121#ifndef OPENSSL_NO_BIO
122#include <openssl/bio.h>
123#endif
124#ifndef OPENSSL_NO_LHASH
125#include <openssl/lhash.h>
126#endif
127
128#ifdef __cplusplus
129extern "C" {
130#endif
131
132#ifndef OPENSSL_NO_FILENAMES
133#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
134#else
135#define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
136#endif
137
138#include <errno.h>
139
140#define ERR_TXT_MALLOCED 0x01
141#define ERR_TXT_STRING 0x02
142
143#define ERR_FLAG_MARK 0x01
144
145#define ERR_NUM_ERRORS 16
146
147/* library */
148#define ERR_LIB_NONE 1
149#define ERR_LIB_SYS 2
150#define ERR_LIB_BN 3
151#define ERR_LIB_RSA 4
152#define ERR_LIB_DH 5
153#define ERR_LIB_EVP 6
154#define ERR_LIB_BUF 7
155#define ERR_LIB_OBJ 8
156#define ERR_LIB_PEM 9
157#define ERR_LIB_DSA 10
158#define ERR_LIB_X509 11
159/* #define ERR_LIB_METH 12 */
160#define ERR_LIB_ASN1 13
161#define ERR_LIB_CONF 14
162#define ERR_LIB_CRYPTO 15
163#define ERR_LIB_EC 16
164#define ERR_LIB_SSL 20
165/* #define ERR_LIB_SSL23 21 */
166/* #define ERR_LIB_SSL2 22 */
167/* #define ERR_LIB_SSL3 23 */
168/* #define ERR_LIB_RSAREF 30 */
169/* #define ERR_LIB_PROXY 31 */
170#define ERR_LIB_BIO 32
171#define ERR_LIB_PKCS7 33
172#define ERR_LIB_X509V3 34
173#define ERR_LIB_PKCS12 35
174#define ERR_LIB_RAND 36
175#define ERR_LIB_DSO 37
176#define ERR_LIB_ENGINE 38
177#define ERR_LIB_OCSP 39
178#define ERR_LIB_UI 40
179#define ERR_LIB_COMP 41
180#define ERR_LIB_ECDSA 42
181#define ERR_LIB_ECDH 43
182#define ERR_LIB_STORE 44
183#define ERR_LIB_FIPS 45
184#define ERR_LIB_CMS 46
185#define ERR_LIB_TS 47
186#define ERR_LIB_HMAC 48
187#define ERR_LIB_JPAKE 49
188#define ERR_LIB_GOST 50
189#define ERR_LIB_CT 51
190#define ERR_LIB_KDF 52
191
192#define ERR_LIB_USER 128
193
194#ifndef LIBRESSL_INTERNAL
195#define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
196#define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
197#define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
198#define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
199#define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
200#define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
201#define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
202#define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
203#define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
204#define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
205#define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
206#define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
207#define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
208#define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
209#define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
210#define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
211#define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
212#define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
213#define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
214#define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
215#define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
216#define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
217#define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
218#define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
219#define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
220#define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
221#define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
222#define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
223#define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
224#define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
225#define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
226#define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
227#define GOSTerr(f,r) ERR_PUT_error(ERR_LIB_GOST,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
228#define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
229#define CTerr(f, r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
230#define KDFerr(f, r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
231#endif
232
233#ifdef LIBRESSL_INTERNAL
234#define SYSerror(r) ERR_PUT_error(ERR_LIB_SYS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
235#define BNerror(r) ERR_PUT_error(ERR_LIB_BN,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
236#define RSAerror(r) ERR_PUT_error(ERR_LIB_RSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
237#define DHerror(r) ERR_PUT_error(ERR_LIB_DH,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
238#define EVPerror(r) ERR_PUT_error(ERR_LIB_EVP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
239#define BUFerror(r) ERR_PUT_error(ERR_LIB_BUF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
240#define OBJerror(r) ERR_PUT_error(ERR_LIB_OBJ,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
241#define PEMerror(r) ERR_PUT_error(ERR_LIB_PEM,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
242#define DSAerror(r) ERR_PUT_error(ERR_LIB_DSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
243#define X509error(r) ERR_PUT_error(ERR_LIB_X509,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
244#define ASN1error(r) ERR_PUT_error(ERR_LIB_ASN1,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
245#define CONFerror(r) ERR_PUT_error(ERR_LIB_CONF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
246#define CRYPTOerror(r) ERR_PUT_error(ERR_LIB_CRYPTO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
247#define ECerror(r) ERR_PUT_error(ERR_LIB_EC,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
248#define BIOerror(r) ERR_PUT_error(ERR_LIB_BIO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
249#define PKCS7error(r) ERR_PUT_error(ERR_LIB_PKCS7,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
250#define X509V3error(r) ERR_PUT_error(ERR_LIB_X509V3,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
251#define PKCS12error(r) ERR_PUT_error(ERR_LIB_PKCS12,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
252#define RANDerror(r) ERR_PUT_error(ERR_LIB_RAND,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
253#define DSOerror(r) ERR_PUT_error(ERR_LIB_DSO,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
254#define ENGINEerror(r) ERR_PUT_error(ERR_LIB_ENGINE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
255#define OCSPerror(r) ERR_PUT_error(ERR_LIB_OCSP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
256#define UIerror(r) ERR_PUT_error(ERR_LIB_UI,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
257#define COMPerror(r) ERR_PUT_error(ERR_LIB_COMP,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
258#define ECDSAerror(r) ERR_PUT_error(ERR_LIB_ECDSA,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
259#define ECDHerror(r) ERR_PUT_error(ERR_LIB_ECDH,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
260#define STOREerror(r) ERR_PUT_error(ERR_LIB_STORE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
261#define FIPSerror(r) ERR_PUT_error(ERR_LIB_FIPS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
262#define CMSerror(r) ERR_PUT_error(ERR_LIB_CMS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
263#define TSerror(r) ERR_PUT_error(ERR_LIB_TS,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
264#define HMACerror(r) ERR_PUT_error(ERR_LIB_HMAC,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
265#define JPAKEerror(r) ERR_PUT_error(ERR_LIB_JPAKE,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
266#define GOSTerror(r) ERR_PUT_error(ERR_LIB_GOST,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
267#define CTerror(r) ERR_PUT_error(ERR_LIB_CT,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
268#define KDFerror(r) ERR_PUT_error(ERR_LIB_KDF,(0xfff),(r),OPENSSL_FILE,OPENSSL_LINE)
269#endif
270
271#define ERR_PACK(l,f,r) (((((unsigned long)l)&0xffL)<<24L)| \
272 ((((unsigned long)f)&0xfffL)<<12L)| \
273 ((((unsigned long)r)&0xfffL)))
274#define ERR_GET_LIB(l) (int)((((unsigned long)l)>>24L)&0xffL)
275#define ERR_GET_FUNC(l) (int)((((unsigned long)l)>>12L)&0xfffL)
276#define ERR_GET_REASON(l) (int)((l)&0xfffL)
277#define ERR_FATAL_ERROR(l) (int)((l)&ERR_R_FATAL)
278
279
280/* OS functions */
281#define SYS_F_FOPEN 1
282#define SYS_F_CONNECT 2
283#define SYS_F_GETSERVBYNAME 3
284#define SYS_F_SOCKET 4
285#define SYS_F_IOCTLSOCKET 5
286#define SYS_F_BIND 6
287#define SYS_F_LISTEN 7
288#define SYS_F_ACCEPT 8
289#define SYS_F_WSASTARTUP 9 /* Winsock stuff */
290#define SYS_F_OPENDIR 10
291#define SYS_F_FREAD 11
292
293
294/* reasons */
295#define ERR_R_SYS_LIB ERR_LIB_SYS /* 2 */
296#define ERR_R_BN_LIB ERR_LIB_BN /* 3 */
297#define ERR_R_RSA_LIB ERR_LIB_RSA /* 4 */
298#define ERR_R_DH_LIB ERR_LIB_DH /* 5 */
299#define ERR_R_EVP_LIB ERR_LIB_EVP /* 6 */
300#define ERR_R_BUF_LIB ERR_LIB_BUF /* 7 */
301#define ERR_R_OBJ_LIB ERR_LIB_OBJ /* 8 */
302#define ERR_R_PEM_LIB ERR_LIB_PEM /* 9 */
303#define ERR_R_DSA_LIB ERR_LIB_DSA /* 10 */
304#define ERR_R_X509_LIB ERR_LIB_X509 /* 11 */
305#define ERR_R_ASN1_LIB ERR_LIB_ASN1 /* 13 */
306#define ERR_R_CONF_LIB ERR_LIB_CONF /* 14 */
307#define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO /* 15 */
308#define ERR_R_EC_LIB ERR_LIB_EC /* 16 */
309#define ERR_R_SSL_LIB ERR_LIB_SSL /* 20 */
310#define ERR_R_BIO_LIB ERR_LIB_BIO /* 32 */
311#define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 /* 33 */
312#define ERR_R_X509V3_LIB ERR_LIB_X509V3 /* 34 */
313#define ERR_R_PKCS12_LIB ERR_LIB_PKCS12 /* 35 */
314#define ERR_R_RAND_LIB ERR_LIB_RAND /* 36 */
315#define ERR_R_DSO_LIB ERR_LIB_DSO /* 37 */
316#define ERR_R_ENGINE_LIB ERR_LIB_ENGINE /* 38 */
317#define ERR_R_OCSP_LIB ERR_LIB_OCSP /* 39 */
318#define ERR_R_UI_LIB ERR_LIB_UI /* 40 */
319#define ERR_R_COMP_LIB ERR_LIB_COMP /* 41 */
320#define ERR_R_ECDSA_LIB ERR_LIB_ECDSA /* 42 */
321#define ERR_R_ECDH_LIB ERR_LIB_ECDH /* 43 */
322#define ERR_R_STORE_LIB ERR_LIB_STORE /* 44 */
323#define ERR_R_TS_LIB ERR_LIB_TS /* 45 */
324
325#define ERR_R_NESTED_ASN1_ERROR 58
326#define ERR_R_BAD_ASN1_OBJECT_HEADER 59
327#define ERR_R_BAD_GET_ASN1_OBJECT_CALL 60
328#define ERR_R_EXPECTING_AN_ASN1_SEQUENCE 61
329#define ERR_R_ASN1_LENGTH_MISMATCH 62
330#define ERR_R_MISSING_ASN1_EOS 63
331
332/* fatal error */
333#define ERR_R_FATAL 64
334#define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
335#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
336#define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
337#define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
338#define ERR_R_DISABLED (5|ERR_R_FATAL)
339#define ERR_R_INIT_FAIL (6|ERR_R_FATAL)
340
341/* 99 is the maximum possible ERR_R_... code, higher values
342 * are reserved for the individual libraries */
343
344typedef struct ERR_string_data_st {
345 unsigned long error;
346 const char *string;
347} ERR_STRING_DATA;
348
349void ERR_put_error(int lib, int func, int reason, const char *file, int line);
350void ERR_set_error_data(char *data, int flags);
351
352unsigned long ERR_get_error(void);
353unsigned long ERR_get_error_line(const char **file, int *line);
354unsigned long ERR_get_error_line_data(const char **file, int *line,
355 const char **data, int *flags);
356unsigned long ERR_peek_error(void);
357unsigned long ERR_peek_error_line(const char **file, int *line);
358unsigned long ERR_peek_error_line_data(const char **file, int *line,
359 const char **data, int *flags);
360unsigned long ERR_peek_last_error(void);
361unsigned long ERR_peek_last_error_line(const char **file, int *line);
362unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
363 const char **data, int *flags);
364void ERR_clear_error(void );
365char *ERR_error_string(unsigned long e, char *buf);
366void ERR_error_string_n(unsigned long e, char *buf, size_t len);
367const char *ERR_lib_error_string(unsigned long e);
368const char *ERR_func_error_string(unsigned long e);
369const char *ERR_reason_error_string(unsigned long e);
370void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
371 void *u);
372void ERR_print_errors_fp(FILE *fp);
373#ifndef OPENSSL_NO_BIO
374void ERR_print_errors(BIO *bp);
375#endif
376void ERR_asprintf_error_data(char * format, ...);
377void ERR_load_strings(int lib, ERR_STRING_DATA *str);
378void ERR_unload_strings(int lib, ERR_STRING_DATA *str);
379void ERR_load_ERR_strings(void);
380void ERR_load_crypto_strings(void);
381void ERR_free_strings(void);
382
383void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
384/* Wrapped in OPENSSL_NO_DEPRECATED in 0.9.8. Still used in 2023. */
385void ERR_remove_state(unsigned long pid);
386
387int ERR_get_next_error_library(void);
388
389int ERR_set_mark(void);
390int ERR_pop_to_mark(void);
391
392#ifdef __cplusplus
393}
394#endif
395
396#endif
diff --git a/src/lib/libcrypto/err/err_all.c b/src/lib/libcrypto/err/err_all.c
deleted file mode 100644
index 9f135a2f58..0000000000
--- a/src/lib/libcrypto/err/err_all.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/* $OpenBSD: err_all.c,v 1.36 2024/03/29 02:22:18 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <pthread.h>
60#include <stdio.h>
61
62#include <openssl/opensslconf.h>
63
64#include <openssl/asn1.h>
65#include <openssl/bio.h>
66#include <openssl/bn.h>
67#include <openssl/buffer.h>
68#include <openssl/cms.h>
69#include <openssl/comp.h>
70#include <openssl/conf.h>
71#include <openssl/ct.h>
72#include <openssl/err.h>
73#include <openssl/evp.h>
74#include <openssl/kdf.h>
75#include <openssl/objects.h>
76#include <openssl/ocsp.h>
77#include <openssl/pem.h>
78#include <openssl/pkcs12.h>
79#include <openssl/rand.h>
80#include <openssl/ts.h>
81#include <openssl/ui.h>
82#include <openssl/x509.h>
83#include <openssl/x509v3.h>
84
85#ifndef OPENSSL_NO_DH
86#include <openssl/dh.h>
87#endif
88#ifndef OPENSSL_NO_DSA
89#include <openssl/dsa.h>
90#endif
91#ifndef OPENSSL_NO_EC
92#include <openssl/ec.h>
93#endif
94#ifndef OPENSSL_NO_RSA
95#include <openssl/rsa.h>
96#endif
97
98void ERR_load_ERR_strings_internal(void);
99
100static void
101ERR_load_crypto_strings_internal(void)
102{
103#ifndef OPENSSL_NO_ERR
104 ERR_load_ERR_strings_internal(); /* include error strings for SYSerr */
105
106 ERR_load_ASN1_strings();
107 ERR_load_BIO_strings();
108 ERR_load_BN_strings();
109 ERR_load_BUF_strings();
110#ifndef OPENSSL_NO_CMS
111 ERR_load_CMS_strings();
112#endif
113 ERR_load_CONF_strings();
114 ERR_load_CRYPTO_strings();
115#ifndef OPENSSL_NO_CT
116 ERR_load_CT_strings();
117#endif
118#ifndef OPENSSL_NO_DH
119 ERR_load_DH_strings();
120#endif
121#ifndef OPENSSL_NO_DSA
122 ERR_load_DSA_strings();
123#endif
124#ifndef OPENSSL_NO_EC
125 ERR_load_EC_strings();
126#endif
127 ERR_load_EVP_strings();
128 ERR_load_KDF_strings();
129 ERR_load_OBJ_strings();
130 ERR_load_OCSP_strings();
131 ERR_load_PEM_strings();
132 ERR_load_PKCS12_strings();
133 ERR_load_PKCS7_strings();
134 ERR_load_RAND_strings();
135#ifndef OPENSSL_NO_RSA
136 ERR_load_RSA_strings();
137#endif
138 ERR_load_TS_strings();
139 ERR_load_UI_strings();
140 ERR_load_X509V3_strings();
141 ERR_load_X509_strings();
142#endif
143}
144
145void
146ERR_load_crypto_strings(void)
147{
148 static pthread_once_t loaded = PTHREAD_ONCE_INIT;
149 (void) pthread_once(&loaded, ERR_load_crypto_strings_internal);
150}
151LCRYPTO_ALIAS(ERR_load_crypto_strings);
diff --git a/src/lib/libcrypto/err/err_local.h b/src/lib/libcrypto/err/err_local.h
deleted file mode 100644
index d091b979cc..0000000000
--- a/src/lib/libcrypto/err/err_local.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/* $OpenBSD: err_local.h,v 1.1 2024/06/24 06:43:22 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <openssl/err.h>
113
114#ifndef HEADER_ERR_LOCAL_H
115#define HEADER_ERR_LOCAL_H
116
117__BEGIN_HIDDEN_DECLS
118
119void ERR_load_const_strings(const ERR_STRING_DATA *str);
120
121__END_HIDDEN_DECLS
122
123#endif /* HEADER_ERR_LOCAL_H */
diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c
deleted file mode 100644
index 4bd9482e61..0000000000
--- a/src/lib/libcrypto/err/err_prn.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/* $OpenBSD: err_prn.c,v 1.24 2024/11/02 08:54:40 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <limits.h>
60#include <pthread.h>
61#include <stdio.h>
62#include <string.h>
63
64#include <openssl/buffer.h>
65#include <openssl/crypto.h>
66#include <openssl/err.h>
67#include <openssl/lhash.h>
68
69#include "bio_local.h"
70
71void
72ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u), void *u)
73{
74 unsigned long l;
75 char buf[256];
76 char buf2[4096];
77 const char *file, *data;
78 int line, flags;
79 unsigned long es;
80
81 es = (unsigned long)pthread_self();
82 while ((l = ERR_get_error_line_data(&file, &line, &data,
83 &flags)) != 0) {
84 ERR_error_string_n(l, buf, sizeof buf);
85 (void) snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es,
86 buf, file, line, (flags & ERR_TXT_STRING) ? data : "");
87 if (cb(buf2, strlen(buf2), u) <= 0)
88 break; /* abort outputting the error report */
89 }
90}
91LCRYPTO_ALIAS(ERR_print_errors_cb);
92
93static int
94print_fp(const char *str, size_t len, void *fp)
95{
96 if (len > INT_MAX)
97 return -1;
98 return fprintf(fp, "%.*s", (int)len, str);
99}
100
101void
102ERR_print_errors_fp(FILE *fp)
103{
104 ERR_print_errors_cb(print_fp, fp);
105}
106LCRYPTO_ALIAS(ERR_print_errors_fp);
107
108static int
109print_bio(const char *str, size_t len, void *bp)
110{
111 return BIO_write(bp, str, len);
112}
113
114void
115ERR_print_errors(BIO *bp)
116{
117 ERR_print_errors_cb(print_bio, bp);
118}
119LCRYPTO_ALIAS(ERR_print_errors);