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