xref: /openbsd-src/lib/libcrypto/crypto_err.c (revision de94663e21b578ae8757d4b91fe2979a6554d74b)
1*de94663eStb /* $OpenBSD: crypto_err.c,v 1.1 2024/11/05 11:21:15 tb Exp $ */
2*de94663eStb /* ====================================================================
3*de94663eStb  * Copyright (c) 1999-2011 The OpenSSL Project.  All rights reserved.
4*de94663eStb  *
5*de94663eStb  * Redistribution and use in source and binary forms, with or without
6*de94663eStb  * modification, are permitted provided that the following conditions
7*de94663eStb  * are met:
8*de94663eStb  *
9*de94663eStb  * 1. Redistributions of source code must retain the above copyright
10*de94663eStb  *    notice, this list of conditions and the following disclaimer.
11*de94663eStb  *
12*de94663eStb  * 2. Redistributions in binary form must reproduce the above copyright
13*de94663eStb  *    notice, this list of conditions and the following disclaimer in
14*de94663eStb  *    the documentation and/or other materials provided with the
15*de94663eStb  *    distribution.
16*de94663eStb  *
17*de94663eStb  * 3. All advertising materials mentioning features or use of this
18*de94663eStb  *    software must display the following acknowledgment:
19*de94663eStb  *    "This product includes software developed by the OpenSSL Project
20*de94663eStb  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21*de94663eStb  *
22*de94663eStb  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23*de94663eStb  *    endorse or promote products derived from this software without
24*de94663eStb  *    prior written permission. For written permission, please contact
25*de94663eStb  *    openssl-core@OpenSSL.org.
26*de94663eStb  *
27*de94663eStb  * 5. Products derived from this software may not be called "OpenSSL"
28*de94663eStb  *    nor may "OpenSSL" appear in their names without prior written
29*de94663eStb  *    permission of the OpenSSL Project.
30*de94663eStb  *
31*de94663eStb  * 6. Redistributions of any form whatsoever must retain the following
32*de94663eStb  *    acknowledgment:
33*de94663eStb  *    "This product includes software developed by the OpenSSL Project
34*de94663eStb  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35*de94663eStb  *
36*de94663eStb  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37*de94663eStb  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38*de94663eStb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39*de94663eStb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
40*de94663eStb  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41*de94663eStb  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42*de94663eStb  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43*de94663eStb  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44*de94663eStb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45*de94663eStb  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46*de94663eStb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47*de94663eStb  * OF THE POSSIBILITY OF SUCH DAMAGE.
48*de94663eStb  * ====================================================================
49*de94663eStb  *
50*de94663eStb  * This product includes cryptographic software written by Eric Young
51*de94663eStb  * (eay@cryptsoft.com).  This product includes software written by Tim
52*de94663eStb  * Hudson (tjh@cryptsoft.com).
53*de94663eStb  *
54*de94663eStb  */
55*de94663eStb 
56*de94663eStb #include <stdio.h>
57*de94663eStb 
58*de94663eStb #include <openssl/opensslconf.h>
59*de94663eStb 
60*de94663eStb #include <openssl/err.h>
61*de94663eStb #include <openssl/crypto.h>
62*de94663eStb 
63*de94663eStb #include "err_local.h"
64*de94663eStb 
65*de94663eStb #ifndef OPENSSL_NO_ERR
66*de94663eStb 
67*de94663eStb #define ERR_FUNC(func) ERR_PACK(ERR_LIB_CRYPTO,func,0)
68*de94663eStb #define ERR_REASON(reason) ERR_PACK(ERR_LIB_CRYPTO,0,reason)
69*de94663eStb 
70*de94663eStb static const ERR_STRING_DATA CRYPTO_str_functs[] = {
71*de94663eStb 	{ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX),	"CRYPTO_get_ex_new_index"},
72*de94663eStb 	{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID),	"CRYPTO_get_new_dynlockid"},
73*de94663eStb 	{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID),	"CRYPTO_get_new_lockid"},
74*de94663eStb 	{ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA),	"CRYPTO_set_ex_data"},
75*de94663eStb 	{ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX),	"DEF_ADD_INDEX"},
76*de94663eStb 	{ERR_FUNC(CRYPTO_F_DEF_GET_CLASS),	"DEF_GET_CLASS"},
77*de94663eStb 	{ERR_FUNC(CRYPTO_F_FIPS_MODE_SET),	"FIPS_mode_set"},
78*de94663eStb 	{ERR_FUNC(CRYPTO_F_INT_DUP_EX_DATA),	"INT_DUP_EX_DATA"},
79*de94663eStb 	{ERR_FUNC(CRYPTO_F_INT_FREE_EX_DATA),	"INT_FREE_EX_DATA"},
80*de94663eStb 	{ERR_FUNC(CRYPTO_F_INT_NEW_EX_DATA),	"INT_NEW_EX_DATA"},
81*de94663eStb 	{0, NULL}
82*de94663eStb };
83*de94663eStb 
84*de94663eStb static const ERR_STRING_DATA CRYPTO_str_reasons[] = {
85*de94663eStb 	{ERR_REASON(CRYPTO_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"},
86*de94663eStb 	{ERR_REASON(CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK), "no dynlock create callback"},
87*de94663eStb 	{0, NULL}
88*de94663eStb };
89*de94663eStb 
90*de94663eStb #endif
91*de94663eStb 
92*de94663eStb void
93*de94663eStb ERR_load_CRYPTO_strings(void)
94*de94663eStb {
95*de94663eStb #ifndef OPENSSL_NO_ERR
96*de94663eStb 	if (ERR_func_error_string(CRYPTO_str_functs[0].error) == NULL) {
97*de94663eStb 		ERR_load_const_strings(CRYPTO_str_functs);
98*de94663eStb 		ERR_load_const_strings(CRYPTO_str_reasons);
99*de94663eStb 	}
100*de94663eStb #endif
101*de94663eStb }
102*de94663eStb LCRYPTO_ALIAS(ERR_load_CRYPTO_strings);
103