err.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. #ifndef OPENSSL_HEADER_ERR_H
  109. #define OPENSSL_HEADER_ERR_H
  110. #include <stdio.h>
  111. #include <openssl/base.h>
  112. #if defined(__cplusplus)
  113. extern "C" {
  114. #endif
  115. // Error queue handling functions.
  116. //
  117. // Errors in OpenSSL are generally signaled by the return value of a function.
  118. // When a function fails it may add an entry to a per-thread error queue,
  119. // which is managed by the functions in this header.
  120. //
  121. // Each error contains:
  122. // 1) The library (i.e. ec, pem, rsa) which created it.
  123. // 2) The file and line number of the call that added the error.
  124. // 3) A pointer to some error specific data, which may be NULL.
  125. //
  126. // The library identifier and reason code are packed in a uint32_t and there
  127. // exist various functions for unpacking it.
  128. //
  129. // The typical behaviour is that an error will occur deep in a call queue and
  130. // that code will push an error onto the error queue. As the error queue
  131. // unwinds, other functions will push their own errors. Thus, the "least
  132. // recent" error is the most specific and the other errors will provide a
  133. // backtrace of sorts.
  134. // Startup and shutdown.
  135. // ERR_load_BIO_strings does nothing.
  136. //
  137. // TODO(fork): remove. libjingle calls this.
  138. OPENSSL_EXPORT void ERR_load_BIO_strings(void);
  139. // ERR_load_ERR_strings does nothing.
  140. OPENSSL_EXPORT void ERR_load_ERR_strings(void);
  141. // ERR_load_crypto_strings does nothing.
  142. OPENSSL_EXPORT void ERR_load_crypto_strings(void);
  143. // ERR_load_RAND_strings does nothing.
  144. OPENSSL_EXPORT void ERR_load_RAND_strings(void);
  145. // ERR_free_strings does nothing.
  146. OPENSSL_EXPORT void ERR_free_strings(void);
  147. // Reading and formatting errors.
  148. // ERR_GET_LIB returns the library code for the error. This is one of
  149. // the |ERR_LIB_*| values.
  150. #define ERR_GET_LIB(packed_error) ((int)(((packed_error) >> 24) & 0xff))
  151. // ERR_GET_REASON returns the reason code for the error. This is one of
  152. // library-specific |LIB_R_*| values where |LIB| is the library (see
  153. // |ERR_GET_LIB|). Note that reason codes are specific to the library.
  154. #define ERR_GET_REASON(packed_error) ((int)((packed_error) & 0xfff))
  155. // ERR_get_error gets the packed error code for the least recent error and
  156. // removes that error from the queue. If there are no errors in the queue then
  157. // it returns zero.
  158. OPENSSL_EXPORT uint32_t ERR_get_error(void);
  159. // ERR_get_error_line acts like |ERR_get_error|, except that the file and line
  160. // number of the call that added the error are also returned.
  161. OPENSSL_EXPORT uint32_t ERR_get_error_line(const char **file, int *line);
  162. // ERR_FLAG_STRING means that the |data| member is a NUL-terminated string that
  163. // can be printed. This is always set if |data| is non-NULL.
  164. #define ERR_FLAG_STRING 1
  165. // ERR_FLAG_MALLOCED is passed into |ERR_set_error_data| to indicate that |data|
  166. // was allocated with |OPENSSL_malloc|. It is never returned from
  167. // |ERR_get_error_line_data|.
  168. #define ERR_FLAG_MALLOCED 2
  169. // ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the
  170. // error-specific data pointer and flags. The flags are a bitwise-OR of
  171. // |ERR_FLAG_*| values. The error-specific data is owned by the error queue
  172. // and the pointer becomes invalid after the next call that affects the same
  173. // thread's error queue. If |*flags| contains |ERR_FLAG_STRING| then |*data| is
  174. // human-readable.
  175. OPENSSL_EXPORT uint32_t ERR_get_error_line_data(const char **file, int *line,
  176. const char **data, int *flags);
  177. // The "peek" functions act like the |ERR_get_error| functions, above, but they
  178. // do not remove the error from the queue.
  179. OPENSSL_EXPORT uint32_t ERR_peek_error(void);
  180. OPENSSL_EXPORT uint32_t ERR_peek_error_line(const char **file, int *line);
  181. OPENSSL_EXPORT uint32_t ERR_peek_error_line_data(const char **file, int *line,
  182. const char **data, int *flags);
  183. // The "peek last" functions act like the "peek" functions, above, except that
  184. // they return the most recent error.
  185. OPENSSL_EXPORT uint32_t ERR_peek_last_error(void);
  186. OPENSSL_EXPORT uint32_t ERR_peek_last_error_line(const char **file, int *line);
  187. OPENSSL_EXPORT uint32_t ERR_peek_last_error_line_data(const char **file,
  188. int *line,
  189. const char **data,
  190. int *flags);
  191. // ERR_error_string_n generates a human-readable string representing
  192. // |packed_error|, places it at |buf|, and returns |buf|. It writes at most
  193. // |len| bytes (including the terminating NUL) and truncates the string if
  194. // necessary. If |len| is greater than zero then |buf| is always NUL terminated.
  195. //
  196. // The string will have the following format:
  197. //
  198. // error:[error code]:[library name]:OPENSSL_internal:[reason string]
  199. //
  200. // error code is an 8 digit hexadecimal number; library name and reason string
  201. // are ASCII text.
  202. OPENSSL_EXPORT char *ERR_error_string_n(uint32_t packed_error, char *buf,
  203. size_t len);
  204. // ERR_lib_error_string returns a string representation of the library that
  205. // generated |packed_error|, or a placeholder string is the library is
  206. // unrecognized.
  207. OPENSSL_EXPORT const char *ERR_lib_error_string(uint32_t packed_error);
  208. // ERR_reason_error_string returns a string representation of the reason for
  209. // |packed_error|, or a placeholder string if the reason is unrecognized.
  210. OPENSSL_EXPORT const char *ERR_reason_error_string(uint32_t packed_error);
  211. // ERR_print_errors_callback_t is the type of a function used by
  212. // |ERR_print_errors_cb|. It takes a pointer to a human readable string (and
  213. // its length) that describes an entry in the error queue. The |ctx| argument
  214. // is an opaque pointer given to |ERR_print_errors_cb|.
  215. //
  216. // It should return one on success or zero on error, which will stop the
  217. // iteration over the error queue.
  218. typedef int (*ERR_print_errors_callback_t)(const char *str, size_t len,
  219. void *ctx);
  220. // ERR_print_errors_cb clears the current thread's error queue, calling
  221. // |callback| with a string representation of each error, from the least recent
  222. // to the most recent error.
  223. //
  224. // The string will have the following format (which differs from
  225. // |ERR_error_string|):
  226. //
  227. // [thread id]:error:[error code]:[library name]:OPENSSL_internal:[reason string]:[file]:[line number]:[optional string data]
  228. //
  229. // The callback can return one to continue the iteration or zero to stop it.
  230. // The |ctx| argument is an opaque value that is passed through to the
  231. // callback.
  232. OPENSSL_EXPORT void ERR_print_errors_cb(ERR_print_errors_callback_t callback,
  233. void *ctx);
  234. // ERR_print_errors_fp clears the current thread's error queue, printing each
  235. // error to |file|. See |ERR_print_errors_cb| for the format.
  236. OPENSSL_EXPORT void ERR_print_errors_fp(FILE *file);
  237. // Clearing errors.
  238. // ERR_clear_error clears the error queue for the current thread.
  239. OPENSSL_EXPORT void ERR_clear_error(void);
  240. // ERR_set_mark "marks" the most recent error for use with |ERR_pop_to_mark|.
  241. // It returns one if an error was marked and zero if there are no errors.
  242. OPENSSL_EXPORT int ERR_set_mark(void);
  243. // ERR_pop_to_mark removes errors from the most recent to the least recent
  244. // until (and not including) a "marked" error. It returns zero if no marked
  245. // error was found (and thus all errors were removed) and one otherwise. Errors
  246. // are marked using |ERR_set_mark|.
  247. OPENSSL_EXPORT int ERR_pop_to_mark(void);
  248. // Custom errors.
  249. // ERR_get_next_error_library returns a value suitable for passing as the
  250. // |library| argument to |ERR_put_error|. This is intended for code that wishes
  251. // to push its own, non-standard errors to the error queue.
  252. OPENSSL_EXPORT int ERR_get_next_error_library(void);
  253. // Built-in library and reason codes.
  254. // The following values are built-in library codes.
  255. enum {
  256. ERR_LIB_NONE = 1,
  257. ERR_LIB_SYS,
  258. ERR_LIB_BN,
  259. ERR_LIB_RSA,
  260. ERR_LIB_DH,
  261. ERR_LIB_EVP,
  262. ERR_LIB_BUF,
  263. ERR_LIB_OBJ,
  264. ERR_LIB_PEM,
  265. ERR_LIB_DSA,
  266. ERR_LIB_X509,
  267. ERR_LIB_ASN1,
  268. ERR_LIB_CONF,
  269. ERR_LIB_CRYPTO,
  270. ERR_LIB_EC,
  271. ERR_LIB_SSL,
  272. ERR_LIB_BIO,
  273. ERR_LIB_PKCS7,
  274. ERR_LIB_PKCS8,
  275. ERR_LIB_X509V3,
  276. ERR_LIB_RAND,
  277. ERR_LIB_ENGINE,
  278. ERR_LIB_OCSP,
  279. ERR_LIB_UI,
  280. ERR_LIB_COMP,
  281. ERR_LIB_ECDSA,
  282. ERR_LIB_ECDH,
  283. ERR_LIB_HMAC,
  284. ERR_LIB_DIGEST,
  285. ERR_LIB_CIPHER,
  286. ERR_LIB_HKDF,
  287. ERR_LIB_TRUST_TOKEN,
  288. ERR_LIB_USER,
  289. ERR_NUM_LIBS
  290. };
  291. // The following reason codes used to denote an error occuring in another
  292. // library. They are sometimes used for a stack trace.
  293. #define ERR_R_SYS_LIB ERR_LIB_SYS
  294. #define ERR_R_BN_LIB ERR_LIB_BN
  295. #define ERR_R_RSA_LIB ERR_LIB_RSA
  296. #define ERR_R_DH_LIB ERR_LIB_DH
  297. #define ERR_R_EVP_LIB ERR_LIB_EVP
  298. #define ERR_R_BUF_LIB ERR_LIB_BUF
  299. #define ERR_R_OBJ_LIB ERR_LIB_OBJ
  300. #define ERR_R_PEM_LIB ERR_LIB_PEM
  301. #define ERR_R_DSA_LIB ERR_LIB_DSA
  302. #define ERR_R_X509_LIB ERR_LIB_X509
  303. #define ERR_R_ASN1_LIB ERR_LIB_ASN1
  304. #define ERR_R_CONF_LIB ERR_LIB_CONF
  305. #define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO
  306. #define ERR_R_EC_LIB ERR_LIB_EC
  307. #define ERR_R_SSL_LIB ERR_LIB_SSL
  308. #define ERR_R_BIO_LIB ERR_LIB_BIO
  309. #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7
  310. #define ERR_R_PKCS8_LIB ERR_LIB_PKCS8
  311. #define ERR_R_X509V3_LIB ERR_LIB_X509V3
  312. #define ERR_R_RAND_LIB ERR_LIB_RAND
  313. #define ERR_R_DSO_LIB ERR_LIB_DSO
  314. #define ERR_R_ENGINE_LIB ERR_LIB_ENGINE
  315. #define ERR_R_OCSP_LIB ERR_LIB_OCSP
  316. #define ERR_R_UI_LIB ERR_LIB_UI
  317. #define ERR_R_COMP_LIB ERR_LIB_COMP
  318. #define ERR_R_ECDSA_LIB ERR_LIB_ECDSA
  319. #define ERR_R_ECDH_LIB ERR_LIB_ECDH
  320. #define ERR_R_STORE_LIB ERR_LIB_STORE
  321. #define ERR_R_FIPS_LIB ERR_LIB_FIPS
  322. #define ERR_R_CMS_LIB ERR_LIB_CMS
  323. #define ERR_R_TS_LIB ERR_LIB_TS
  324. #define ERR_R_HMAC_LIB ERR_LIB_HMAC
  325. #define ERR_R_JPAKE_LIB ERR_LIB_JPAKE
  326. #define ERR_R_USER_LIB ERR_LIB_USER
  327. #define ERR_R_DIGEST_LIB ERR_LIB_DIGEST
  328. #define ERR_R_CIPHER_LIB ERR_LIB_CIPHER
  329. #define ERR_R_HKDF_LIB ERR_LIB_HKDF
  330. #define ERR_R_TRUST_TOKEN_LIB ERR_LIB_TRUST_TOKEN
  331. // The following values are global reason codes. They may occur in any library.
  332. #define ERR_R_FATAL 64
  333. #define ERR_R_MALLOC_FAILURE (1 | ERR_R_FATAL)
  334. #define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2 | ERR_R_FATAL)
  335. #define ERR_R_PASSED_NULL_PARAMETER (3 | ERR_R_FATAL)
  336. #define ERR_R_INTERNAL_ERROR (4 | ERR_R_FATAL)
  337. #define ERR_R_OVERFLOW (5 | ERR_R_FATAL)
  338. // Deprecated functions.
  339. // ERR_remove_state calls |ERR_clear_error|.
  340. OPENSSL_EXPORT void ERR_remove_state(unsigned long pid);
  341. // ERR_remove_thread_state clears the error queue for the current thread if
  342. // |tid| is NULL. Otherwise it calls |assert(0)|, because it's no longer
  343. // possible to delete the error queue for other threads.
  344. //
  345. // Use |ERR_clear_error| instead. Note error queues are deleted automatically on
  346. // thread exit. You do not need to call this function to release memory.
  347. OPENSSL_EXPORT void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
  348. // ERR_func_error_string returns the string "OPENSSL_internal".
  349. OPENSSL_EXPORT const char *ERR_func_error_string(uint32_t packed_error);
  350. // ERR_error_string behaves like |ERR_error_string_n| but |len| is implicitly
  351. // |ERR_ERROR_STRING_BUF_LEN|.
  352. //
  353. // Additionally, if |buf| is NULL, the error string is placed in a static buffer
  354. // which is returned. This is not thread-safe and only exists for backwards
  355. // compatibility with legacy callers. The static buffer will be overridden by
  356. // calls in other threads.
  357. //
  358. // Use |ERR_error_string_n| instead.
  359. //
  360. // TODO(fork): remove this function.
  361. OPENSSL_EXPORT char *ERR_error_string(uint32_t packed_error, char *buf);
  362. #define ERR_ERROR_STRING_BUF_LEN 120
  363. // ERR_GET_FUNC returns zero. BoringSSL errors do not report a function code.
  364. #define ERR_GET_FUNC(packed_error) 0
  365. // ERR_TXT_* are provided for compatibility with code that assumes that it's
  366. // using OpenSSL.
  367. #define ERR_TXT_STRING ERR_FLAG_STRING
  368. #define ERR_TXT_MALLOCED ERR_FLAG_MALLOCED
  369. // Private functions.
  370. // ERR_clear_system_error clears the system's error value (i.e. errno).
  371. OPENSSL_EXPORT void ERR_clear_system_error(void);
  372. // OPENSSL_PUT_ERROR is used by OpenSSL code to add an error to the error
  373. // queue.
  374. #define OPENSSL_PUT_ERROR(library, reason) \
  375. ERR_put_error(ERR_LIB_##library, 0, reason, __FILE__, __LINE__)
  376. // OPENSSL_PUT_SYSTEM_ERROR is used by OpenSSL code to add an error from the
  377. // operating system to the error queue.
  378. // TODO(fork): include errno.
  379. #define OPENSSL_PUT_SYSTEM_ERROR() \
  380. ERR_put_error(ERR_LIB_SYS, 0, 0, __FILE__, __LINE__);
  381. // ERR_put_error adds an error to the error queue, dropping the least recent
  382. // error if necessary for space reasons.
  383. OPENSSL_EXPORT void ERR_put_error(int library, int unused, int reason,
  384. const char *file, unsigned line);
  385. // ERR_add_error_data takes a variable number (|count|) of const char*
  386. // pointers, concatenates them and sets the result as the data on the most
  387. // recent error.
  388. OPENSSL_EXPORT void ERR_add_error_data(unsigned count, ...);
  389. // ERR_add_error_dataf takes a printf-style format and arguments, and sets the
  390. // result as the data on the most recent error.
  391. OPENSSL_EXPORT void ERR_add_error_dataf(const char *format, ...)
  392. OPENSSL_PRINTF_FORMAT_FUNC(1, 2);
  393. // ERR_set_error_data sets the data on the most recent error to |data|, which
  394. // must be a NUL-terminated string. |flags| must contain |ERR_FLAG_STRING|. If
  395. // |flags| contains |ERR_FLAG_MALLOCED|, this function takes ownership of
  396. // |data|, which must have been allocated with |OPENSSL_malloc|. Otherwise, it
  397. // saves a copy of |data|.
  398. //
  399. // Note this differs from OpenSSL which, when |ERR_FLAG_MALLOCED| is unset,
  400. // saves the pointer as-is and requires it remain valid for the lifetime of the
  401. // address space.
  402. OPENSSL_EXPORT void ERR_set_error_data(char *data, int flags);
  403. // ERR_NUM_ERRORS is one more than the limit of the number of errors in the
  404. // queue.
  405. #define ERR_NUM_ERRORS 16
  406. #define ERR_PACK(lib, reason) \
  407. (((((uint32_t)(lib)) & 0xff) << 24) | ((((uint32_t)(reason)) & 0xfff)))
  408. // OPENSSL_DECLARE_ERROR_REASON is used by util/make_errors.h (which generates
  409. // the error defines) to recognise that an additional reason value is needed.
  410. // This is needed when the reason value is used outside of an
  411. // |OPENSSL_PUT_ERROR| macro. The resulting define will be
  412. // ${lib}_R_${reason}.
  413. #define OPENSSL_DECLARE_ERROR_REASON(lib, reason)
  414. #if defined(__cplusplus)
  415. } // extern C
  416. #endif
  417. #endif // OPENSSL_HEADER_ERR_H