Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
error.c
00001 /* error.c 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 #ifdef HAVE_CONFIG_H 00024 #include <config.h> 00025 #endif 00026 00027 #include <wolfcrypt/settings.h> 00028 00029 #include <wolfcrypt/error-crypt.h> 00030 00031 #ifdef _MSC_VER 00032 /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ 00033 #pragma warning(disable: 4996) 00034 #endif 00035 00036 #ifndef NO_ERROR_STRINGS 00037 const char* wc_GetErrorString(int error) 00038 { 00039 switch (error) { 00040 00041 case OPEN_RAN_E : 00042 return "opening random device error"; 00043 00044 case READ_RAN_E : 00045 return "reading random device error"; 00046 00047 case WINCRYPT_E : 00048 return "windows crypt init error"; 00049 00050 case CRYPTGEN_E : 00051 return "windows crypt generation error"; 00052 00053 case RAN_BLOCK_E : 00054 return "random device read would block error"; 00055 00056 case BAD_MUTEX_E : 00057 return "Bad mutex, operation failed"; 00058 00059 case WC_TIMEOUT_E: 00060 return "Timeout error"; 00061 00062 case WC_PENDING_E: 00063 return "wolfCrypt Operation Pending (would block / eagain) error"; 00064 00065 case WC_NOT_PENDING_E: 00066 return "wolfCrypt operation not pending error"; 00067 00068 case MP_INIT_E : 00069 return "mp_init error state"; 00070 00071 case MP_READ_E : 00072 return "mp_read error state"; 00073 00074 case MP_EXPTMOD_E : 00075 return "mp_exptmod error state"; 00076 00077 case MP_TO_E : 00078 return "mp_to_xxx error state, can't convert"; 00079 00080 case MP_SUB_E : 00081 return "mp_sub error state, can't subtract"; 00082 00083 case MP_ADD_E : 00084 return "mp_add error state, can't add"; 00085 00086 case MP_MUL_E : 00087 return "mp_mul error state, can't multiply"; 00088 00089 case MP_MULMOD_E : 00090 return "mp_mulmod error state, can't multiply mod"; 00091 00092 case MP_MOD_E : 00093 return "mp_mod error state, can't mod"; 00094 00095 case MP_INVMOD_E : 00096 return "mp_invmod error state, can't inv mod"; 00097 00098 case MP_CMP_E : 00099 return "mp_cmp error state"; 00100 00101 case MP_ZERO_E : 00102 return "mp zero result, not expected"; 00103 00104 case MEMORY_E : 00105 return "out of memory error"; 00106 00107 case VAR_STATE_CHANGE_E : 00108 return "Variable state modified by different thread"; 00109 00110 case RSA_WRONG_TYPE_E : 00111 return "RSA wrong block type for RSA function"; 00112 00113 case RSA_BUFFER_E : 00114 return "RSA buffer error, output too small or input too big"; 00115 00116 case BUFFER_E : 00117 return "Buffer error, output too small or input too big"; 00118 00119 case ALGO_ID_E : 00120 return "Setting Cert AlgoID error"; 00121 00122 case PUBLIC_KEY_E : 00123 return "Setting Cert Public Key error"; 00124 00125 case DATE_E : 00126 return "Setting Cert Date validity error"; 00127 00128 case SUBJECT_E : 00129 return "Setting Cert Subject name error"; 00130 00131 case ISSUER_E : 00132 return "Setting Cert Issuer name error"; 00133 00134 case CA_TRUE_E : 00135 return "Setting basic constraint CA true error"; 00136 00137 case EXTENSIONS_E : 00138 return "Setting extensions error"; 00139 00140 case ASN_PARSE_E : 00141 return "ASN parsing error, invalid input"; 00142 00143 case ASN_VERSION_E : 00144 return "ASN version error, invalid number"; 00145 00146 case ASN_GETINT_E : 00147 return "ASN get big int error, invalid data"; 00148 00149 case ASN_RSA_KEY_E : 00150 return "ASN key init error, invalid input"; 00151 00152 case ASN_OBJECT_ID_E : 00153 return "ASN object id error, invalid id"; 00154 00155 case ASN_TAG_NULL_E : 00156 return "ASN tag error, not null"; 00157 00158 case ASN_EXPECT_0_E : 00159 return "ASN expect error, not zero"; 00160 00161 case ASN_BITSTR_E : 00162 return "ASN bit string error, wrong id"; 00163 00164 case ASN_UNKNOWN_OID_E : 00165 return "ASN oid error, unknown sum id"; 00166 00167 case ASN_DATE_SZ_E : 00168 return "ASN date error, bad size"; 00169 00170 case ASN_BEFORE_DATE_E : 00171 return "ASN date error, current date before"; 00172 00173 case ASN_AFTER_DATE_E : 00174 return "ASN date error, current date after"; 00175 00176 case ASN_SIG_OID_E : 00177 return "ASN signature error, mismatched oid"; 00178 00179 case ASN_TIME_E : 00180 return "ASN time error, unknown time type"; 00181 00182 case ASN_INPUT_E : 00183 return "ASN input error, not enough data"; 00184 00185 case ASN_SIG_CONFIRM_E : 00186 return "ASN sig error, confirm failure"; 00187 00188 case ASN_SIG_HASH_E : 00189 return "ASN sig error, unsupported hash type"; 00190 00191 case ASN_SIG_KEY_E : 00192 return "ASN sig error, unsupported key type"; 00193 00194 case ASN_DH_KEY_E : 00195 return "ASN key init error, invalid input"; 00196 00197 case ASN_NTRU_KEY_E : 00198 return "ASN NTRU key decode error, invalid input"; 00199 00200 case ASN_CRIT_EXT_E: 00201 return "X.509 Critical extension ignored or invalid"; 00202 00203 case ASN_ALT_NAME_E: 00204 return "ASN alternate name error"; 00205 00206 case ECC_BAD_ARG_E : 00207 return "ECC input argument wrong type, invalid input"; 00208 00209 case ASN_ECC_KEY_E : 00210 return "ECC ASN1 bad key data, invalid input"; 00211 00212 case ECC_CURVE_OID_E : 00213 return "ECC curve sum OID unsupported, invalid input"; 00214 00215 case BAD_FUNC_ARG : 00216 return "Bad function argument"; 00217 00218 case NOT_COMPILED_IN : 00219 return "Feature not compiled in"; 00220 00221 case UNICODE_SIZE_E : 00222 return "Unicode password too big"; 00223 00224 case NO_PASSWORD : 00225 return "No password provided by user"; 00226 00227 case ALT_NAME_E : 00228 return "Alt Name problem, too big"; 00229 00230 case AES_GCM_AUTH_E: 00231 return "AES-GCM Authentication check fail"; 00232 00233 case AES_CCM_AUTH_E: 00234 return "AES-CCM Authentication check fail"; 00235 00236 case ASYNC_INIT_E: 00237 return "Async Init error"; 00238 00239 case COMPRESS_INIT_E: 00240 return "Compress Init error"; 00241 00242 case COMPRESS_E: 00243 return "Compress error"; 00244 00245 case DECOMPRESS_INIT_E: 00246 return "DeCompress Init error"; 00247 00248 case DECOMPRESS_E: 00249 return "DeCompress error"; 00250 00251 case BAD_ALIGN_E: 00252 return "Bad alignment error, no alloc help"; 00253 00254 case ASN_NO_SIGNER_E : 00255 return "ASN no signer error to confirm failure"; 00256 00257 case ASN_CRL_CONFIRM_E : 00258 return "ASN CRL sig error, confirm failure"; 00259 00260 case ASN_CRL_NO_SIGNER_E : 00261 return "ASN CRL no signer error to confirm failure"; 00262 00263 case ASN_OCSP_CONFIRM_E : 00264 return "ASN OCSP sig error, confirm failure"; 00265 00266 case ASN_NO_PEM_HEADER: 00267 return "ASN no PEM Header Error"; 00268 00269 case BAD_STATE_E: 00270 return "Bad state operation"; 00271 00272 case BAD_PADDING_E: 00273 return "Bad padding, message wrong length"; 00274 00275 case REQ_ATTRIBUTE_E: 00276 return "Setting cert request attributes error"; 00277 00278 case PKCS7_OID_E: 00279 return "PKCS#7 error: mismatched OID value"; 00280 00281 case PKCS7_RECIP_E: 00282 return "PKCS#7 error: no matching recipient found"; 00283 00284 case FIPS_NOT_ALLOWED_E: 00285 return "FIPS mode not allowed error"; 00286 00287 case ASN_NAME_INVALID_E: 00288 return "Name Constraint error"; 00289 00290 case RNG_FAILURE_E: 00291 return "Random Number Generator failed"; 00292 00293 case HMAC_MIN_KEYLEN_E: 00294 return "FIPS Mode HMAC Minimum Key Length error"; 00295 00296 case RSA_PAD_E: 00297 return "Rsa Padding error"; 00298 00299 case LENGTH_ONLY_E: 00300 return "Output length only set, not for other use error"; 00301 00302 case IN_CORE_FIPS_E: 00303 return "In Core Integrity check FIPS error"; 00304 00305 case AES_KAT_FIPS_E: 00306 return "AES Known Answer Test check FIPS error"; 00307 00308 case DES3_KAT_FIPS_E: 00309 return "DES3 Known Answer Test check FIPS error"; 00310 00311 case HMAC_KAT_FIPS_E: 00312 return "HMAC Known Answer Test check FIPS error"; 00313 00314 case RSA_KAT_FIPS_E: 00315 return "RSA Known Answer Test check FIPS error"; 00316 00317 case DRBG_KAT_FIPS_E: 00318 return "DRBG Known Answer Test check FIPS error"; 00319 00320 case DRBG_CONT_FIPS_E: 00321 return "DRBG Continuous Test FIPS error"; 00322 00323 case AESGCM_KAT_FIPS_E: 00324 return "AESGCM Known Answer Test check FIPS error"; 00325 00326 case THREAD_STORE_KEY_E: 00327 return "Thread Storage Key Create error"; 00328 00329 case THREAD_STORE_SET_E: 00330 return "Thread Storage Set error"; 00331 00332 case MAC_CMP_FAILED_E: 00333 return "MAC comparison failed"; 00334 00335 case IS_POINT_E: 00336 return "ECC is point on curve failed"; 00337 00338 case ECC_INF_E: 00339 return " ECC point at infinity error"; 00340 00341 case ECC_OUT_OF_RANGE_E: 00342 return " ECC Qx or Qy out of range error"; 00343 00344 case ECC_PRIV_KEY_E: 00345 return " ECC private key is not valid error"; 00346 00347 case SRP_CALL_ORDER_E: 00348 return "SRP function called in the wrong order error"; 00349 00350 case SRP_VERIFY_E: 00351 return "SRP proof verification error"; 00352 00353 case SRP_BAD_KEY_E: 00354 return "SRP bad key values error"; 00355 00356 case ASN_NO_SKID: 00357 return "ASN no Subject Key Identifier found error"; 00358 00359 case ASN_NO_AKID: 00360 return "ASN no Authority Key Identifier found error"; 00361 00362 case ASN_NO_KEYUSAGE: 00363 return "ASN no Key Usage found error"; 00364 00365 case SKID_E: 00366 return "Setting Subject Key Identifier error"; 00367 00368 case AKID_E: 00369 return "Setting Authority Key Identifier error"; 00370 00371 case KEYUSAGE_E: 00372 return "Key Usage value error"; 00373 00374 case EXTKEYUSAGE_E: 00375 return "Extended Key Usage value error"; 00376 00377 case CERTPOLICIES_E: 00378 return "Setting Certificate Policies error"; 00379 00380 case WC_INIT_E: 00381 return "wolfCrypt Initialize Failure error"; 00382 00383 case SIG_VERIFY_E: 00384 return "Signature verify error"; 00385 00386 case BAD_COND_E: 00387 return "Bad condition variable operation error"; 00388 00389 case SIG_TYPE_E: 00390 return "Signature type not enabled/available"; 00391 00392 case HASH_TYPE_E: 00393 return "Hash type not enabled/available"; 00394 00395 case WC_KEY_SIZE_E: 00396 return "Key size error, either too small or large"; 00397 00398 case ASN_COUNTRY_SIZE_E: 00399 return "Country code size error, either too small or large"; 00400 00401 case MISSING_RNG_E: 00402 return "RNG required but not provided"; 00403 00404 case ASN_PATHLEN_SIZE_E: 00405 return "ASN CA path length value too large error"; 00406 00407 case ASN_PATHLEN_INV_E: 00408 return "ASN CA path length larger than signer error"; 00409 00410 case BAD_KEYWRAP_ALG_E: 00411 return "Unsupported key wrap algorithm error"; 00412 00413 case BAD_KEYWRAP_IV_E: 00414 return "Decrypted AES key wrap IV does not match expected"; 00415 00416 case WC_CLEANUP_E: 00417 return "wolfcrypt cleanup failed"; 00418 00419 case ECC_CDH_KAT_FIPS_E: 00420 return "wolfcrypt FIPS ECC CDH Known Answer Test Failure"; 00421 00422 case DH_CHECK_PUB_E: 00423 return "DH Check Public Key failure"; 00424 00425 case BAD_PATH_ERROR: 00426 return "Bad path for opendir error"; 00427 00428 case ASYNC_OP_E: 00429 return "Async operation error"; 00430 00431 case BAD_OCSP_RESPONDER: 00432 return "Invalid OCSP Responder, missing specific key usage extensions"; 00433 00434 case ECC_PRIVATEONLY_E: 00435 return "Invalid use of private only ECC key"; 00436 00437 case WC_HW_E: 00438 return "Error with hardware crypto use"; 00439 00440 case WC_HW_WAIT_E: 00441 return "Hardware waiting on resource"; 00442 00443 case PSS_SALTLEN_E: 00444 return "PSS - Length of salt is too big for hash algorithm"; 00445 00446 case PRIME_GEN_E: 00447 return "Unable to find a prime for RSA key"; 00448 00449 case BER_INDEF_E: 00450 return "Unable to decode an indefinite length encoded message"; 00451 00452 case RSA_OUT_OF_RANGE_E: 00453 return "Ciphertext to decrypt is out of range"; 00454 00455 case RSAPSS_PAT_FIPS_E: 00456 return "wolfcrypt FIPS RSA-PSS Pairwise Agreement Test Failure"; 00457 00458 case ECDSA_PAT_FIPS_E: 00459 return "wolfcrypt FIPS ECDSA Pairwise Agreement Test Failure"; 00460 00461 case DH_KAT_FIPS_E: 00462 return "wolfcrypt FIPS DH Known Answer Test Failure"; 00463 00464 case AESCCM_KAT_FIPS_E: 00465 return "AESCCM Known Answer Test check FIPS error"; 00466 00467 case SHA3_KAT_FIPS_E: 00468 return "SHA-3 Known Answer Test check FIPS error"; 00469 00470 case ECDHE_KAT_FIPS_E: 00471 return "wolfcrypt FIPS ECDHE Known Answer Test Failure"; 00472 00473 case AES_GCM_OVERFLOW_E: 00474 return "AES-GCM invocation counter overflow"; 00475 00476 case AES_CCM_OVERFLOW_E: 00477 return "AES-CCM invocation counter overflow"; 00478 00479 case RSA_KEY_PAIR_E: 00480 return "RSA Key Pair-Wise Consistency check fail"; 00481 00482 case DH_CHECK_PRIV_E: 00483 return "DH Check Private Key failure"; 00484 00485 default: 00486 return "unknown error number"; 00487 00488 } 00489 } 00490 00491 void wc_ErrorString(int error, char* buffer) 00492 { 00493 XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ); 00494 } 00495 #endif /* !NO_ERROR_STRINGS */ 00496 00497
Generated on Tue Jul 12 2022 16:58:05 by
1.7.2