jpayne@69
|
1 /*
|
jpayne@69
|
2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * Licensed under the OpenSSL license (the "License"). You may not use
|
jpayne@69
|
5 * this file except in compliance with the License. You can obtain a copy
|
jpayne@69
|
6 * in the file LICENSE in the source distribution or at
|
jpayne@69
|
7 * https://www.openssl.org/source/license.html
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 #ifndef HEADER_ERR_H
|
jpayne@69
|
11 # define HEADER_ERR_H
|
jpayne@69
|
12
|
jpayne@69
|
13 # include <openssl/e_os2.h>
|
jpayne@69
|
14
|
jpayne@69
|
15 # ifndef OPENSSL_NO_STDIO
|
jpayne@69
|
16 # include <stdio.h>
|
jpayne@69
|
17 # include <stdlib.h>
|
jpayne@69
|
18 # endif
|
jpayne@69
|
19
|
jpayne@69
|
20 # include <openssl/ossl_typ.h>
|
jpayne@69
|
21 # include <openssl/bio.h>
|
jpayne@69
|
22 # include <openssl/lhash.h>
|
jpayne@69
|
23
|
jpayne@69
|
24 #ifdef __cplusplus
|
jpayne@69
|
25 extern "C" {
|
jpayne@69
|
26 #endif
|
jpayne@69
|
27
|
jpayne@69
|
28 # ifndef OPENSSL_NO_ERR
|
jpayne@69
|
29 # define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e)
|
jpayne@69
|
30 # else
|
jpayne@69
|
31 # define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0)
|
jpayne@69
|
32 # endif
|
jpayne@69
|
33
|
jpayne@69
|
34 # include <errno.h>
|
jpayne@69
|
35
|
jpayne@69
|
36 # define ERR_TXT_MALLOCED 0x01
|
jpayne@69
|
37 # define ERR_TXT_STRING 0x02
|
jpayne@69
|
38
|
jpayne@69
|
39 # define ERR_FLAG_MARK 0x01
|
jpayne@69
|
40 # define ERR_FLAG_CLEAR 0x02
|
jpayne@69
|
41
|
jpayne@69
|
42 # define ERR_NUM_ERRORS 16
|
jpayne@69
|
43 typedef struct err_state_st {
|
jpayne@69
|
44 int err_flags[ERR_NUM_ERRORS];
|
jpayne@69
|
45 unsigned long err_buffer[ERR_NUM_ERRORS];
|
jpayne@69
|
46 char *err_data[ERR_NUM_ERRORS];
|
jpayne@69
|
47 int err_data_flags[ERR_NUM_ERRORS];
|
jpayne@69
|
48 const char *err_file[ERR_NUM_ERRORS];
|
jpayne@69
|
49 int err_line[ERR_NUM_ERRORS];
|
jpayne@69
|
50 int top, bottom;
|
jpayne@69
|
51 } ERR_STATE;
|
jpayne@69
|
52
|
jpayne@69
|
53 /* library */
|
jpayne@69
|
54 # define ERR_LIB_NONE 1
|
jpayne@69
|
55 # define ERR_LIB_SYS 2
|
jpayne@69
|
56 # define ERR_LIB_BN 3
|
jpayne@69
|
57 # define ERR_LIB_RSA 4
|
jpayne@69
|
58 # define ERR_LIB_DH 5
|
jpayne@69
|
59 # define ERR_LIB_EVP 6
|
jpayne@69
|
60 # define ERR_LIB_BUF 7
|
jpayne@69
|
61 # define ERR_LIB_OBJ 8
|
jpayne@69
|
62 # define ERR_LIB_PEM 9
|
jpayne@69
|
63 # define ERR_LIB_DSA 10
|
jpayne@69
|
64 # define ERR_LIB_X509 11
|
jpayne@69
|
65 /* #define ERR_LIB_METH 12 */
|
jpayne@69
|
66 # define ERR_LIB_ASN1 13
|
jpayne@69
|
67 # define ERR_LIB_CONF 14
|
jpayne@69
|
68 # define ERR_LIB_CRYPTO 15
|
jpayne@69
|
69 # define ERR_LIB_EC 16
|
jpayne@69
|
70 # define ERR_LIB_SSL 20
|
jpayne@69
|
71 /* #define ERR_LIB_SSL23 21 */
|
jpayne@69
|
72 /* #define ERR_LIB_SSL2 22 */
|
jpayne@69
|
73 /* #define ERR_LIB_SSL3 23 */
|
jpayne@69
|
74 /* #define ERR_LIB_RSAREF 30 */
|
jpayne@69
|
75 /* #define ERR_LIB_PROXY 31 */
|
jpayne@69
|
76 # define ERR_LIB_BIO 32
|
jpayne@69
|
77 # define ERR_LIB_PKCS7 33
|
jpayne@69
|
78 # define ERR_LIB_X509V3 34
|
jpayne@69
|
79 # define ERR_LIB_PKCS12 35
|
jpayne@69
|
80 # define ERR_LIB_RAND 36
|
jpayne@69
|
81 # define ERR_LIB_DSO 37
|
jpayne@69
|
82 # define ERR_LIB_ENGINE 38
|
jpayne@69
|
83 # define ERR_LIB_OCSP 39
|
jpayne@69
|
84 # define ERR_LIB_UI 40
|
jpayne@69
|
85 # define ERR_LIB_COMP 41
|
jpayne@69
|
86 # define ERR_LIB_ECDSA 42
|
jpayne@69
|
87 # define ERR_LIB_ECDH 43
|
jpayne@69
|
88 # define ERR_LIB_OSSL_STORE 44
|
jpayne@69
|
89 # define ERR_LIB_FIPS 45
|
jpayne@69
|
90 # define ERR_LIB_CMS 46
|
jpayne@69
|
91 # define ERR_LIB_TS 47
|
jpayne@69
|
92 # define ERR_LIB_HMAC 48
|
jpayne@69
|
93 /* # define ERR_LIB_JPAKE 49 */
|
jpayne@69
|
94 # define ERR_LIB_CT 50
|
jpayne@69
|
95 # define ERR_LIB_ASYNC 51
|
jpayne@69
|
96 # define ERR_LIB_KDF 52
|
jpayne@69
|
97 # define ERR_LIB_SM2 53
|
jpayne@69
|
98
|
jpayne@69
|
99 # define ERR_LIB_USER 128
|
jpayne@69
|
100
|
jpayne@69
|
101 # define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
102 # define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
103 # define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
104 # define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
105 # define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
106 # define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
107 # define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
108 # define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
109 # define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
110 # define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
111 # define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
112 # define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
113 # define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
114 # define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
115 # define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
116 # define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
117 # define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
118 # define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
119 # define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
120 # define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
121 # define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
122 # define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
123 # define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
124 # define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
125 # define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
126 # define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
127 # define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
128 # define OSSL_STOREerr(f,r) ERR_PUT_error(ERR_LIB_OSSL_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
129 # define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
130 # define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
131 # define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
132 # define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
133 # define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
134 # define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
135 # define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
136 # define SM2err(f,r) ERR_PUT_error(ERR_LIB_SM2,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
jpayne@69
|
137
|
jpayne@69
|
138 # define ERR_PACK(l,f,r) ( \
|
jpayne@69
|
139 (((unsigned int)(l) & 0x0FF) << 24L) | \
|
jpayne@69
|
140 (((unsigned int)(f) & 0xFFF) << 12L) | \
|
jpayne@69
|
141 (((unsigned int)(r) & 0xFFF) ) )
|
jpayne@69
|
142 # define ERR_GET_LIB(l) (int)(((l) >> 24L) & 0x0FFL)
|
jpayne@69
|
143 # define ERR_GET_FUNC(l) (int)(((l) >> 12L) & 0xFFFL)
|
jpayne@69
|
144 # define ERR_GET_REASON(l) (int)( (l) & 0xFFFL)
|
jpayne@69
|
145 # define ERR_FATAL_ERROR(l) (int)( (l) & ERR_R_FATAL)
|
jpayne@69
|
146
|
jpayne@69
|
147 /* OS functions */
|
jpayne@69
|
148 # define SYS_F_FOPEN 1
|
jpayne@69
|
149 # define SYS_F_CONNECT 2
|
jpayne@69
|
150 # define SYS_F_GETSERVBYNAME 3
|
jpayne@69
|
151 # define SYS_F_SOCKET 4
|
jpayne@69
|
152 # define SYS_F_IOCTLSOCKET 5
|
jpayne@69
|
153 # define SYS_F_BIND 6
|
jpayne@69
|
154 # define SYS_F_LISTEN 7
|
jpayne@69
|
155 # define SYS_F_ACCEPT 8
|
jpayne@69
|
156 # define SYS_F_WSASTARTUP 9/* Winsock stuff */
|
jpayne@69
|
157 # define SYS_F_OPENDIR 10
|
jpayne@69
|
158 # define SYS_F_FREAD 11
|
jpayne@69
|
159 # define SYS_F_GETADDRINFO 12
|
jpayne@69
|
160 # define SYS_F_GETNAMEINFO 13
|
jpayne@69
|
161 # define SYS_F_SETSOCKOPT 14
|
jpayne@69
|
162 # define SYS_F_GETSOCKOPT 15
|
jpayne@69
|
163 # define SYS_F_GETSOCKNAME 16
|
jpayne@69
|
164 # define SYS_F_GETHOSTBYNAME 17
|
jpayne@69
|
165 # define SYS_F_FFLUSH 18
|
jpayne@69
|
166 # define SYS_F_OPEN 19
|
jpayne@69
|
167 # define SYS_F_CLOSE 20
|
jpayne@69
|
168 # define SYS_F_IOCTL 21
|
jpayne@69
|
169 # define SYS_F_STAT 22
|
jpayne@69
|
170 # define SYS_F_FCNTL 23
|
jpayne@69
|
171 # define SYS_F_FSTAT 24
|
jpayne@69
|
172
|
jpayne@69
|
173 /* reasons */
|
jpayne@69
|
174 # define ERR_R_SYS_LIB ERR_LIB_SYS/* 2 */
|
jpayne@69
|
175 # define ERR_R_BN_LIB ERR_LIB_BN/* 3 */
|
jpayne@69
|
176 # define ERR_R_RSA_LIB ERR_LIB_RSA/* 4 */
|
jpayne@69
|
177 # define ERR_R_DH_LIB ERR_LIB_DH/* 5 */
|
jpayne@69
|
178 # define ERR_R_EVP_LIB ERR_LIB_EVP/* 6 */
|
jpayne@69
|
179 # define ERR_R_BUF_LIB ERR_LIB_BUF/* 7 */
|
jpayne@69
|
180 # define ERR_R_OBJ_LIB ERR_LIB_OBJ/* 8 */
|
jpayne@69
|
181 # define ERR_R_PEM_LIB ERR_LIB_PEM/* 9 */
|
jpayne@69
|
182 # define ERR_R_DSA_LIB ERR_LIB_DSA/* 10 */
|
jpayne@69
|
183 # define ERR_R_X509_LIB ERR_LIB_X509/* 11 */
|
jpayne@69
|
184 # define ERR_R_ASN1_LIB ERR_LIB_ASN1/* 13 */
|
jpayne@69
|
185 # define ERR_R_EC_LIB ERR_LIB_EC/* 16 */
|
jpayne@69
|
186 # define ERR_R_BIO_LIB ERR_LIB_BIO/* 32 */
|
jpayne@69
|
187 # define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */
|
jpayne@69
|
188 # define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */
|
jpayne@69
|
189 # define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */
|
jpayne@69
|
190 # define ERR_R_UI_LIB ERR_LIB_UI/* 40 */
|
jpayne@69
|
191 # define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */
|
jpayne@69
|
192 # define ERR_R_OSSL_STORE_LIB ERR_LIB_OSSL_STORE/* 44 */
|
jpayne@69
|
193
|
jpayne@69
|
194 # define ERR_R_NESTED_ASN1_ERROR 58
|
jpayne@69
|
195 # define ERR_R_MISSING_ASN1_EOS 63
|
jpayne@69
|
196
|
jpayne@69
|
197 /* fatal error */
|
jpayne@69
|
198 # define ERR_R_FATAL 64
|
jpayne@69
|
199 # define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL)
|
jpayne@69
|
200 # define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL)
|
jpayne@69
|
201 # define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL)
|
jpayne@69
|
202 # define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL)
|
jpayne@69
|
203 # define ERR_R_DISABLED (5|ERR_R_FATAL)
|
jpayne@69
|
204 # define ERR_R_INIT_FAIL (6|ERR_R_FATAL)
|
jpayne@69
|
205 # define ERR_R_PASSED_INVALID_ARGUMENT (7)
|
jpayne@69
|
206 # define ERR_R_OPERATION_FAIL (8|ERR_R_FATAL)
|
jpayne@69
|
207
|
jpayne@69
|
208 /*
|
jpayne@69
|
209 * 99 is the maximum possible ERR_R_... code, higher values are reserved for
|
jpayne@69
|
210 * the individual libraries
|
jpayne@69
|
211 */
|
jpayne@69
|
212
|
jpayne@69
|
213 typedef struct ERR_string_data_st {
|
jpayne@69
|
214 unsigned long error;
|
jpayne@69
|
215 const char *string;
|
jpayne@69
|
216 } ERR_STRING_DATA;
|
jpayne@69
|
217
|
jpayne@69
|
218 DEFINE_LHASH_OF(ERR_STRING_DATA);
|
jpayne@69
|
219
|
jpayne@69
|
220 void ERR_put_error(int lib, int func, int reason, const char *file, int line);
|
jpayne@69
|
221 void ERR_set_error_data(char *data, int flags);
|
jpayne@69
|
222
|
jpayne@69
|
223 unsigned long ERR_get_error(void);
|
jpayne@69
|
224 unsigned long ERR_get_error_line(const char **file, int *line);
|
jpayne@69
|
225 unsigned long ERR_get_error_line_data(const char **file, int *line,
|
jpayne@69
|
226 const char **data, int *flags);
|
jpayne@69
|
227 unsigned long ERR_peek_error(void);
|
jpayne@69
|
228 unsigned long ERR_peek_error_line(const char **file, int *line);
|
jpayne@69
|
229 unsigned long ERR_peek_error_line_data(const char **file, int *line,
|
jpayne@69
|
230 const char **data, int *flags);
|
jpayne@69
|
231 unsigned long ERR_peek_last_error(void);
|
jpayne@69
|
232 unsigned long ERR_peek_last_error_line(const char **file, int *line);
|
jpayne@69
|
233 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
|
jpayne@69
|
234 const char **data, int *flags);
|
jpayne@69
|
235 void ERR_clear_error(void);
|
jpayne@69
|
236 char *ERR_error_string(unsigned long e, char *buf);
|
jpayne@69
|
237 void ERR_error_string_n(unsigned long e, char *buf, size_t len);
|
jpayne@69
|
238 const char *ERR_lib_error_string(unsigned long e);
|
jpayne@69
|
239 const char *ERR_func_error_string(unsigned long e);
|
jpayne@69
|
240 const char *ERR_reason_error_string(unsigned long e);
|
jpayne@69
|
241 void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
|
jpayne@69
|
242 void *u);
|
jpayne@69
|
243 # ifndef OPENSSL_NO_STDIO
|
jpayne@69
|
244 void ERR_print_errors_fp(FILE *fp);
|
jpayne@69
|
245 # endif
|
jpayne@69
|
246 void ERR_print_errors(BIO *bp);
|
jpayne@69
|
247 void ERR_add_error_data(int num, ...);
|
jpayne@69
|
248 void ERR_add_error_vdata(int num, va_list args);
|
jpayne@69
|
249 int ERR_load_strings(int lib, ERR_STRING_DATA *str);
|
jpayne@69
|
250 int ERR_load_strings_const(const ERR_STRING_DATA *str);
|
jpayne@69
|
251 int ERR_unload_strings(int lib, ERR_STRING_DATA *str);
|
jpayne@69
|
252 int ERR_load_ERR_strings(void);
|
jpayne@69
|
253
|
jpayne@69
|
254 #if OPENSSL_API_COMPAT < 0x10100000L
|
jpayne@69
|
255 # define ERR_load_crypto_strings() \
|
jpayne@69
|
256 OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
|
jpayne@69
|
257 # define ERR_free_strings() while(0) continue
|
jpayne@69
|
258 #endif
|
jpayne@69
|
259
|
jpayne@69
|
260 DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))
|
jpayne@69
|
261 DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))
|
jpayne@69
|
262 ERR_STATE *ERR_get_state(void);
|
jpayne@69
|
263
|
jpayne@69
|
264 int ERR_get_next_error_library(void);
|
jpayne@69
|
265
|
jpayne@69
|
266 int ERR_set_mark(void);
|
jpayne@69
|
267 int ERR_pop_to_mark(void);
|
jpayne@69
|
268 int ERR_clear_last_mark(void);
|
jpayne@69
|
269
|
jpayne@69
|
270 #ifdef __cplusplus
|
jpayne@69
|
271 }
|
jpayne@69
|
272 #endif
|
jpayne@69
|
273
|
jpayne@69
|
274 #endif
|