Xuyi Wang / wolfcrypt

Dependents:   OS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers error-crypt.h Source File

error-crypt.h

00001 /* error-crypt.h
00002  *
00003  * Copyright (C) 2006-2017 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 /*!
00023     \file wolfssl/wolfcrypt/error-crypt.h
00024 */
00025 
00026 #ifndef WOLF_CRYPT_ERROR_H
00027 #define WOLF_CRYPT_ERROR_H
00028 
00029 #include <wolfcrypt/types.h>
00030 
00031 #ifdef HAVE_FIPS
00032     #include <cyassl/ctaocrypt/error-crypt.h>
00033 #endif /* HAVE_FIPS */
00034 
00035 #ifdef __cplusplus
00036     extern "C" {
00037 #endif
00038 
00039 
00040 /* error codes, add string for new errors !!! */
00041 enum {
00042     MAX_CODE_E         = -100,  /* errors -101 - -299 */
00043     OPEN_RAN_E         = -101,  /* opening random device error */
00044     READ_RAN_E         = -102,  /* reading random device error */
00045     WINCRYPT_E         = -103,  /* windows crypt init error */
00046     CRYPTGEN_E         = -104,  /* windows crypt generation error */
00047     RAN_BLOCK_E        = -105,  /* reading random device would block */
00048     BAD_MUTEX_E        = -106,  /* Bad mutex operation */
00049     WC_TIMEOUT_E       = -107,  /* timeout error */
00050     WC_PENDING_E       = -108,  /* wolfCrypt operation pending (would block) */
00051     WC_NOT_PENDING_E   = -109,  /* wolfCrypt operation not pending */
00052 
00053     MP_INIT_E          = -110,  /* mp_init error state */
00054     MP_READ_E          = -111,  /* mp_read error state */
00055     MP_EXPTMOD_E       = -112,  /* mp_exptmod error state */
00056     MP_TO_E            = -113,  /* mp_to_xxx error state, can't convert */
00057     MP_SUB_E           = -114,  /* mp_sub error state, can't subtract */
00058     MP_ADD_E           = -115,  /* mp_add error state, can't add */
00059     MP_MUL_E           = -116,  /* mp_mul error state, can't multiply */
00060     MP_MULMOD_E        = -117,  /* mp_mulmod error state, can't multiply mod */
00061     MP_MOD_E           = -118,  /* mp_mod error state, can't mod */
00062     MP_INVMOD_E        = -119,  /* mp_invmod error state, can't inv mod */
00063     MP_CMP_E           = -120,  /* mp_cmp error state */
00064     MP_ZERO_E          = -121,  /* got a mp zero result, not expected */
00065 
00066     MEMORY_E           = -125,  /* out of memory error */
00067     VAR_STATE_CHANGE_E = -126,  /* var state modified by different thread */
00068 
00069     RSA_WRONG_TYPE_E   = -130,  /* RSA wrong block type for RSA function */
00070     RSA_BUFFER_E       = -131,  /* RSA buffer error, output too small or
00071                                    input too large */
00072     BUFFER_E           = -132,  /* output buffer too small or input too large */
00073     ALGO_ID_E          = -133,  /* setting algo id error */
00074     PUBLIC_KEY_E       = -134,  /* setting public key error */
00075     DATE_E             = -135,  /* setting date validity error */
00076     SUBJECT_E          = -136,  /* setting subject name error */
00077     ISSUER_E           = -137,  /* setting issuer  name error */
00078     CA_TRUE_E          = -138,  /* setting CA basic constraint true error */
00079     EXTENSIONS_E       = -139,  /* setting extensions error */
00080 
00081     ASN_PARSE_E        = -140,  /* ASN parsing error, invalid input */
00082     ASN_VERSION_E      = -141,  /* ASN version error, invalid number */
00083     ASN_GETINT_E       = -142,  /* ASN get big int error, invalid data */
00084     ASN_RSA_KEY_E      = -143,  /* ASN key init error, invalid input */
00085     ASN_OBJECT_ID_E    = -144,  /* ASN object id error, invalid id */
00086     ASN_TAG_NULL_E     = -145,  /* ASN tag error, not null */
00087     ASN_EXPECT_0_E     = -146,  /* ASN expect error, not zero */
00088     ASN_BITSTR_E       = -147,  /* ASN bit string error, wrong id */
00089     ASN_UNKNOWN_OID_E  = -148,  /* ASN oid error, unknown sum id */
00090     ASN_DATE_SZ_E      = -149,  /* ASN date error, bad size */
00091     ASN_BEFORE_DATE_E  = -150,  /* ASN date error, current date before */
00092     ASN_AFTER_DATE_E   = -151,  /* ASN date error, current date after */
00093     ASN_SIG_OID_E      = -152,  /* ASN signature error, mismatched oid */
00094     ASN_TIME_E         = -153,  /* ASN time error, unknown time type */
00095     ASN_INPUT_E        = -154,  /* ASN input error, not enough data */
00096     ASN_SIG_CONFIRM_E  = -155,  /* ASN sig error, confirm failure */
00097     ASN_SIG_HASH_E     = -156,  /* ASN sig error, unsupported hash type */
00098     ASN_SIG_KEY_E      = -157,  /* ASN sig error, unsupported key type */
00099     ASN_DH_KEY_E       = -158,  /* ASN key init error, invalid input */
00100     ASN_NTRU_KEY_E     = -159,  /* ASN ntru key decode error, invalid input */
00101     ASN_CRIT_EXT_E     = -160,  /* ASN unsupported critical extension */
00102     ASN_ALT_NAME_E     = -161,  /* ASN alternate name error */
00103     ASN_NO_PEM_HEADER  = -162,  /* ASN no PEM header found */
00104 
00105     ECC_BAD_ARG_E      = -170,  /* ECC input argument of wrong type */
00106     ASN_ECC_KEY_E      = -171,  /* ASN ECC bad input */
00107     ECC_CURVE_OID_E    = -172,  /* Unsupported ECC OID curve type */
00108     BAD_FUNC_ARG       = -173,  /* Bad function argument provided */
00109     NOT_COMPILED_IN    = -174,  /* Feature not compiled in */
00110     UNICODE_SIZE_E     = -175,  /* Unicode password too big */
00111     NO_PASSWORD        = -176,  /* no password provided by user */
00112     ALT_NAME_E         = -177,  /* alt name size problem, too big */
00113     BAD_OCSP_RESPONDER = -178,  /* missing key usage extensions */
00114 
00115     AES_GCM_AUTH_E     = -180,  /* AES-GCM Authentication check failure */
00116     AES_CCM_AUTH_E     = -181,  /* AES-CCM Authentication check failure */
00117 
00118     ASYNC_INIT_E       = -182,  /* Async Init type error */
00119 
00120     COMPRESS_INIT_E    = -183,  /* Compress init error */
00121     COMPRESS_E         = -184,  /* Compress error */
00122     DECOMPRESS_INIT_E  = -185,  /* DeCompress init error */
00123     DECOMPRESS_E       = -186,  /* DeCompress error */
00124 
00125     BAD_ALIGN_E         = -187,  /* Bad alignment for operation, no alloc */
00126     ASN_NO_SIGNER_E     = -188,  /* ASN no signer to confirm failure */
00127     ASN_CRL_CONFIRM_E   = -189,  /* ASN CRL signature confirm failure */
00128     ASN_CRL_NO_SIGNER_E = -190,  /* ASN CRL no signer to confirm failure */
00129     ASN_OCSP_CONFIRM_E  = -191,  /* ASN OCSP signature confirm failure */
00130 
00131     BAD_STATE_E         = -192,  /* Bad state operation */
00132     BAD_PADDING_E       = -193,  /* Bad padding, msg not correct length  */
00133 
00134     REQ_ATTRIBUTE_E     = -194,  /* setting cert request attributes error */
00135 
00136     PKCS7_OID_E         = -195,  /* PKCS#7, mismatched OID error */
00137     PKCS7_RECIP_E       = -196,  /* PKCS#7, recipient error */
00138     FIPS_NOT_ALLOWED_E  = -197,  /* FIPS not allowed error */
00139     ASN_NAME_INVALID_E  = -198,  /* ASN name constraint error */
00140 
00141     RNG_FAILURE_E       = -199,  /* RNG Failed, Reinitialize */
00142     HMAC_MIN_KEYLEN_E   = -200,  /* FIPS Mode HMAC Minimum Key Length error */
00143     RSA_PAD_E           = -201,  /* RSA Padding Error */
00144     LENGTH_ONLY_E       = -202,  /* Returning output length only */
00145 
00146     IN_CORE_FIPS_E      = -203,  /* In Core Integrity check failure */
00147     AES_KAT_FIPS_E      = -204,  /* AES KAT failure */
00148     DES3_KAT_FIPS_E     = -205,  /* DES3 KAT failure */
00149     HMAC_KAT_FIPS_E     = -206,  /* HMAC KAT failure */
00150     RSA_KAT_FIPS_E      = -207,  /* RSA KAT failure */
00151     DRBG_KAT_FIPS_E     = -208,  /* HASH DRBG KAT failure */
00152     DRBG_CONT_FIPS_E    = -209,  /* HASH DRBG Continuous test failure */
00153     AESGCM_KAT_FIPS_E   = -210,  /* AESGCM KAT failure */
00154     THREAD_STORE_KEY_E  = -211,  /* Thread local storage key create failure */
00155     THREAD_STORE_SET_E  = -212,  /* Thread local storage key set failure */
00156 
00157     MAC_CMP_FAILED_E    = -213,  /* MAC comparison failed */
00158     IS_POINT_E          = -214,  /* ECC is point on curve failed */
00159     ECC_INF_E           = -215,  /* ECC point infinity error */
00160     ECC_PRIV_KEY_E      = -216,  /* ECC private key not valid error */
00161     ECC_OUT_OF_RANGE_E  = -217,  /* ECC key component out of range */
00162 
00163     SRP_CALL_ORDER_E    = -218,  /* SRP function called in the wrong order. */
00164     SRP_VERIFY_E        = -219,  /* SRP proof verification failed. */
00165     SRP_BAD_KEY_E       = -220,  /* SRP bad ephemeral values. */
00166 
00167     ASN_NO_SKID         = -221,  /* ASN no Subject Key Identifier found */
00168     ASN_NO_AKID         = -222,  /* ASN no Authority Key Identifier found */
00169     ASN_NO_KEYUSAGE     = -223,  /* ASN no Key Usage found */
00170     SKID_E              = -224,  /* setting Subject Key Identifier error */
00171     AKID_E              = -225,  /* setting Authority Key Identifier error */
00172     KEYUSAGE_E          = -226,  /* Bad Key Usage value */
00173     CERTPOLICIES_E      = -227,  /* setting Certificate Policies error */
00174 
00175     WC_INIT_E           = -228,  /* wolfcrypt failed to initialize */
00176     SIG_VERIFY_E        = -229,  /* wolfcrypt signature verify error */
00177     BAD_COND_E          = -230,  /* Bad condition variable operation */
00178     SIG_TYPE_E          = -231,  /* Signature Type not enabled/available */
00179     HASH_TYPE_E         = -232,  /* Hash Type not enabled/available */
00180 
00181     WC_KEY_SIZE_E       = -234,  /* Key size error, either too small or large */
00182     ASN_COUNTRY_SIZE_E  = -235,  /* ASN Cert Gen, invalid country code size */
00183     MISSING_RNG_E       = -236,  /* RNG required but not provided */
00184     ASN_PATHLEN_SIZE_E  = -237,  /* ASN CA path length too large error */
00185     ASN_PATHLEN_INV_E   = -238,  /* ASN CA path length inversion error */
00186 
00187     BAD_KEYWRAP_ALG_E   = -239,
00188     BAD_KEYWRAP_IV_E    = -240,  /* Decrypted AES key wrap IV incorrect */
00189     WC_CLEANUP_E        = -241,  /* wolfcrypt cleanup failed */
00190     ECC_CDH_KAT_FIPS_E  = -242,  /* ECC CDH Known Answer Test failure */
00191     DH_CHECK_PUB_E      = -243,  /* DH Check Pub Key error */
00192     BAD_PATH_ERROR      = -244,  /* Bad path for opendir */
00193 
00194     ASYNC_OP_E          = -245,  /* Async operation error */
00195 
00196     ECC_PRIVATEONLY_E   = -246,  /* Invalid use of private only ECC key*/
00197     EXTKEYUSAGE_E       = -247,  /* Bad Extended Key Usage value */
00198     WC_HW_E             = -248,  /* Error with hardware crypto use */
00199     WC_HW_WAIT_E        = -249,  /* Hardware waiting on resource */
00200 
00201     PSS_SALTLEN_E       = -250,  /* PSS length of salt is to long for hash */
00202     PRIME_GEN_E         = -251,  /* Failure finding a prime. */
00203     BER_INDEF_E         = -252,  /* Cannot decode indefinite length BER. */
00204     RSA_OUT_OF_RANGE_E  = -253,  /* Ciphertext to decrypt out of range. */
00205     RSAPSS_PAT_FIPS_E   = -254,  /* RSA-PSS PAT failure */
00206     ECDSA_PAT_FIPS_E    = -255,  /* ECDSA PAT failure */
00207     DH_KAT_FIPS_E       = -256,  /* DH KAT failure */
00208     AESCCM_KAT_FIPS_E   = -257,  /* AESCCM KAT failure */
00209     SHA3_KAT_FIPS_E     = -258,  /* SHA-3 KAT failure */
00210     ECDHE_KAT_FIPS_E    = -259,  /* ECDHE KAT failure */
00211     AES_GCM_OVERFLOW_E  = -260,  /* AES-GCM invocation counter overflow. */
00212     AES_CCM_OVERFLOW_E  = -261,  /* AES-CCM invocation counter overflow. */
00213     RSA_KEY_PAIR_E      = -262,  /* RSA Key Pair-Wise Consistency check fail. */
00214     DH_CHECK_PRIV_E     = -263,  /* DH Check Priv Key error */
00215 
00216     WC_LAST_E           = -263,  /* Update this to indicate last error */
00217     MIN_CODE_E          = -300   /* errors -101 - -299 */
00218 
00219     /* add new companion error id strings for any new error codes
00220        wolfcrypt/src/error.c !!! */
00221 };
00222 
00223 
00224 #ifdef NO_ERROR_STRINGS
00225     #define wc_GetErrorString(error) "no support for error strings built in"
00226     #define wc_ErrorString(err, buf) \
00227         (void)err; XSTRNCPY((buf), wc_GetErrorString((err)), \
00228         WOLFSSL_MAX_ERROR_SZ);
00229 
00230 #else
00231 WOLFSSL_API void wc_ErrorString(int err, char* buff);
00232 WOLFSSL_API const char* wc_GetErrorString(int error);
00233 #endif
00234 
00235 #ifdef __cplusplus
00236     } /* extern "C" */
00237 #endif
00238 #endif /* WOLF_CRYPT_ERROR_H */
00239