25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

510 lines
20 KiB

  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 signalled 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) A function identifier and reason code.
  124. * 3) The file and line number of the call that added the error.
  125. * 4) A pointer to some error specific data, which may be NULL.
  126. *
  127. * The library identifier, function identifier and reason code are packed in a
  128. * uint32_t and there exist various functions for unpacking it.
  129. *
  130. * The typical behaviour is that an error will occur deep in a call queue and
  131. * that code will push an error onto the error queue. As the error queue
  132. * unwinds, other functions will push their own errors. Thus, the "least
  133. * recent" error is the most specific and the other errors will provide a
  134. * backtrace of sorts. */
  135. /* Startup and shutdown. */
  136. /* ERR_load_BIO_strings does nothing.
  137. *
  138. * TODO(fork): remove. libjingle calls this. */
  139. OPENSSL_EXPORT void ERR_load_BIO_strings(void);
  140. /* ERR_load_ERR_strings does nothing. */
  141. OPENSSL_EXPORT void ERR_load_ERR_strings(void);
  142. /* ERR_load_crypto_strings does nothing. */
  143. OPENSSL_EXPORT void ERR_load_crypto_strings(void);
  144. /* ERR_free_strings does nothing. */
  145. OPENSSL_EXPORT void ERR_free_strings(void);
  146. /* Reading and formatting errors. */
  147. /* ERR_get_error gets the packed error code for the least recent error and
  148. * removes that error from the queue. If there are no errors in the queue then
  149. * it returns zero. */
  150. OPENSSL_EXPORT uint32_t ERR_get_error(void);
  151. /* ERR_get_error_line acts like |ERR_get_error|, except that the file and line
  152. * number of the call that added the error are also returned. */
  153. OPENSSL_EXPORT uint32_t ERR_get_error_line(const char **file, int *line);
  154. /* ERR_get_error_line_data acts like |ERR_get_error_line|, but also returns the
  155. * error-specific data pointer and flags. The flags are a bitwise-OR of
  156. * |ERR_FLAG_*| values. The error-specific data is owned by the error queue
  157. * and the pointer becomes invalid after the next call that affects the same
  158. * thread's error queue. If |*flags| contains |ERR_FLAG_STRING| then |*data| is
  159. * human-readable. */
  160. OPENSSL_EXPORT uint32_t ERR_get_error_line_data(const char **file, int *line,
  161. const char **data, int *flags);
  162. /* The "peek" functions act like the |ERR_get_error| functions, above, but they
  163. * do not remove the error from the queue. */
  164. OPENSSL_EXPORT uint32_t ERR_peek_error(void);
  165. OPENSSL_EXPORT uint32_t ERR_peek_error_line(const char **file, int *line);
  166. OPENSSL_EXPORT uint32_t ERR_peek_error_line_data(const char **file, int *line,
  167. const char **data, int *flags);
  168. /* The "peek last" functions act like the "peek" functions, above, except that
  169. * they return the most recent error. */
  170. OPENSSL_EXPORT uint32_t ERR_peek_last_error(void);
  171. OPENSSL_EXPORT uint32_t ERR_peek_last_error_line(const char **file, int *line);
  172. OPENSSL_EXPORT uint32_t ERR_peek_last_error_line_data(const char **file,
  173. int *line,
  174. const char **data,
  175. int *flags);
  176. /* ERR_error_string generates a human-readable string representing
  177. * |packed_error|, places it at |buf| (which must be at least
  178. * ERR_ERROR_STRING_BUF_LEN bytes long) and returns |buf|. If |buf| is NULL,
  179. * the error string is placed in a static buffer which is returned. (The static
  180. * buffer may be overridden by concurrent calls in other threads so this form
  181. * is deprecated.)
  182. *
  183. * The string will have the following format:
  184. *
  185. * error:[error code]:[library name]:[function name]:[reason string]
  186. *
  187. * error code is an 8 digit hexadecimal number; library name, function name
  188. * and reason string are ASCII text.
  189. *
  190. * TODO(fork): remove in favour of |ERR_error_string_n|. */
  191. OPENSSL_EXPORT char *ERR_error_string(uint32_t packed_error, char *buf);
  192. #define ERR_ERROR_STRING_BUF_LEN 256
  193. /* ERR_error_string_n is a variant of |ERR_error_string| that writes at most
  194. * len characters (including the terminating NUL) and truncates the string if
  195. * necessary. If |len| is greater than zero then |buf| is always NUL
  196. * terminated. */
  197. OPENSSL_EXPORT void ERR_error_string_n(uint32_t packed_error, char *buf,
  198. size_t len);
  199. /* ERR_lib_error_string returns a string representation of the library that
  200. * generated |packed_error|. */
  201. OPENSSL_EXPORT const char *ERR_lib_error_string(uint32_t packed_error);
  202. /* ERR_func_error_string returns a string representation of the function that
  203. * generated |packed_error|. */
  204. OPENSSL_EXPORT const char *ERR_func_error_string(uint32_t packed_error);
  205. /* ERR_reason_error_string returns a string representation of the reason for
  206. * |packed_error|. */
  207. OPENSSL_EXPORT const char *ERR_reason_error_string(uint32_t packed_error);
  208. /* ERR_print_errors_callback_t is the type of a function used by
  209. * |ERR_print_errors_cb|. It takes a pointer to a human readable string (and
  210. * its length) that describes an entry in the error queue. The |ctx| argument
  211. * is an opaque pointer given to |ERR_print_errors_cb|.
  212. *
  213. * It should return one on success or zero on error, which will stop the
  214. * iteration over the error queue. */
  215. typedef int (*ERR_print_errors_callback_t)(const char *str, size_t len,
  216. void *ctx);
  217. /* ERR_print_errors_cb calls |callback| with a string representation of each
  218. * error in the current thread's error queue, from the least recent to the most
  219. * recent error.
  220. *
  221. * The string will have the following format (which differs from
  222. * |ERR_error_string|):
  223. *
  224. * [thread id]:error:[error code]:[library name]:[function name]:
  225. * [reason string]:[file]:[line number]:[optional string data]
  226. *
  227. * (All in one line.)
  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 prints the current contents of the error stack to |file|
  235. * using human readable strings where possible. */
  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_remove_thread_state clears the error queue for the current thread if
  241. * |tid| is NULL. Otherwise it calls |assert(0)|, because it's no longer
  242. * possible to delete the error queue for other threads.
  243. *
  244. * Error queues are thread-local data and are deleted automatically. You do not
  245. * need to call this function. Use |ERR_clear_error|. */
  246. OPENSSL_EXPORT void ERR_remove_thread_state(const CRYPTO_THREADID *tid);
  247. /* Custom errors. */
  248. /* ERR_get_next_error_library returns a value suitable for passing as the
  249. * |library| argument to |ERR_put_error|. This is intended for code that wishes
  250. * to push its own, non-standard errors to the error queue. */
  251. OPENSSL_EXPORT int ERR_get_next_error_library(void);
  252. /* Deprecated functions. */
  253. /* ERR_remove_state calls |ERR_clear_error|. */
  254. OPENSSL_EXPORT void ERR_remove_state(unsigned long pid);
  255. /* Private functions. */
  256. /* ERR_clear_system_error clears the system's error value (i.e. errno). */
  257. OPENSSL_EXPORT void ERR_clear_system_error(void);
  258. /* OPENSSL_PUT_ERROR is used by OpenSSL code to add an error to the error
  259. * queue. */
  260. #define OPENSSL_PUT_ERROR(library, func, reason) \
  261. ERR_put_error(ERR_LIB_##library, library##_F_##func, reason, __FILE__, \
  262. __LINE__)
  263. /* OPENSSL_PUT_SYSTEM_ERROR is used by OpenSSL code to add an error from the
  264. * operating system to the error queue. */
  265. /* TODO(fork): include errno. */
  266. #define OPENSSL_PUT_SYSTEM_ERROR(func) \
  267. ERR_put_error(ERR_LIB_SYS, SYS_F_##func, 0, __FILE__, __LINE__);
  268. /* ERR_put_error adds an error to the error queue, dropping the least recent
  269. * error if neccessary for space reasons. */
  270. OPENSSL_EXPORT void ERR_put_error(int library, int func, int reason,
  271. const char *file, unsigned line);
  272. /* ERR_add_error_data takes a variable number (|count|) of const char*
  273. * pointers, concatenates them and sets the result as the data on the most
  274. * recent error. */
  275. OPENSSL_EXPORT void ERR_add_error_data(unsigned count, ...);
  276. /* ERR_add_error_dataf takes a printf-style format and arguments, and sets the
  277. * result as the data on the most recent error. */
  278. OPENSSL_EXPORT void ERR_add_error_dataf(const char *format, ...);
  279. /* ERR_set_mark "marks" the most recent error for use with |ERR_pop_to_mark|.
  280. * It returns one if an error was marked and zero if there are no errors. */
  281. OPENSSL_EXPORT int ERR_set_mark(void);
  282. /* ERR_pop_to_mark removes errors from the most recent to the least recent
  283. * until (and not including) a "marked" error. It returns zero if no marked
  284. * error was found (and thus all errors were removed) and one otherwise. Errors
  285. * are marked using |ERR_set_mark|. */
  286. OPENSSL_EXPORT int ERR_pop_to_mark(void);
  287. struct err_error_st {
  288. /* file contains the filename where the error occured. */
  289. const char *file;
  290. /* data contains optional data. It must be freed with |OPENSSL_free| if
  291. * |flags&ERR_FLAG_MALLOCED|. */
  292. char *data;
  293. /* packed contains the error library, function and reason, as packed by
  294. * ERR_PACK. */
  295. uint32_t packed;
  296. /* line contains the line number where the error occured. */
  297. uint16_t line;
  298. /* flags contains a bitwise-OR of ERR_FLAG_* values. */
  299. uint8_t flags;
  300. };
  301. /* ERR_FLAG_STRING means that the |data| member is a NUL-terminated string that
  302. * can be printed. */
  303. #define ERR_FLAG_STRING 1
  304. /* ERR_TXT_STRING is provided for compatibility with code that assumes that
  305. * it's using OpenSSL. */
  306. #define ERR_TXT_STRING ERR_FLAG_STRING
  307. /* ERR_FLAG_PUBLIC_MASK is applied to the flags field before it is returned
  308. * from functions like |ERR_get_error_line_data|. */
  309. #define ERR_FLAG_PUBLIC_MASK 0xf
  310. /* The following flag values are internal and are masked when flags are
  311. * returned from functions like |ERR_get_error_line_data|. */
  312. /* ERR_FLAG_MALLOCED means the the |data| member must be freed when no longer
  313. * needed. */
  314. #define ERR_FLAG_MALLOCED 16
  315. /* ERR_FLAG_MARK is used to indicate a reversion point in the queue. See
  316. * |ERR_pop_to_mark|. */
  317. #define ERR_FLAG_MARK 32
  318. /* ERR_NUM_ERRORS is the limit of the number of errors in the queue. */
  319. #define ERR_NUM_ERRORS 16
  320. /* ERR_STATE contains the per-thread, error queue. */
  321. typedef struct err_state_st {
  322. /* errors contains the ERR_NUM_ERRORS most recent errors, organised as a ring
  323. * buffer. */
  324. struct err_error_st errors[ERR_NUM_ERRORS];
  325. /* top contains the index one past the most recent error. If |top| equals
  326. * |bottom| then the queue is empty. */
  327. unsigned top;
  328. /* bottom contains the index of the last error in the queue. */
  329. unsigned bottom;
  330. /* to_free, if not NULL, contains a pointer owned by this structure that was
  331. * previously a |data| pointer of one of the elements of |errors|. */
  332. void *to_free;
  333. } ERR_STATE;
  334. enum {
  335. ERR_LIB_NONE = 1,
  336. ERR_LIB_SYS,
  337. ERR_LIB_BN,
  338. ERR_LIB_RSA,
  339. ERR_LIB_DH,
  340. ERR_LIB_EVP,
  341. ERR_LIB_BUF,
  342. ERR_LIB_OBJ,
  343. ERR_LIB_PEM,
  344. ERR_LIB_DSA,
  345. ERR_LIB_X509,
  346. ERR_LIB_ASN1,
  347. ERR_LIB_CONF,
  348. ERR_LIB_CRYPTO,
  349. ERR_LIB_EC,
  350. ERR_LIB_SSL,
  351. ERR_LIB_BIO,
  352. ERR_LIB_PKCS7,
  353. ERR_LIB_PKCS8,
  354. ERR_LIB_X509V3,
  355. ERR_LIB_RAND,
  356. ERR_LIB_ENGINE,
  357. ERR_LIB_OCSP,
  358. ERR_LIB_UI,
  359. ERR_LIB_COMP,
  360. ERR_LIB_ECDSA,
  361. ERR_LIB_ECDH,
  362. ERR_LIB_HMAC,
  363. ERR_LIB_DIGEST,
  364. ERR_LIB_CIPHER,
  365. ERR_LIB_USER,
  366. ERR_LIB_HKDF,
  367. ERR_NUM_LIBS
  368. };
  369. #define ERR_R_SYS_LIB ERR_LIB_SYS
  370. #define ERR_R_BN_LIB ERR_LIB_BN
  371. #define ERR_R_RSA_LIB ERR_LIB_RSA
  372. #define ERR_R_DH_LIB ERR_LIB_DH
  373. #define ERR_R_EVP_LIB ERR_LIB_EVP
  374. #define ERR_R_BUF_LIB ERR_LIB_BUF
  375. #define ERR_R_OBJ_LIB ERR_LIB_OBJ
  376. #define ERR_R_PEM_LIB ERR_LIB_PEM
  377. #define ERR_R_DSA_LIB ERR_LIB_DSA
  378. #define ERR_R_X509_LIB ERR_LIB_X509
  379. #define ERR_R_ASN1_LIB ERR_LIB_ASN1
  380. #define ERR_R_CONF_LIB ERR_LIB_CONF
  381. #define ERR_R_CRYPTO_LIB ERR_LIB_CRYPTO
  382. #define ERR_R_EC_LIB ERR_LIB_EC
  383. #define ERR_R_SSL_LIB ERR_LIB_SSL
  384. #define ERR_R_BIO_LIB ERR_LIB_BIO
  385. #define ERR_R_PKCS7_LIB ERR_LIB_PKCS7
  386. #define ERR_R_PKCS8_LIB ERR_LIB_PKCS8
  387. #define ERR_R_X509V3_LIB ERR_LIB_X509V3
  388. #define ERR_R_RAND_LIB ERR_LIB_RAND
  389. #define ERR_R_DSO_LIB ERR_LIB_DSO
  390. #define ERR_R_ENGINE_LIB ERR_LIB_ENGINE
  391. #define ERR_R_OCSP_LIB ERR_LIB_OCSP
  392. #define ERR_R_UI_LIB ERR_LIB_UI
  393. #define ERR_R_COMP_LIB ERR_LIB_COMP
  394. #define ERR_R_ECDSA_LIB ERR_LIB_ECDSA
  395. #define ERR_R_ECDH_LIB ERR_LIB_ECDH
  396. #define ERR_R_STORE_LIB ERR_LIB_STORE
  397. #define ERR_R_FIPS_LIB ERR_LIB_FIPS
  398. #define ERR_R_CMS_LIB ERR_LIB_CMS
  399. #define ERR_R_TS_LIB ERR_LIB_TS
  400. #define ERR_R_HMAC_LIB ERR_LIB_HMAC
  401. #define ERR_R_JPAKE_LIB ERR_LIB_JPAKE
  402. #define ERR_R_USER_LIB ERR_LIB_USER
  403. #define ERR_R_DIGEST_LIB ERR_LIB_DIGEST
  404. #define ERR_R_CIPHER_LIB ERR_LIB_CIPHER
  405. #define ERR_R_HKDF_LIB ERR_LIB_HKDF
  406. /* Global reasons. */
  407. #define ERR_R_FATAL 64
  408. #define ERR_R_MALLOC_FAILURE (1 | ERR_R_FATAL)
  409. #define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2 | ERR_R_FATAL)
  410. #define ERR_R_PASSED_NULL_PARAMETER (3 | ERR_R_FATAL)
  411. #define ERR_R_INTERNAL_ERROR (4 | ERR_R_FATAL)
  412. #define ERR_R_OVERFLOW (5 | ERR_R_FATAL)
  413. /* System error functions */
  414. #define SYS_F_fopen 100
  415. #define SYS_F_fclose 101
  416. #define SYS_F_fread 102
  417. #define SYS_F_fwrite 103
  418. #define SYS_F_socket 104
  419. #define SYS_F_setsockopt 105
  420. #define SYS_F_connect 106
  421. #define SYS_F_getaddrinfo 107
  422. #define ERR_PACK(lib, func, reason) \
  423. (((((uint32_t)lib) & 0xff) << 24) | ((((uint32_t)func) & 0xfff) << 12) | \
  424. ((((uint32_t)reason) & 0xfff)))
  425. #define ERR_GET_LIB(packed_error) ((int)(((packed_error) >> 24) & 0xff))
  426. #define ERR_GET_FUNC(packed_error) ((int)(((packed_error) >> 12) & 0xfff))
  427. #define ERR_GET_REASON(packed_error) ((int)((packed_error) & 0xfff))
  428. /* OPENSSL_DECLARE_ERROR_REASON is used by util/make_errors.h (which generates
  429. * the error defines) to recognise that an additional reason value is needed.
  430. * This is needed when the reason value is used outside of an
  431. * |OPENSSL_PUT_ERROR| macro. The resulting define will be
  432. * ${lib}_R_${reason}. */
  433. #define OPENSSL_DECLARE_ERROR_REASON(lib, reason)
  434. /* OPENSSL_DECLARE_ERROR_FUNCTION is used by util/make_errors.h (which
  435. * generates the error * defines to recognise that an additional function value
  436. * is needed. This is * needed when the function value is used outside of an
  437. * |OPENSSL_PUT_ERROR| * macro. The resulting define will be
  438. * ${lib}_F_${reason}. */
  439. #define OPENSSL_DECLARE_ERROR_FUNCTION(lib, function_name)
  440. #if defined(__cplusplus)
  441. } /* extern C */
  442. #endif
  443. #endif /* OPENSSL_HEADER_ERR_H */