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.
Fork of wolfSSL by
error.c
00001 /* error.c 00002 * 00003 * Copyright (C) 2006-2016 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 <wolfssl/wolfcrypt/settings.h> 00028 00029 #include <wolfssl/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 const char* wc_GetErrorString(int error) 00037 { 00038 #ifdef NO_ERROR_STRINGS 00039 00040 (void)error; 00041 return "no support for error strings built in"; 00042 00043 #else 00044 00045 switch (error) { 00046 00047 case OPEN_RAN_E : 00048 return "opening random device error"; 00049 00050 case READ_RAN_E : 00051 return "reading random device error"; 00052 00053 case WINCRYPT_E : 00054 return "windows crypt init error"; 00055 00056 case CRYPTGEN_E : 00057 return "windows crypt generation error"; 00058 00059 case RAN_BLOCK_E : 00060 return "random device read would block error"; 00061 00062 case BAD_MUTEX_E : 00063 return "Bad mutex, operation failed"; 00064 00065 case WC_TIMEOUT_E: 00066 return "Timeout error"; 00067 00068 case WC_PENDING_E: 00069 return "wolfCrypt Operation Pending (would block / eagain) error"; 00070 00071 case WC_NOT_PENDING_E: 00072 return "wolfCrypt operation not pending error"; 00073 00074 case MP_INIT_E : 00075 return "mp_init error state"; 00076 00077 case MP_READ_E : 00078 return "mp_read error state"; 00079 00080 case MP_EXPTMOD_E : 00081 return "mp_exptmod error state"; 00082 00083 case MP_TO_E : 00084 return "mp_to_xxx error state, can't convert"; 00085 00086 case MP_SUB_E : 00087 return "mp_sub error state, can't subtract"; 00088 00089 case MP_ADD_E : 00090 return "mp_add error state, can't add"; 00091 00092 case MP_MUL_E : 00093 return "mp_mul error state, can't multiply"; 00094 00095 case MP_MULMOD_E : 00096 return "mp_mulmod error state, can't multiply mod"; 00097 00098 case MP_MOD_E : 00099 return "mp_mod error state, can't mod"; 00100 00101 case MP_INVMOD_E : 00102 return "mp_invmod error state, can't inv mod"; 00103 00104 case MP_CMP_E : 00105 return "mp_cmp error state"; 00106 00107 case MP_ZERO_E : 00108 return "mp zero result, not expected"; 00109 00110 case MEMORY_E : 00111 return "out of memory error"; 00112 00113 case VAR_STATE_CHANGE_E : 00114 return "Variable state modified by different thread"; 00115 00116 case RSA_WRONG_TYPE_E : 00117 return "RSA wrong block type for RSA function"; 00118 00119 case RSA_BUFFER_E : 00120 return "RSA buffer error, output too small or input too big"; 00121 00122 case BUFFER_E : 00123 return "Buffer error, output too small or input too big"; 00124 00125 case ALGO_ID_E : 00126 return "Setting Cert AlgoID error"; 00127 00128 case PUBLIC_KEY_E : 00129 return "Setting Cert Public Key error"; 00130 00131 case DATE_E : 00132 return "Setting Cert Date validity error"; 00133 00134 case SUBJECT_E : 00135 return "Setting Cert Subject name error"; 00136 00137 case ISSUER_E : 00138 return "Setting Cert Issuer name error"; 00139 00140 case CA_TRUE_E : 00141 return "Setting basic constraint CA true error"; 00142 00143 case EXTENSIONS_E : 00144 return "Setting extensions error"; 00145 00146 case ASN_PARSE_E : 00147 return "ASN parsing error, invalid input"; 00148 00149 case ASN_VERSION_E : 00150 return "ASN version error, invalid number"; 00151 00152 case ASN_GETINT_E : 00153 return "ASN get big int error, invalid data"; 00154 00155 case ASN_RSA_KEY_E : 00156 return "ASN key init error, invalid input"; 00157 00158 case ASN_OBJECT_ID_E : 00159 return "ASN object id error, invalid id"; 00160 00161 case ASN_TAG_NULL_E : 00162 return "ASN tag error, not null"; 00163 00164 case ASN_EXPECT_0_E : 00165 return "ASN expect error, not zero"; 00166 00167 case ASN_BITSTR_E : 00168 return "ASN bit string error, wrong id"; 00169 00170 case ASN_UNKNOWN_OID_E : 00171 return "ASN oid error, unknown sum id"; 00172 00173 case ASN_DATE_SZ_E : 00174 return "ASN date error, bad size"; 00175 00176 case ASN_BEFORE_DATE_E : 00177 return "ASN date error, current date before"; 00178 00179 case ASN_AFTER_DATE_E : 00180 return "ASN date error, current date after"; 00181 00182 case ASN_SIG_OID_E : 00183 return "ASN signature error, mismatched oid"; 00184 00185 case ASN_TIME_E : 00186 return "ASN time error, unknown time type"; 00187 00188 case ASN_INPUT_E : 00189 return "ASN input error, not enough data"; 00190 00191 case ASN_SIG_CONFIRM_E : 00192 return "ASN sig error, confirm failure"; 00193 00194 case ASN_SIG_HASH_E : 00195 return "ASN sig error, unsupported hash type"; 00196 00197 case ASN_SIG_KEY_E : 00198 return "ASN sig error, unsupported key type"; 00199 00200 case ASN_DH_KEY_E : 00201 return "ASN key init error, invalid input"; 00202 00203 case ASN_NTRU_KEY_E : 00204 return "ASN NTRU key decode error, invalid input"; 00205 00206 case ASN_CRIT_EXT_E: 00207 return "X.509 Critical extension ignored or invalid"; 00208 00209 case ECC_BAD_ARG_E : 00210 return "ECC input argument wrong type, invalid input"; 00211 00212 case ASN_ECC_KEY_E : 00213 return "ECC ASN1 bad key data, invalid input"; 00214 00215 case ECC_CURVE_OID_E : 00216 return "ECC curve sum OID unsupported, invalid input"; 00217 00218 case BAD_FUNC_ARG : 00219 return "Bad function argument"; 00220 00221 case NOT_COMPILED_IN : 00222 return "Feature not compiled in"; 00223 00224 case UNICODE_SIZE_E : 00225 return "Unicode password too big"; 00226 00227 case NO_PASSWORD : 00228 return "No password provided by user"; 00229 00230 case ALT_NAME_E : 00231 return "Alt Name problem, too big"; 00232 00233 case AES_GCM_AUTH_E: 00234 return "AES-GCM Authentication check fail"; 00235 00236 case AES_CCM_AUTH_E: 00237 return "AES-CCM Authentication check fail"; 00238 00239 case ASYNC_INIT_E: 00240 return "Async Init error"; 00241 00242 case COMPRESS_INIT_E: 00243 return "Compress Init error"; 00244 00245 case COMPRESS_E: 00246 return "Compress error"; 00247 00248 case DECOMPRESS_INIT_E: 00249 return "DeCompress Init error"; 00250 00251 case DECOMPRESS_E: 00252 return "DeCompress error"; 00253 00254 case BAD_ALIGN_E: 00255 return "Bad alignment error, no alloc help"; 00256 00257 case ASN_NO_SIGNER_E : 00258 return "ASN no signer error to confirm failure"; 00259 00260 case ASN_CRL_CONFIRM_E : 00261 return "ASN CRL sig error, confirm failure"; 00262 00263 case ASN_CRL_NO_SIGNER_E : 00264 return "ASN CRL no signer error to confirm failure"; 00265 00266 case ASN_OCSP_CONFIRM_E : 00267 return "ASN OCSP sig error, confirm failure"; 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 "Bad Key Usage value error"; 00373 00374 case CERTPOLICIES_E: 00375 return "Setting Certificate Policies error"; 00376 00377 case WC_INIT_E: 00378 return "wolfCrypt Initialize Failure error"; 00379 00380 case SIG_VERIFY_E: 00381 return "Signature verify error"; 00382 00383 case BAD_COND_E: 00384 return "Bad condition variable operation error"; 00385 00386 case SIG_TYPE_E: 00387 return "Signature type not enabled/available"; 00388 00389 case HASH_TYPE_E: 00390 return "Hash type not enabled/available"; 00391 00392 case WC_KEY_SIZE_E: 00393 return "Key size error, either too small or large"; 00394 00395 case ASN_COUNTRY_SIZE_E: 00396 return "Country code size error, either too small or large"; 00397 00398 case MISSING_RNG_E: 00399 return "RNG required but not provided"; 00400 00401 case ASN_PATHLEN_SIZE_E: 00402 return "ASN CA path length value too large error"; 00403 00404 case ASN_PATHLEN_INV_E: 00405 return "ASN CA path length larger than signer error"; 00406 00407 case BAD_KEYWRAP_ALG_E: 00408 return "Unsupported key wrap algorithm error"; 00409 00410 case BAD_KEYWRAP_IV_E: 00411 return "Decrypted AES key wrap IV does not match expected"; 00412 00413 case WC_CLEANUP_E: 00414 return "wolfcrypt cleanup failed"; 00415 00416 case ECC_CDH_KAT_FIPS_E: 00417 return "wolfcrypt FIPS ECC CDH Known Answer Test Failure"; 00418 00419 case DH_CHECK_PUB_E: 00420 return "DH Check Public Key failure"; 00421 00422 case BAD_PATH_ERROR: 00423 return "Bad path for opendir error"; 00424 00425 case ASYNC_OP_E: 00426 return "Async operation error"; 00427 00428 default: 00429 return "unknown error number"; 00430 00431 } 00432 00433 #endif /* NO_ERROR_STRINGS */ 00434 00435 } 00436 00437 void wc_ErrorString(int error, char* buffer) 00438 { 00439 XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ); 00440 } 00441
Generated on Tue Jul 12 2022 23:30:55 by
 1.7.2 
    