1 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
2 | * All rights reserved. |
3 | * |
4 | * This package is an SSL implementation written |
5 | * by Eric Young (eay@cryptsoft.com). |
6 | * The implementation was written so as to conform with Netscapes SSL. |
7 | * |
8 | * This library is free for commercial and non-commercial use as long as |
9 | * the following conditions are aheared to. The following conditions |
10 | * apply to all code found in this distribution, be it the RC4, RSA, |
11 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
12 | * included with this distribution is covered by the same copyright terms |
13 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
14 | * |
15 | * Copyright remains Eric Young's, and as such any Copyright notices in |
16 | * the code are not to be removed. |
17 | * If this package is used in a product, Eric Young should be given attribution |
18 | * as the author of the parts of the library used. |
19 | * This can be in the form of a textual message at program startup or |
20 | * in documentation (online or textual) provided with the package. |
21 | * |
22 | * Redistribution and use in source and binary forms, with or without |
23 | * modification, are permitted provided that the following conditions |
24 | * are met: |
25 | * 1. Redistributions of source code must retain the copyright |
26 | * notice, this list of conditions and the following disclaimer. |
27 | * 2. Redistributions in binary form must reproduce the above copyright |
28 | * notice, this list of conditions and the following disclaimer in the |
29 | * documentation and/or other materials provided with the distribution. |
30 | * 3. All advertising materials mentioning features or use of this software |
31 | * must display the following acknowledgement: |
32 | * "This product includes cryptographic software written by |
33 | * Eric Young (eay@cryptsoft.com)" |
34 | * The word 'cryptographic' can be left out if the rouines from the library |
35 | * being used are not cryptographic related :-). |
36 | * 4. If you include any Windows specific code (or a derivative thereof) from |
37 | * the apps directory (application code) you must include an acknowledgement: |
38 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
39 | * |
40 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
41 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
43 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
44 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
45 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
46 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
48 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
49 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
50 | * SUCH DAMAGE. |
51 | * |
52 | * The licence and distribution terms for any publically available version or |
53 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
54 | * copied and put under another distribution licence |
55 | * [including the GNU Public Licence.] |
56 | */ |
57 | /* ==================================================================== |
58 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. |
59 | * |
60 | * Redistribution and use in source and binary forms, with or without |
61 | * modification, are permitted provided that the following conditions |
62 | * are met: |
63 | * |
64 | * 1. Redistributions of source code must retain the above copyright |
65 | * notice, this list of conditions and the following disclaimer. |
66 | * |
67 | * 2. Redistributions in binary form must reproduce the above copyright |
68 | * notice, this list of conditions and the following disclaimer in |
69 | * the documentation and/or other materials provided with the |
70 | * distribution. |
71 | * |
72 | * 3. All advertising materials mentioning features or use of this |
73 | * software must display the following acknowledgment: |
74 | * "This product includes software developed by the OpenSSL Project |
75 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" |
76 | * |
77 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
78 | * endorse or promote products derived from this software without |
79 | * prior written permission. For written permission, please contact |
80 | * openssl-core@openssl.org. |
81 | * |
82 | * 5. Products derived from this software may not be called "OpenSSL" |
83 | * nor may "OpenSSL" appear in their names without prior written |
84 | * permission of the OpenSSL Project. |
85 | * |
86 | * 6. Redistributions of any form whatsoever must retain the following |
87 | * acknowledgment: |
88 | * "This product includes software developed by the OpenSSL Project |
89 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" |
90 | * |
91 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
92 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
93 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
94 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
95 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
96 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
97 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
98 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
99 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
100 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
101 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
102 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
103 | * ==================================================================== |
104 | * |
105 | * This product includes cryptographic software written by Eric Young |
106 | * (eay@cryptsoft.com). This product includes software written by Tim |
107 | * Hudson (tjh@cryptsoft.com). */ |
108 | |
109 | #ifndef OPENSSL_HEADER_ERR_H |
110 | #define |
111 | |
112 | #include <stdio.h> |
113 | |
114 | #include <openssl/base.h> |
115 | |
116 | #if defined(__cplusplus) |
117 | extern "C" { |
118 | #endif |
119 | |
120 | |
121 | // Error queue handling functions. |
122 | // |
123 | // Errors in OpenSSL are generally signaled by the return value of a function. |
124 | // When a function fails it may add an entry to a per-thread error queue, |
125 | // which is managed by the functions in this header. |
126 | // |
127 | // Each error contains: |
128 | // 1) The library (i.e. ec, pem, rsa) which created it. |
129 | // 2) The file and line number of the call that added the error. |
130 | // 3) A pointer to some error specific data, which may be NULL. |
131 | // |
132 | // The library identifier and reason code are packed in a uint32_t and there |
133 | // exist various functions for unpacking it. |
134 | // |
135 | // The typical behaviour is that an error will occur deep in a call queue and |
136 | // that code will push an error onto the error queue. As the error queue |
137 | // unwinds, other functions will push their own errors. Thus, the "least |
138 | // recent" error is the most specific and the other errors will provide a |
139 | // backtrace of sorts. |
140 | |
141 | |
142 | // Startup and shutdown. |
143 | |
144 | // ERR_load_BIO_strings does nothing. |
145 | // |
146 | // TODO(fork): remove. libjingle calls this. |
147 | OPENSSL_EXPORT void ERR_load_BIO_strings(void); |
148 | |
149 | // ERR_load_ERR_strings does nothing. |
150 | OPENSSL_EXPORT void ERR_load_ERR_strings(void); |
151 | |
152 | // ERR_load_crypto_strings does nothing. |
153 | OPENSSL_EXPORT void ERR_load_crypto_strings(void); |
154 | |
155 | // ERR_load_RAND_strings does nothing. |
156 | OPENSSL_EXPORT void ERR_load_RAND_strings(void); |
157 | |
158 | // ERR_free_strings does nothing. |
159 | OPENSSL_EXPORT void ERR_free_strings(void); |
160 | |
161 | |
162 | // Reading and formatting errors. |
163 | |
164 | // ERR_GET_LIB returns the library code for the error. This is one of |
165 | // the |ERR_LIB_*| values. |
166 | OPENSSL_INLINE int ERR_GET_LIB(uint32_t packed_error) { |
167 | return (int)((packed_error >> 24) & 0xff); |
168 | } |
169 | |
170 | // ERR_GET_REASON returns the reason code for the error. This is one of |
171 | // library-specific |LIB_R_*| values where |LIB| is the library (see |
172 | // |ERR_GET_LIB|). Note that reason codes are specific to the library. |
173 | OPENSSL_INLINE int ERR_GET_REASON(uint32_t packed_error) { |
174 | return (int)(packed_error & 0xfff); |
175 | } |
176 | |
177 | // ERR_get_error gets the packed error code for the least recent error and |
178 | // removes that error from the queue. If there are no errors in the queue then |
179 | // it returns zero. |
180 | OPENSSL_EXPORT uint32_t ERR_get_error(void); |
181 | |
182 | // ERR_get_error_line acts like |ERR_get_error|, except that the file and line |
183 | // number of the call that added the error are also returned. |
184 | OPENSSL_EXPORT uint32_t ERR_get_error_line(const char **file, int *line); |
185 | |
186 | // ERR_FLAG_STRING means that the |data| member is a NUL-terminated string that |
187 | // can be printed. This is always set if |data| is non-NULL. |
188 | #define ERR_FLAG_STRING 1 |
189 | |
190 | // ERR_FLAG_MALLOCED is passed into |ERR_set_error_data| to indicate that |data| |
191 | // was allocated with |OPENSSL_malloc|. |
192 | // |
193 | // It is, separately, returned in |*flags| from |ERR_get_error_line_data| to |
194 | // indicate that |*data| has a non-static lifetime, but this lifetime is still |
195 | // managed by the library. The caller must not call |OPENSSL_free| or |free| on |
196 | // |data|. |
197 | #define ERR_FLAG_MALLOCED 2 |
198 | |
199 | // ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the |
200 | // error-specific data pointer and flags. The flags are a bitwise-OR of |
201 | // |ERR_FLAG_*| values. The error-specific data is owned by the error queue |
202 | // and the pointer becomes invalid after the next call that affects the same |
203 | // thread's error queue. If |*flags| contains |ERR_FLAG_STRING| then |*data| is |
204 | // human-readable. |
205 | OPENSSL_EXPORT uint32_t ERR_get_error_line_data(const char **file, int *line, |
206 | const char **data, int *flags); |
207 | |
208 | // The "peek" functions act like the |ERR_get_error| functions, above, but they |
209 | // do not remove the error from the queue. |
210 | OPENSSL_EXPORT uint32_t ERR_peek_error(void); |
211 | OPENSSL_EXPORT uint32_t ERR_peek_error_line(const char **file, int *line); |
212 | OPENSSL_EXPORT uint32_t ERR_peek_error_line_data(const char **file, int *line, |
213 | const char **data, int *flags); |
214 | |
215 | // The "peek last" functions act like the "peek" functions, above, except that |
216 | // they return the most recent error. |
217 | OPENSSL_EXPORT uint32_t ERR_peek_last_error(void); |
218 | OPENSSL_EXPORT uint32_t ERR_peek_last_error_line(const char **file, int *line); |
219 | OPENSSL_EXPORT uint32_t ERR_peek_last_error_line_data(const char **file, |
220 | int *line, |
221 | const char **data, |
222 | int *flags); |
223 | |
224 | // ERR_error_string_n generates a human-readable string representing |
225 | // |packed_error|, places it at |buf|, and returns |buf|. It writes at most |
226 | // |len| bytes (including the terminating NUL) and truncates the string if |
227 | // necessary. If |len| is greater than zero then |buf| is always NUL terminated. |
228 | // |
229 | // The string will have the following format: |
230 | // |
231 | // error:[error code]:[library name]:OPENSSL_internal:[reason string] |
232 | // |
233 | // error code is an 8 digit hexadecimal number; library name and reason string |
234 | // are ASCII text. |
235 | OPENSSL_EXPORT char *ERR_error_string_n(uint32_t packed_error, char *buf, |
236 | size_t len); |
237 | |
238 | // ERR_lib_error_string returns a string representation of the library that |
239 | // generated |packed_error|, or a placeholder string is the library is |
240 | // unrecognized. |
241 | OPENSSL_EXPORT const char *ERR_lib_error_string(uint32_t packed_error); |
242 | |
243 | // ERR_reason_error_string returns a string representation of the reason for |
244 | // |packed_error|, or a placeholder string if the reason is unrecognized. |
245 | OPENSSL_EXPORT const char *ERR_reason_error_string(uint32_t packed_error); |
246 | |
247 | // ERR_print_errors_callback_t is the type of a function used by |
248 | // |ERR_print_errors_cb|. It takes a pointer to a human readable string (and |
249 | // its length) that describes an entry in the error queue. The |ctx| argument |
250 | // is an opaque pointer given to |ERR_print_errors_cb|. |
251 | // |
252 | // It should return one on success or zero on error, which will stop the |
253 | // iteration over the error queue. |
254 | typedef int (*ERR_print_errors_callback_t)(const char *str, size_t len, |
255 | void *ctx); |
256 | |
257 | // ERR_print_errors_cb clears the current thread's error queue, calling |
258 | // |callback| with a string representation of each error, from the least recent |
259 | // to the most recent error. |
260 | // |
261 | // The string will have the following format (which differs from |
262 | // |ERR_error_string|): |
263 | // |
264 | // [thread id]:error:[error code]:[library name]:OPENSSL_internal:[reason string]:[file]:[line number]:[optional string data] |
265 | // |
266 | // The callback can return one to continue the iteration or zero to stop it. |
267 | // The |ctx| argument is an opaque value that is passed through to the |
268 | // callback. |
269 | OPENSSL_EXPORT void ERR_print_errors_cb(ERR_print_errors_callback_t callback, |
270 | void *ctx); |
271 | |
272 | // ERR_print_errors_fp clears the current thread's error queue, printing each |
273 | // error to |file|. See |ERR_print_errors_cb| for the format. |
274 | OPENSSL_EXPORT void ERR_print_errors_fp(FILE *file); |
275 | |
276 | |
277 | // Clearing errors. |
278 | |
279 | // ERR_clear_error clears the error queue for the current thread. |
280 | OPENSSL_EXPORT void ERR_clear_error(void); |
281 | |
282 | // ERR_set_mark "marks" the most recent error for use with |ERR_pop_to_mark|. |
283 | // It returns one if an error was marked and zero if there are no errors. |
284 | OPENSSL_EXPORT int ERR_set_mark(void); |
285 | |
286 | // ERR_pop_to_mark removes errors from the most recent to the least recent |
287 | // until (and not including) a "marked" error. It returns zero if no marked |
288 | // error was found (and thus all errors were removed) and one otherwise. Errors |
289 | // are marked using |ERR_set_mark|. |
290 | OPENSSL_EXPORT int ERR_pop_to_mark(void); |
291 | |
292 | |
293 | // Custom errors. |
294 | |
295 | // ERR_get_next_error_library returns a value suitable for passing as the |
296 | // |library| argument to |ERR_put_error|. This is intended for code that wishes |
297 | // to push its own, non-standard errors to the error queue. |
298 | OPENSSL_EXPORT int ERR_get_next_error_library(void); |
299 | |
300 | |
301 | // Built-in library and reason codes. |
302 | |
303 | // The following values are built-in library codes. |
304 | enum { |
305 | ERR_LIB_NONE = 1, |
306 | ERR_LIB_SYS, |
307 | ERR_LIB_BN, |
308 | ERR_LIB_RSA, |
309 | ERR_LIB_DH, |
310 | ERR_LIB_EVP, |
311 | ERR_LIB_BUF, |
312 | ERR_LIB_OBJ, |
313 | ERR_LIB_PEM, |
314 | ERR_LIB_DSA, |
315 | ERR_LIB_X509, |
316 | ERR_LIB_ASN1, |
317 | ERR_LIB_CONF, |
318 | ERR_LIB_CRYPTO, |
319 | ERR_LIB_EC, |
320 | ERR_LIB_SSL, |
321 | ERR_LIB_BIO, |
322 | ERR_LIB_PKCS7, |
323 | ERR_LIB_PKCS8, |
324 | ERR_LIB_X509V3, |
325 | ERR_LIB_RAND, |
326 | ERR_LIB_ENGINE, |
327 | ERR_LIB_OCSP, |
328 | ERR_LIB_UI, |
329 | ERR_LIB_COMP, |
330 | ERR_LIB_ECDSA, |
331 | ERR_LIB_ECDH, |
332 | ERR_LIB_HMAC, |
333 | ERR_LIB_DIGEST, |
334 | ERR_LIB_CIPHER, |
335 | ERR_LIB_HKDF, |
336 | ERR_LIB_TRUST_TOKEN, |
337 | ERR_LIB_USER, |
338 | ERR_NUM_LIBS |
339 | }; |
340 | |
341 | // The following reason codes used to denote an error occuring in another |
342 | // library. They are sometimes used for a stack trace. |
343 | #define ERR_R_SYS_LIB ERR_LIB_SYS |
344 | #define ERR_R_BN_LIB ERR_LIB_BN |
345 | #define ERR_R_RSA_LIB ERR_LIB_RSA |
346 | #define ERR_R_DH_LIB ERR_LIB_DH |
347 | #define ERR_R_EVP_LIB ERR_LIB_EVP |
348 | #define ERR_R_BUF_LIB ERR_LIB_BUF |
349 | #define ERR_R_OBJ_LIB ERR_LIB_OBJ |
350 | #define ERR_R_PEM_LIB ERR_LIB_PEM |
351 | #define ERR_R_DSA_LIB ERR_LIB_DSA |
352 | #define ERR_R_X509_LIB ERR_LIB_X509 |
353 | #define ERR_R_ASN1_LIB ERR_LIB_ASN1 |
354 | #define ERR_R_CONF_LIB ERR_LIB_CONF |
355 | #define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO |
356 | #define ERR_R_EC_LIB ERR_LIB_EC |
357 | #define ERR_R_SSL_LIB ERR_LIB_SSL |
358 | #define ERR_R_BIO_LIB ERR_LIB_BIO |
359 | #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7 |
360 | #define ERR_R_PKCS8_LIB ERR_LIB_PKCS8 |
361 | #define ERR_R_X509V3_LIB ERR_LIB_X509V3 |
362 | #define ERR_R_RAND_LIB ERR_LIB_RAND |
363 | #define ERR_R_DSO_LIB ERR_LIB_DSO |
364 | #define ERR_R_ENGINE_LIB ERR_LIB_ENGINE |
365 | #define ERR_R_OCSP_LIB ERR_LIB_OCSP |
366 | #define ERR_R_UI_LIB ERR_LIB_UI |
367 | #define ERR_R_COMP_LIB ERR_LIB_COMP |
368 | #define ERR_R_ECDSA_LIB ERR_LIB_ECDSA |
369 | #define ERR_R_ECDH_LIB ERR_LIB_ECDH |
370 | #define ERR_R_STORE_LIB ERR_LIB_STORE |
371 | #define ERR_R_FIPS_LIB ERR_LIB_FIPS |
372 | #define ERR_R_CMS_LIB ERR_LIB_CMS |
373 | #define ERR_R_TS_LIB ERR_LIB_TS |
374 | #define ERR_R_HMAC_LIB ERR_LIB_HMAC |
375 | #define ERR_R_JPAKE_LIB ERR_LIB_JPAKE |
376 | #define ERR_R_USER_LIB ERR_LIB_USER |
377 | #define ERR_R_DIGEST_LIB ERR_LIB_DIGEST |
378 | #define ERR_R_CIPHER_LIB ERR_LIB_CIPHER |
379 | #define ERR_R_HKDF_LIB ERR_LIB_HKDF |
380 | #define ERR_R_TRUST_TOKEN_LIB ERR_LIB_TRUST_TOKEN |
381 | |
382 | // The following values are global reason codes. They may occur in any library. |
383 | #define ERR_R_FATAL 64 |
384 | #define ERR_R_MALLOC_FAILURE (1 | ERR_R_FATAL) |
385 | #define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2 | ERR_R_FATAL) |
386 | #define ERR_R_PASSED_NULL_PARAMETER (3 | ERR_R_FATAL) |
387 | #define ERR_R_INTERNAL_ERROR (4 | ERR_R_FATAL) |
388 | #define ERR_R_OVERFLOW (5 | ERR_R_FATAL) |
389 | |
390 | |
391 | // Deprecated functions. |
392 | |
393 | // ERR_remove_state calls |ERR_clear_error|. |
394 | OPENSSL_EXPORT void ERR_remove_state(unsigned long pid); |
395 | |
396 | // ERR_remove_thread_state clears the error queue for the current thread if |
397 | // |tid| is NULL. Otherwise it calls |assert(0)|, because it's no longer |
398 | // possible to delete the error queue for other threads. |
399 | // |
400 | // Use |ERR_clear_error| instead. Note error queues are deleted automatically on |
401 | // thread exit. You do not need to call this function to release memory. |
402 | OPENSSL_EXPORT void ERR_remove_thread_state(const CRYPTO_THREADID *tid); |
403 | |
404 | // ERR_func_error_string returns the string "OPENSSL_internal". |
405 | OPENSSL_EXPORT const char *ERR_func_error_string(uint32_t packed_error); |
406 | |
407 | // ERR_error_string behaves like |ERR_error_string_n| but |len| is implicitly |
408 | // |ERR_ERROR_STRING_BUF_LEN|. |
409 | // |
410 | // Additionally, if |buf| is NULL, the error string is placed in a static buffer |
411 | // which is returned. This is not thread-safe and only exists for backwards |
412 | // compatibility with legacy callers. The static buffer will be overridden by |
413 | // calls in other threads. |
414 | // |
415 | // Use |ERR_error_string_n| instead. |
416 | // |
417 | // TODO(fork): remove this function. |
418 | OPENSSL_EXPORT char *ERR_error_string(uint32_t packed_error, char *buf); |
419 | #define ERR_ERROR_STRING_BUF_LEN 120 |
420 | |
421 | // ERR_GET_FUNC returns zero. BoringSSL errors do not report a function code. |
422 | OPENSSL_INLINE int ERR_GET_FUNC(uint32_t packed_error) { |
423 | (void)packed_error; |
424 | return 0; |
425 | } |
426 | |
427 | // ERR_TXT_* are provided for compatibility with code that assumes that it's |
428 | // using OpenSSL. |
429 | #define ERR_TXT_STRING ERR_FLAG_STRING |
430 | #define ERR_TXT_MALLOCED ERR_FLAG_MALLOCED |
431 | |
432 | |
433 | // Private functions. |
434 | |
435 | // ERR_clear_system_error clears the system's error value (i.e. errno). |
436 | OPENSSL_EXPORT void ERR_clear_system_error(void); |
437 | |
438 | // OPENSSL_PUT_ERROR is used by OpenSSL code to add an error to the error |
439 | // queue. |
440 | #define OPENSSL_PUT_ERROR(library, reason) \ |
441 | ERR_put_error(ERR_LIB_##library, 0, reason, __FILE__, __LINE__) |
442 | |
443 | // OPENSSL_PUT_SYSTEM_ERROR is used by OpenSSL code to add an error from the |
444 | // operating system to the error queue. |
445 | // TODO(fork): include errno. |
446 | #define OPENSSL_PUT_SYSTEM_ERROR() \ |
447 | ERR_put_error(ERR_LIB_SYS, 0, 0, __FILE__, __LINE__); |
448 | |
449 | // ERR_put_error adds an error to the error queue, dropping the least recent |
450 | // error if necessary for space reasons. |
451 | OPENSSL_EXPORT void ERR_put_error(int library, int unused, int reason, |
452 | const char *file, unsigned line); |
453 | |
454 | // ERR_add_error_data takes a variable number (|count|) of const char* |
455 | // pointers, concatenates them and sets the result as the data on the most |
456 | // recent error. |
457 | OPENSSL_EXPORT void ERR_add_error_data(unsigned count, ...); |
458 | |
459 | // ERR_add_error_dataf takes a printf-style format and arguments, and sets the |
460 | // result as the data on the most recent error. |
461 | OPENSSL_EXPORT void ERR_add_error_dataf(const char *format, ...) |
462 | OPENSSL_PRINTF_FORMAT_FUNC(1, 2); |
463 | |
464 | // ERR_set_error_data sets the data on the most recent error to |data|, which |
465 | // must be a NUL-terminated string. |flags| must contain |ERR_FLAG_STRING|. If |
466 | // |flags| contains |ERR_FLAG_MALLOCED|, this function takes ownership of |
467 | // |data|, which must have been allocated with |OPENSSL_malloc|. Otherwise, it |
468 | // saves a copy of |data|. |
469 | // |
470 | // Note this differs from OpenSSL which, when |ERR_FLAG_MALLOCED| is unset, |
471 | // saves the pointer as-is and requires it remain valid for the lifetime of the |
472 | // address space. |
473 | OPENSSL_EXPORT void ERR_set_error_data(char *data, int flags); |
474 | |
475 | // ERR_NUM_ERRORS is one more than the limit of the number of errors in the |
476 | // queue. |
477 | #define ERR_NUM_ERRORS 16 |
478 | |
479 | #define ERR_PACK(lib, reason) \ |
480 | (((((uint32_t)(lib)) & 0xff) << 24) | ((((uint32_t)(reason)) & 0xfff))) |
481 | |
482 | // OPENSSL_DECLARE_ERROR_REASON is used by util/make_errors.h (which generates |
483 | // the error defines) to recognise that an additional reason value is needed. |
484 | // This is needed when the reason value is used outside of an |
485 | // |OPENSSL_PUT_ERROR| macro. The resulting define will be |
486 | // ${lib}_R_${reason}. |
487 | #define OPENSSL_DECLARE_ERROR_REASON(lib, reason) |
488 | |
489 | |
490 | #if defined(__cplusplus) |
491 | } // extern C |
492 | #endif |
493 | |
494 | #endif // OPENSSL_HEADER_ERR_H |
495 | |