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