error-crypt.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /* error-crypt.h
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /*!
  22. \file wolfssl/wolfcrypt/error-crypt.h
  23. */
  24. /*
  25. DESCRIPTION
  26. This library defines error codes and contains routines for setting and examining
  27. the error status.
  28. */
  29. #ifndef WOLF_CRYPT_ERROR_H
  30. #define WOLF_CRYPT_ERROR_H
  31. #include <wolfssl/wolfcrypt/types.h>
  32. #if defined(HAVE_FIPS) && \
  33. (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
  34. #include <cyassl/ctaocrypt/error-crypt.h>
  35. #endif /* HAVE_FIPS V1 */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /* error codes, add string for new errors !!! */
  40. enum {
  41. MAX_CODE_E = -100, /* errors -101 - -299 */
  42. OPEN_RAN_E = -101, /* opening random device error */
  43. READ_RAN_E = -102, /* reading random device error */
  44. WINCRYPT_E = -103, /* windows crypt init error */
  45. CRYPTGEN_E = -104, /* windows crypt generation error */
  46. RAN_BLOCK_E = -105, /* reading random device would block */
  47. BAD_MUTEX_E = -106, /* Bad mutex operation */
  48. WC_TIMEOUT_E = -107, /* timeout error */
  49. WC_PENDING_E = -108, /* wolfCrypt operation pending (would block) */
  50. WC_NOT_PENDING_E = -109, /* wolfCrypt operation not pending */
  51. MP_INIT_E = -110, /* mp_init error state */
  52. MP_READ_E = -111, /* mp_read error state */
  53. MP_EXPTMOD_E = -112, /* mp_exptmod error state */
  54. MP_TO_E = -113, /* mp_to_xxx error state, can't convert */
  55. MP_SUB_E = -114, /* mp_sub error state, can't subtract */
  56. MP_ADD_E = -115, /* mp_add error state, can't add */
  57. MP_MUL_E = -116, /* mp_mul error state, can't multiply */
  58. MP_MULMOD_E = -117, /* mp_mulmod error state, can't multiply mod */
  59. MP_MOD_E = -118, /* mp_mod error state, can't mod */
  60. MP_INVMOD_E = -119, /* mp_invmod error state, can't inv mod */
  61. MP_CMP_E = -120, /* mp_cmp error state */
  62. MP_ZERO_E = -121, /* got a mp zero result, not expected */
  63. MEMORY_E = -125, /* out of memory error */
  64. VAR_STATE_CHANGE_E = -126, /* var state modified by different thread */
  65. RSA_WRONG_TYPE_E = -130, /* RSA wrong block type for RSA function */
  66. RSA_BUFFER_E = -131, /* RSA buffer error, output too small or
  67. input too large */
  68. BUFFER_E = -132, /* output buffer too small or input too large */
  69. ALGO_ID_E = -133, /* setting algo id error */
  70. PUBLIC_KEY_E = -134, /* setting public key error */
  71. DATE_E = -135, /* setting date validity error */
  72. SUBJECT_E = -136, /* setting subject name error */
  73. ISSUER_E = -137, /* setting issuer name error */
  74. CA_TRUE_E = -138, /* setting CA basic constraint true error */
  75. EXTENSIONS_E = -139, /* setting extensions error */
  76. ASN_PARSE_E = -140, /* ASN parsing error, invalid input */
  77. ASN_VERSION_E = -141, /* ASN version error, invalid number */
  78. ASN_GETINT_E = -142, /* ASN get big int error, invalid data */
  79. ASN_RSA_KEY_E = -143, /* ASN key init error, invalid input */
  80. ASN_OBJECT_ID_E = -144, /* ASN object id error, invalid id */
  81. ASN_TAG_NULL_E = -145, /* ASN tag error, not null */
  82. ASN_EXPECT_0_E = -146, /* ASN expect error, not zero */
  83. ASN_BITSTR_E = -147, /* ASN bit string error, wrong id */
  84. ASN_UNKNOWN_OID_E = -148, /* ASN oid error, unknown sum id */
  85. ASN_DATE_SZ_E = -149, /* ASN date error, bad size */
  86. ASN_BEFORE_DATE_E = -150, /* ASN date error, current date before */
  87. ASN_AFTER_DATE_E = -151, /* ASN date error, current date after */
  88. ASN_SIG_OID_E = -152, /* ASN signature error, mismatched oid */
  89. ASN_TIME_E = -153, /* ASN time error, unknown time type */
  90. ASN_INPUT_E = -154, /* ASN input error, not enough data */
  91. ASN_SIG_CONFIRM_E = -155, /* ASN sig error, confirm failure */
  92. ASN_SIG_HASH_E = -156, /* ASN sig error, unsupported hash type */
  93. ASN_SIG_KEY_E = -157, /* ASN sig error, unsupported key type */
  94. ASN_DH_KEY_E = -158, /* ASN key init error, invalid input */
  95. ASN_CRIT_EXT_E = -160, /* ASN unsupported critical extension */
  96. ASN_ALT_NAME_E = -161, /* ASN alternate name error */
  97. ASN_NO_PEM_HEADER = -162, /* ASN no PEM header found */
  98. ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */
  99. ASN_ECC_KEY_E = -171, /* ASN ECC bad input */
  100. ECC_CURVE_OID_E = -172, /* Unsupported ECC OID curve type */
  101. BAD_FUNC_ARG = -173, /* Bad function argument provided */
  102. NOT_COMPILED_IN = -174, /* Feature not compiled in */
  103. UNICODE_SIZE_E = -175, /* Unicode password too big */
  104. NO_PASSWORD = -176, /* no password provided by user */
  105. ALT_NAME_E = -177, /* alt name size problem, too big */
  106. BAD_OCSP_RESPONDER = -178, /* missing key usage extensions */
  107. CRL_CERT_DATE_ERR = -179, /* CRL date error */
  108. AES_GCM_AUTH_E = -180, /* AES-GCM Authentication check failure */
  109. AES_CCM_AUTH_E = -181, /* AES-CCM Authentication check failure */
  110. ASYNC_INIT_E = -182, /* Async Init type error */
  111. COMPRESS_INIT_E = -183, /* Compress init error */
  112. COMPRESS_E = -184, /* Compress error */
  113. DECOMPRESS_INIT_E = -185, /* DeCompress init error */
  114. DECOMPRESS_E = -186, /* DeCompress error */
  115. BAD_ALIGN_E = -187, /* Bad alignment for operation, no alloc */
  116. ASN_NO_SIGNER_E = -188, /* ASN no signer to confirm failure */
  117. ASN_CRL_CONFIRM_E = -189, /* ASN CRL signature confirm failure */
  118. ASN_CRL_NO_SIGNER_E = -190, /* ASN CRL no signer to confirm failure */
  119. ASN_OCSP_CONFIRM_E = -191, /* ASN OCSP signature confirm failure */
  120. BAD_STATE_E = -192, /* Bad state operation */
  121. BAD_PADDING_E = -193, /* Bad padding, msg not correct length */
  122. REQ_ATTRIBUTE_E = -194, /* setting cert request attributes error */
  123. PKCS7_OID_E = -195, /* PKCS#7, mismatched OID error */
  124. PKCS7_RECIP_E = -196, /* PKCS#7, recipient error */
  125. FIPS_NOT_ALLOWED_E = -197, /* FIPS not allowed error */
  126. ASN_NAME_INVALID_E = -198, /* ASN name constraint error */
  127. RNG_FAILURE_E = -199, /* RNG Failed, Reinitialize */
  128. HMAC_MIN_KEYLEN_E = -200, /* FIPS Mode HMAC Minimum Key Length error */
  129. RSA_PAD_E = -201, /* RSA Padding Error */
  130. LENGTH_ONLY_E = -202, /* Returning output length only */
  131. IN_CORE_FIPS_E = -203, /* In Core Integrity check failure */
  132. AES_KAT_FIPS_E = -204, /* AES KAT failure */
  133. DES3_KAT_FIPS_E = -205, /* DES3 KAT failure */
  134. HMAC_KAT_FIPS_E = -206, /* HMAC KAT failure */
  135. RSA_KAT_FIPS_E = -207, /* RSA KAT failure */
  136. DRBG_KAT_FIPS_E = -208, /* HASH DRBG KAT failure */
  137. DRBG_CONT_FIPS_E = -209, /* HASH DRBG Continuous test failure */
  138. AESGCM_KAT_FIPS_E = -210, /* AESGCM KAT failure */
  139. THREAD_STORE_KEY_E = -211, /* Thread local storage key create failure */
  140. THREAD_STORE_SET_E = -212, /* Thread local storage key set failure */
  141. MAC_CMP_FAILED_E = -213, /* MAC comparison failed */
  142. IS_POINT_E = -214, /* ECC is point on curve failed */
  143. ECC_INF_E = -215, /* ECC point infinity error */
  144. ECC_PRIV_KEY_E = -216, /* ECC private key not valid error */
  145. ECC_OUT_OF_RANGE_E = -217, /* ECC key component out of range */
  146. SRP_CALL_ORDER_E = -218, /* SRP function called in the wrong order. */
  147. SRP_VERIFY_E = -219, /* SRP proof verification failed. */
  148. SRP_BAD_KEY_E = -220, /* SRP bad ephemeral values. */
  149. ASN_NO_SKID = -221, /* ASN no Subject Key Identifier found */
  150. ASN_NO_AKID = -222, /* ASN no Authority Key Identifier found */
  151. ASN_NO_KEYUSAGE = -223, /* ASN no Key Usage found */
  152. SKID_E = -224, /* setting Subject Key Identifier error */
  153. AKID_E = -225, /* setting Authority Key Identifier error */
  154. KEYUSAGE_E = -226, /* Bad Key Usage value */
  155. CERTPOLICIES_E = -227, /* setting Certificate Policies error */
  156. WC_INIT_E = -228, /* wolfcrypt failed to initialize */
  157. SIG_VERIFY_E = -229, /* wolfcrypt signature verify error */
  158. BAD_COND_E = -230, /* Bad condition variable operation */
  159. SIG_TYPE_E = -231, /* Signature Type not enabled/available */
  160. HASH_TYPE_E = -232, /* Hash Type not enabled/available */
  161. WC_KEY_SIZE_E = -234, /* Key size error, either too small or large */
  162. ASN_COUNTRY_SIZE_E = -235, /* ASN Cert Gen, invalid country code size */
  163. MISSING_RNG_E = -236, /* RNG required but not provided */
  164. ASN_PATHLEN_SIZE_E = -237, /* ASN CA path length too large error */
  165. ASN_PATHLEN_INV_E = -238, /* ASN CA path length inversion error */
  166. BAD_KEYWRAP_ALG_E = -239,
  167. BAD_KEYWRAP_IV_E = -240, /* Decrypted AES key wrap IV incorrect */
  168. WC_CLEANUP_E = -241, /* wolfcrypt cleanup failed */
  169. ECC_CDH_KAT_FIPS_E = -242, /* ECC CDH Known Answer Test failure */
  170. DH_CHECK_PUB_E = -243, /* DH Check Pub Key error */
  171. BAD_PATH_ERROR = -244, /* Bad path for opendir */
  172. ASYNC_OP_E = -245, /* Async operation error */
  173. ECC_PRIVATEONLY_E = -246, /* Invalid use of private only ECC key*/
  174. EXTKEYUSAGE_E = -247, /* Bad Extended Key Usage value */
  175. WC_HW_E = -248, /* Error with hardware crypto use */
  176. WC_HW_WAIT_E = -249, /* Hardware waiting on resource */
  177. PSS_SALTLEN_E = -250, /* PSS length of salt is too long for hash */
  178. PRIME_GEN_E = -251, /* Failure finding a prime. */
  179. BER_INDEF_E = -252, /* Cannot decode indefinite length BER. */
  180. RSA_OUT_OF_RANGE_E = -253, /* Ciphertext to decrypt out of range. */
  181. RSAPSS_PAT_FIPS_E = -254, /* RSA-PSS PAT failure */
  182. ECDSA_PAT_FIPS_E = -255, /* ECDSA PAT failure */
  183. DH_KAT_FIPS_E = -256, /* DH KAT failure */
  184. AESCCM_KAT_FIPS_E = -257, /* AESCCM KAT failure */
  185. SHA3_KAT_FIPS_E = -258, /* SHA-3 KAT failure */
  186. ECDHE_KAT_FIPS_E = -259, /* ECDHE KAT failure */
  187. AES_GCM_OVERFLOW_E = -260, /* AES-GCM invocation counter overflow. */
  188. AES_CCM_OVERFLOW_E = -261, /* AES-CCM invocation counter overflow. */
  189. RSA_KEY_PAIR_E = -262, /* RSA Key Pair-Wise Consistency check fail. */
  190. DH_CHECK_PRIV_E = -263, /* DH Check Priv Key error */
  191. WC_AFALG_SOCK_E = -264, /* AF_ALG socket error */
  192. WC_DEVCRYPTO_E = -265, /* /dev/crypto error */
  193. ZLIB_INIT_ERROR = -266, /* zlib init error */
  194. ZLIB_COMPRESS_ERROR = -267, /* zlib compression error */
  195. ZLIB_DECOMPRESS_ERROR = -268, /* zlib decompression error */
  196. PKCS7_NO_SIGNER_E = -269, /* No signer in PKCS#7 signed data msg */
  197. WC_PKCS7_WANT_READ_E= -270, /* PKCS7 operations wants more input */
  198. CRYPTOCB_UNAVAILABLE= -271, /* Crypto callback unavailable */
  199. PKCS7_SIGNEEDS_CHECK= -272, /* signature needs verified by caller */
  200. PSS_SALTLEN_RECOVER_E=-273, /* PSS slat length not recoverable */
  201. CHACHA_POLY_OVERFLOW =-274, /* ChaCha20Poly1305 limit overflow */
  202. ASN_SELF_SIGNED_E = -275, /* ASN self-signed certificate error */
  203. SAKKE_VERIFY_FAIL_E = -276, /* SAKKE derivation verification error */
  204. MISSING_IV = -277, /* IV was not set */
  205. MISSING_KEY = -278, /* Key was not set */
  206. BAD_LENGTH_E = -279, /* Value of length parameter is invalid. */
  207. ECDSA_KAT_FIPS_E = -280, /* ECDSA KAT failure */
  208. RSA_PAT_FIPS_E = -281, /* RSA Pairwise failure */
  209. KDF_TLS12_KAT_FIPS_E = -282, /* TLS12 KDF KAT failure */
  210. KDF_TLS13_KAT_FIPS_E = -283, /* TLS13 KDF KAT failure */
  211. KDF_SSH_KAT_FIPS_E = -284, /* SSH KDF KAT failure */
  212. DHE_PCT_E = -285, /* DHE Pairwise Consistency Test failure */
  213. ECC_PCT_E = -286, /* ECDHE Pairwise Consistency Test failure */
  214. FIPS_PRIVATE_KEY_LOCKED_E = -287, /* Cannot export private key. */
  215. PROTOCOLCB_UNAVAILABLE = -288, /* Protocol callback unavailable */
  216. AES_SIV_AUTH_E = -289, /* AES-SIV authentication failed */
  217. NO_VALID_DEVID = -290, /* no valid device ID */
  218. IO_FAILED_E = -291, /* Input/output failure */
  219. SYSLIB_FAILED_E = -292, /* System/library call failed */
  220. USE_HW_PSK = -293, /* Callback return to indicate HW has PSK */
  221. ENTROPY_RT_E = -294, /* Entropy Repetition Test failed */
  222. ENTROPY_APT_E = -295, /* Entropy Adaptive Proportion Test failed */
  223. ASN_DEPTH_E = -296, /* Invalid ASN.1 - depth check */
  224. ASN_LEN_E = -297, /* ASN.1 length invalid */
  225. WC_LAST_E = -297, /* Update this to indicate last error */
  226. MIN_CODE_E = -300 /* errors -101 - -299 */
  227. /* add new companion error id strings for any new error codes
  228. wolfcrypt/src/error.c !!! */
  229. };
  230. #ifdef NO_ERROR_STRINGS
  231. #define wc_GetErrorString(error) "no support for error strings built in"
  232. #define wc_ErrorString(err, buf) \
  233. (void)err; XSTRNCPY((buf), wc_GetErrorString((err)), \
  234. WOLFSSL_MAX_ERROR_SZ);
  235. #else
  236. WOLFSSL_API void wc_ErrorString(int err, char* buff);
  237. WOLFSSL_ABI WOLFSSL_API const char* wc_GetErrorString(int error);
  238. #endif
  239. #ifdef __cplusplus
  240. } /* extern "C" */
  241. #endif
  242. #endif /* WOLF_CRYPT_ERROR_H */