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.
Dependents: HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL
crypt_error.c
00001 /* error.c 00002 * 00003 * Copyright (C) 2006-2014 wolfSSL Inc. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL 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 * CyaSSL 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-1301, USA 00020 */ 00021 00022 #ifdef HAVE_CONFIG_H 00023 #include <config.h> 00024 #endif 00025 00026 #include <cyassl/ctaocrypt/settings.h> 00027 00028 #include <cyassl/ctaocrypt/error-crypt.h> 00029 00030 #ifdef _MSC_VER 00031 /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ 00032 #pragma warning(disable: 4996) 00033 #endif 00034 00035 const char* CTaoCryptGetErrorString(int error) 00036 { 00037 #ifdef NO_ERROR_STRINGS 00038 00039 (void)error; 00040 return "no support for error strings built in"; 00041 00042 #else 00043 00044 switch (error) { 00045 00046 case OPEN_RAN_E : 00047 return "opening random device error"; 00048 00049 case READ_RAN_E : 00050 return "reading random device error"; 00051 00052 case WINCRYPT_E : 00053 return "windows crypt init error"; 00054 00055 case CRYPTGEN_E : 00056 return "windows crypt generation error"; 00057 00058 case RAN_BLOCK_E : 00059 return "random device read would block error"; 00060 00061 case BAD_MUTEX_E : 00062 return "Bad mutex, operation failed"; 00063 00064 case MP_INIT_E : 00065 return "mp_init error state"; 00066 00067 case MP_READ_E : 00068 return "mp_read error state"; 00069 00070 case MP_EXPTMOD_E : 00071 return "mp_exptmod error state"; 00072 00073 case MP_TO_E : 00074 return "mp_to_xxx error state, can't convert"; 00075 00076 case MP_SUB_E : 00077 return "mp_sub error state, can't subtract"; 00078 00079 case MP_ADD_E : 00080 return "mp_add error state, can't add"; 00081 00082 case MP_MUL_E : 00083 return "mp_mul error state, can't multiply"; 00084 00085 case MP_MULMOD_E : 00086 return "mp_mulmod error state, can't multiply mod"; 00087 00088 case MP_MOD_E : 00089 return "mp_mod error state, can't mod"; 00090 00091 case MP_INVMOD_E : 00092 return "mp_invmod error state, can't inv mod"; 00093 00094 case MP_CMP_E : 00095 return "mp_cmp error state"; 00096 00097 case MP_ZERO_E : 00098 return "mp zero result, not expected"; 00099 00100 case MEMORY_E : 00101 return "out of memory error"; 00102 00103 case RSA_WRONG_TYPE_E : 00104 return "RSA wrong block type for RSA function"; 00105 00106 case RSA_BUFFER_E : 00107 return "RSA buffer error, output too small or input too big"; 00108 00109 case BUFFER_E : 00110 return "Buffer error, output too small or input too big"; 00111 00112 case ALGO_ID_E : 00113 return "Setting Cert AlogID error"; 00114 00115 case PUBLIC_KEY_E : 00116 return "Setting Cert Public Key error"; 00117 00118 case DATE_E : 00119 return "Setting Cert Date validity error"; 00120 00121 case SUBJECT_E : 00122 return "Setting Cert Subject name error"; 00123 00124 case ISSUER_E : 00125 return "Setting Cert Issuer name error"; 00126 00127 case CA_TRUE_E : 00128 return "Setting basic constraint CA true error"; 00129 00130 case EXTENSIONS_E : 00131 return "Setting extensions error"; 00132 00133 case ASN_PARSE_E : 00134 return "ASN parsing error, invalid input"; 00135 00136 case ASN_VERSION_E : 00137 return "ASN version error, invalid number"; 00138 00139 case ASN_GETINT_E : 00140 return "ASN get big int error, invalid data"; 00141 00142 case ASN_RSA_KEY_E : 00143 return "ASN key init error, invalid input"; 00144 00145 case ASN_OBJECT_ID_E : 00146 return "ASN object id error, invalid id"; 00147 00148 case ASN_TAG_NULL_E : 00149 return "ASN tag error, not null"; 00150 00151 case ASN_EXPECT_0_E : 00152 return "ASN expect error, not zero"; 00153 00154 case ASN_BITSTR_E : 00155 return "ASN bit string error, wrong id"; 00156 00157 case ASN_UNKNOWN_OID_E : 00158 return "ASN oid error, unknown sum id"; 00159 00160 case ASN_DATE_SZ_E : 00161 return "ASN date error, bad size"; 00162 00163 case ASN_BEFORE_DATE_E : 00164 return "ASN date error, current date before"; 00165 00166 case ASN_AFTER_DATE_E : 00167 return "ASN date error, current date after"; 00168 00169 case ASN_SIG_OID_E : 00170 return "ASN signature error, mismatched oid"; 00171 00172 case ASN_TIME_E : 00173 return "ASN time error, unkown time type"; 00174 00175 case ASN_INPUT_E : 00176 return "ASN input error, not enough data"; 00177 00178 case ASN_SIG_CONFIRM_E : 00179 return "ASN sig error, confirm failure"; 00180 00181 case ASN_SIG_HASH_E : 00182 return "ASN sig error, unsupported hash type"; 00183 00184 case ASN_SIG_KEY_E : 00185 return "ASN sig error, unsupported key type"; 00186 00187 case ASN_DH_KEY_E : 00188 return "ASN key init error, invalid input"; 00189 00190 case ASN_NTRU_KEY_E : 00191 return "ASN NTRU key decode error, invalid input"; 00192 00193 case ASN_CRIT_EXT_E: 00194 return "X.509 Critical extension ignored"; 00195 00196 case ECC_BAD_ARG_E : 00197 return "ECC input argument wrong type, invalid input"; 00198 00199 case ASN_ECC_KEY_E : 00200 return "ECC ASN1 bad key data, invalid input"; 00201 00202 case ECC_CURVE_OID_E : 00203 return "ECC curve sum OID unsupported, invalid input"; 00204 00205 case BAD_FUNC_ARG : 00206 return "Bad function argument"; 00207 00208 case NOT_COMPILED_IN : 00209 return "Feature not compiled in"; 00210 00211 case UNICODE_SIZE_E : 00212 return "Unicode password too big"; 00213 00214 case NO_PASSWORD : 00215 return "No password provided by user"; 00216 00217 case ALT_NAME_E : 00218 return "Alt Name problem, too big"; 00219 00220 case AES_GCM_AUTH_E: 00221 return "AES-GCM Authentication check fail"; 00222 00223 case AES_CCM_AUTH_E: 00224 return "AES-CCM Authentication check fail"; 00225 00226 case CAVIUM_INIT_E: 00227 return "Cavium Init type error"; 00228 00229 case COMPRESS_INIT_E: 00230 return "Compress Init error"; 00231 00232 case COMPRESS_E: 00233 return "Compress error"; 00234 00235 case DECOMPRESS_INIT_E: 00236 return "DeCompress Init error"; 00237 00238 case DECOMPRESS_E: 00239 return "DeCompress error"; 00240 00241 case BAD_ALIGN_E: 00242 return "Bad alignment error, no alloc help"; 00243 00244 case ASN_NO_SIGNER_E : 00245 return "ASN no signer error to confirm failure"; 00246 00247 case ASN_CRL_CONFIRM_E : 00248 return "ASN CRL sig error, confirm failure"; 00249 00250 case ASN_CRL_NO_SIGNER_E : 00251 return "ASN CRL no signer error to confirm failure"; 00252 00253 case ASN_OCSP_CONFIRM_E : 00254 return "ASN OCSP sig error, confirm failure"; 00255 00256 case BAD_ENC_STATE_E: 00257 return "Bad ecc encrypt state operation"; 00258 00259 case BAD_PADDING_E: 00260 return "Bad padding, message wrong length"; 00261 00262 case REQ_ATTRIBUTE_E: 00263 return "Setting cert request attributes error"; 00264 00265 case PKCS7_OID_E: 00266 return "PKCS#7 error: mismatched OID value"; 00267 00268 case PKCS7_RECIP_E: 00269 return "PKCS#7 error: no matching recipient found"; 00270 00271 case FIPS_NOT_ALLOWED_E: 00272 return "FIPS mode not allowed error"; 00273 00274 case ASN_NAME_INVALID_E: 00275 return "Name Constraint error"; 00276 00277 case RNG_FAILURE_E: 00278 return "Random Number Generator failed"; 00279 00280 case HMAC_MIN_KEYLEN_E: 00281 return "FIPS Mode HMAC Minimum Key Length error"; 00282 00283 case RSA_PAD_E: 00284 return "Rsa Padding error"; 00285 00286 case LENGTH_ONLY_E: 00287 return "Output length only set, not for other use error"; 00288 00289 case IN_CORE_FIPS_E: 00290 return "In Core Integrity check FIPS error"; 00291 00292 case AES_KAT_FIPS_E: 00293 return "AES Known Answer Test check FIPS error"; 00294 00295 case DES3_KAT_FIPS_E: 00296 return "DES3 Known Answer Test check FIPS error"; 00297 00298 case HMAC_KAT_FIPS_E: 00299 return "HMAC Known Answer Test check FIPS error"; 00300 00301 case RSA_KAT_FIPS_E: 00302 return "RSA Known Answer Test check FIPS error"; 00303 00304 case DRBG_KAT_FIPS_E: 00305 return "DRBG Known Answer Test check FIPS error"; 00306 00307 case DRBG_CONT_FIPS_E: 00308 return "DRBG Continuous Test FIPS error"; 00309 00310 case AESGCM_KAT_FIPS_E: 00311 return "AESGCM Known Answer Test check FIPS error"; 00312 00313 default: 00314 return "unknown error number"; 00315 00316 } 00317 00318 #endif /* NO_ERROR_STRINGS */ 00319 00320 } 00321 00322 void CTaoCryptErrorString(int error, char* buffer) 00323 { 00324 XSTRNCPY(buffer, CTaoCryptGetErrorString(error), CYASSL_MAX_ERROR_SZ); 00325 }
Generated on Wed Jul 13 2022 02:33:55 by
1.7.2