mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
error.c
00001 /* 00002 * Error message information 00003 * 00004 * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved 00005 * 00006 * This file is part of mbed TLS (https://tls.mbed.org) 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 */ 00022 00023 #if !defined(POLARSSL_CONFIG_FILE) 00024 #include "polarssl/config.h" 00025 #else 00026 #include POLARSSL_CONFIG_FILE 00027 #endif 00028 00029 #if defined(POLARSSL_ERROR_C) || defined(POLARSSL_ERROR_STRERROR_DUMMY) 00030 #include "polarssl/error.h" 00031 #include <string.h> 00032 #endif 00033 00034 #if defined(POLARSSL_PLATFORM_C) 00035 #include "polarssl/platform.h" 00036 #else 00037 #define polarssl_snprintf snprintf 00038 #endif 00039 00040 #if defined(POLARSSL_ERROR_C) 00041 00042 #include <stdio.h> 00043 00044 #if defined(POLARSSL_AES_C) 00045 #include "polarssl/aes.h" 00046 #endif 00047 00048 #if defined(POLARSSL_BASE64_C) 00049 #include "polarssl/base64.h" 00050 #endif 00051 00052 #if defined(POLARSSL_BIGNUM_C) 00053 #include "polarssl/bignum.h" 00054 #endif 00055 00056 #if defined(POLARSSL_BLOWFISH_C) 00057 #include "polarssl/blowfish.h" 00058 #endif 00059 00060 #if defined(POLARSSL_CAMELLIA_C) 00061 #include "polarssl/camellia.h" 00062 #endif 00063 00064 #if defined(POLARSSL_CCM_C) 00065 #include "polarssl/ccm.h" 00066 #endif 00067 00068 #if defined(POLARSSL_CIPHER_C) 00069 #include "polarssl/cipher.h" 00070 #endif 00071 00072 #if defined(POLARSSL_CTR_DRBG_C) 00073 #include "polarssl/ctr_drbg.h" 00074 #endif 00075 00076 #if defined(POLARSSL_DES_C) 00077 #include "polarssl/des.h" 00078 #endif 00079 00080 #if defined(POLARSSL_DHM_C) 00081 #include "polarssl/dhm.h" 00082 #endif 00083 00084 #if defined(POLARSSL_ECP_C) 00085 #include "polarssl/ecp.h" 00086 #endif 00087 00088 #if defined(POLARSSL_ENTROPY_C) 00089 #include "polarssl/entropy.h" 00090 #endif 00091 00092 #if defined(POLARSSL_GCM_C) 00093 #include "polarssl/gcm.h" 00094 #endif 00095 00096 #if defined(POLARSSL_HMAC_DRBG_C) 00097 #include "polarssl/hmac_drbg.h" 00098 #endif 00099 00100 #if defined(POLARSSL_MD_C) 00101 #include "polarssl/md.h" 00102 #endif 00103 00104 #if defined(POLARSSL_MD2_C) 00105 #include "polarssl/md2.h" 00106 #endif 00107 00108 #if defined(POLARSSL_MD4_C) 00109 #include "polarssl/md4.h" 00110 #endif 00111 00112 #if defined(POLARSSL_MD5_C) 00113 #include "polarssl/md5.h" 00114 #endif 00115 00116 #if defined(POLARSSL_NET_C) 00117 #include "polarssl/net.h" 00118 #endif 00119 00120 #if defined(POLARSSL_OID_C) 00121 #include "polarssl/oid.h" 00122 #endif 00123 00124 #if defined(POLARSSL_PADLOCK_C) 00125 #include "polarssl/padlock.h" 00126 #endif 00127 00128 #if defined(POLARSSL_PBKDF2_C) 00129 #include "polarssl/pbkdf2.h" 00130 #endif 00131 00132 #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) 00133 #include "polarssl/pem.h" 00134 #endif 00135 00136 #if defined(POLARSSL_PK_C) 00137 #include "polarssl/pk.h" 00138 #endif 00139 00140 #if defined(POLARSSL_PKCS12_C) 00141 #include "polarssl/pkcs12.h" 00142 #endif 00143 00144 #if defined(POLARSSL_PKCS5_C) 00145 #include "polarssl/pkcs5.h" 00146 #endif 00147 00148 #if defined(POLARSSL_RIPEMD160_C) 00149 #include "polarssl/ripemd160.h" 00150 #endif 00151 00152 #if defined(POLARSSL_RSA_C) 00153 #include "polarssl/rsa.h" 00154 #endif 00155 00156 #if defined(POLARSSL_SHA1_C) 00157 #include "polarssl/sha1.h" 00158 #endif 00159 00160 #if defined(POLARSSL_SHA256_C) 00161 #include "polarssl/sha256.h" 00162 #endif 00163 00164 #if defined(POLARSSL_SHA512_C) 00165 #include "polarssl/sha512.h" 00166 #endif 00167 00168 #if defined(POLARSSL_SSL_TLS_C) 00169 #include "polarssl/ssl.h" 00170 #endif 00171 00172 #if defined(POLARSSL_THREADING_C) 00173 #include "polarssl/threading.h" 00174 #endif 00175 00176 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) 00177 #include "polarssl/x509.h" 00178 #endif 00179 00180 #if defined(POLARSSL_XTEA_C) 00181 #include "polarssl/xtea.h" 00182 #endif 00183 00184 #if defined(_MSC_VER) && !defined snprintf && !defined(EFIX64) && \ 00185 !defined(EFI32) 00186 #define snprintf _snprintf 00187 #endif 00188 00189 void polarssl_strerror( int ret, char *buf, size_t buflen ) 00190 { 00191 size_t len; 00192 int use_ret; 00193 00194 if( buflen == 0 ) 00195 return; 00196 00197 memset( buf, 0x00, buflen ); 00198 /* Reduce buflen to make sure MSVC _snprintf() ends with \0 as well */ 00199 buflen -= 1; 00200 00201 if( ret < 0 ) 00202 ret = -ret; 00203 00204 if( ret & 0xFF80 ) 00205 { 00206 use_ret = ret & 0xFF80; 00207 00208 // High level error codes 00209 // 00210 // BEGIN generated code 00211 #if defined(POLARSSL_CIPHER_C) 00212 if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) 00213 polarssl_snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); 00214 if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) 00215 polarssl_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); 00216 if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) 00217 polarssl_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); 00218 if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) 00219 polarssl_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); 00220 if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) 00221 polarssl_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); 00222 if( use_ret == -(POLARSSL_ERR_CIPHER_AUTH_FAILED) ) 00223 polarssl_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); 00224 #endif /* POLARSSL_CIPHER_C */ 00225 00226 #if defined(POLARSSL_DHM_C) 00227 if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) 00228 polarssl_snprintf( buf, buflen, "DHM - Bad input parameters to function" ); 00229 if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) 00230 polarssl_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); 00231 if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) 00232 polarssl_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); 00233 if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) 00234 polarssl_snprintf( buf, buflen, "DHM - Reading of the public values failed" ); 00235 if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) 00236 polarssl_snprintf( buf, buflen, "DHM - Making of the public value failed" ); 00237 if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) 00238 polarssl_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); 00239 if( use_ret == -(POLARSSL_ERR_DHM_INVALID_FORMAT) ) 00240 polarssl_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); 00241 if( use_ret == -(POLARSSL_ERR_DHM_MALLOC_FAILED) ) 00242 polarssl_snprintf( buf, buflen, "DHM - Allocation of memory failed" ); 00243 if( use_ret == -(POLARSSL_ERR_DHM_FILE_IO_ERROR) ) 00244 polarssl_snprintf( buf, buflen, "DHM - Read/write of file failed" ); 00245 #endif /* POLARSSL_DHM_C */ 00246 00247 #if defined(POLARSSL_ECP_C) 00248 if( use_ret == -(POLARSSL_ERR_ECP_BAD_INPUT_DATA) ) 00249 polarssl_snprintf( buf, buflen, "ECP - Bad input parameters to function" ); 00250 if( use_ret == -(POLARSSL_ERR_ECP_BUFFER_TOO_SMALL) ) 00251 polarssl_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); 00252 if( use_ret == -(POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE) ) 00253 polarssl_snprintf( buf, buflen, "ECP - Requested curve not available" ); 00254 if( use_ret == -(POLARSSL_ERR_ECP_VERIFY_FAILED) ) 00255 polarssl_snprintf( buf, buflen, "ECP - The signature is not valid" ); 00256 if( use_ret == -(POLARSSL_ERR_ECP_MALLOC_FAILED) ) 00257 polarssl_snprintf( buf, buflen, "ECP - Memory allocation failed" ); 00258 if( use_ret == -(POLARSSL_ERR_ECP_RANDOM_FAILED) ) 00259 polarssl_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); 00260 if( use_ret == -(POLARSSL_ERR_ECP_INVALID_KEY) ) 00261 polarssl_snprintf( buf, buflen, "ECP - Invalid private or public key" ); 00262 if( use_ret == -(POLARSSL_ERR_ECP_SIG_LEN_MISMATCH) ) 00263 polarssl_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" ); 00264 #endif /* POLARSSL_ECP_C */ 00265 00266 #if defined(POLARSSL_MD_C) 00267 if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) 00268 polarssl_snprintf( buf, buflen, "MD - The selected feature is not available" ); 00269 if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) 00270 polarssl_snprintf( buf, buflen, "MD - Bad input parameters to function" ); 00271 if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) 00272 polarssl_snprintf( buf, buflen, "MD - Failed to allocate memory" ); 00273 if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) 00274 polarssl_snprintf( buf, buflen, "MD - Opening or reading of file failed" ); 00275 #endif /* POLARSSL_MD_C */ 00276 00277 #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) 00278 if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) 00279 polarssl_snprintf( buf, buflen, "PEM - No PEM header or footer found" ); 00280 if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) 00281 polarssl_snprintf( buf, buflen, "PEM - PEM string is not as expected" ); 00282 if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) 00283 polarssl_snprintf( buf, buflen, "PEM - Failed to allocate memory" ); 00284 if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) 00285 polarssl_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); 00286 if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) 00287 polarssl_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); 00288 if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) 00289 polarssl_snprintf( buf, buflen, "PEM - Private key password can't be empty" ); 00290 if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) 00291 polarssl_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); 00292 if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) 00293 polarssl_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); 00294 if( use_ret == -(POLARSSL_ERR_PEM_BAD_INPUT_DATA) ) 00295 polarssl_snprintf( buf, buflen, "PEM - Bad input parameters to function" ); 00296 #endif /* POLARSSL_PEM_PARSE_C || POLARSSL_PEM_WRITE_C */ 00297 00298 #if defined(POLARSSL_PK_C) 00299 if( use_ret == -(POLARSSL_ERR_PK_MALLOC_FAILED) ) 00300 polarssl_snprintf( buf, buflen, "PK - Memory alloation failed" ); 00301 if( use_ret == -(POLARSSL_ERR_PK_TYPE_MISMATCH) ) 00302 polarssl_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); 00303 if( use_ret == -(POLARSSL_ERR_PK_BAD_INPUT_DATA) ) 00304 polarssl_snprintf( buf, buflen, "PK - Bad input parameters to function" ); 00305 if( use_ret == -(POLARSSL_ERR_PK_FILE_IO_ERROR) ) 00306 polarssl_snprintf( buf, buflen, "PK - Read/write of file failed" ); 00307 if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_VERSION) ) 00308 polarssl_snprintf( buf, buflen, "PK - Unsupported key version" ); 00309 if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_FORMAT) ) 00310 polarssl_snprintf( buf, buflen, "PK - Invalid key tag or value" ); 00311 if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_PK_ALG) ) 00312 polarssl_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); 00313 if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_REQUIRED) ) 00314 polarssl_snprintf( buf, buflen, "PK - Private key password can't be empty" ); 00315 if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_MISMATCH) ) 00316 polarssl_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); 00317 if( use_ret == -(POLARSSL_ERR_PK_INVALID_PUBKEY) ) 00318 polarssl_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); 00319 if( use_ret == -(POLARSSL_ERR_PK_INVALID_ALG) ) 00320 polarssl_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); 00321 if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE) ) 00322 polarssl_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); 00323 if( use_ret == -(POLARSSL_ERR_PK_FEATURE_UNAVAILABLE) ) 00324 polarssl_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); 00325 if( use_ret == -(POLARSSL_ERR_PK_SIG_LEN_MISMATCH) ) 00326 polarssl_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" ); 00327 #endif /* POLARSSL_PK_C */ 00328 00329 #if defined(POLARSSL_PKCS12_C) 00330 if( use_ret == -(POLARSSL_ERR_PKCS12_BAD_INPUT_DATA) ) 00331 polarssl_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); 00332 if( use_ret == -(POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE) ) 00333 polarssl_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); 00334 if( use_ret == -(POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT) ) 00335 polarssl_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); 00336 if( use_ret == -(POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH) ) 00337 polarssl_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); 00338 #endif /* POLARSSL_PKCS12_C */ 00339 00340 #if defined(POLARSSL_PKCS5_C) 00341 if( use_ret == -(POLARSSL_ERR_PKCS5_BAD_INPUT_DATA) ) 00342 polarssl_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); 00343 if( use_ret == -(POLARSSL_ERR_PKCS5_INVALID_FORMAT) ) 00344 polarssl_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); 00345 if( use_ret == -(POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE) ) 00346 polarssl_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); 00347 if( use_ret == -(POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH) ) 00348 polarssl_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); 00349 #endif /* POLARSSL_PKCS5_C */ 00350 00351 #if defined(POLARSSL_RSA_C) 00352 if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) 00353 polarssl_snprintf( buf, buflen, "RSA - Bad input parameters to function" ); 00354 if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) 00355 polarssl_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); 00356 if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) 00357 polarssl_snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); 00358 if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) 00359 polarssl_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" ); 00360 if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) 00361 polarssl_snprintf( buf, buflen, "RSA - The public key operation failed" ); 00362 if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) 00363 polarssl_snprintf( buf, buflen, "RSA - The private key operation failed" ); 00364 if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) 00365 polarssl_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); 00366 if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) 00367 polarssl_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); 00368 if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) 00369 polarssl_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); 00370 #endif /* POLARSSL_RSA_C */ 00371 00372 #if defined(POLARSSL_SSL_TLS_C) 00373 if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) 00374 polarssl_snprintf( buf, buflen, "SSL - The requested feature is not available" ); 00375 if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) 00376 polarssl_snprintf( buf, buflen, "SSL - Bad input parameters to function" ); 00377 if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) 00378 polarssl_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); 00379 if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) 00380 polarssl_snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); 00381 if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) 00382 polarssl_snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); 00383 if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) 00384 polarssl_snprintf( buf, buflen, "SSL - An unknown cipher was received" ); 00385 if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) 00386 polarssl_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); 00387 if( use_ret == -(POLARSSL_ERR_SSL_NO_RNG) ) 00388 polarssl_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); 00389 if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) 00390 polarssl_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); 00391 if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) 00392 polarssl_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" ); 00393 if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) 00394 polarssl_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); 00395 if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) 00396 polarssl_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); 00397 if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) 00398 polarssl_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); 00399 if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) 00400 polarssl_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); 00401 if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) 00402 { 00403 polarssl_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); 00404 return; 00405 } 00406 if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) 00407 polarssl_snprintf( buf, buflen, "SSL - Verification of our peer failed" ); 00408 if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) 00409 polarssl_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); 00410 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) 00411 polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); 00412 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) 00413 polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); 00414 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) 00415 polarssl_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); 00416 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) 00417 polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); 00418 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) 00419 polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); 00420 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) 00421 polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); 00422 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) 00423 polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); 00424 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) 00425 polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); 00426 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) 00427 polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); 00428 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) 00429 polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); 00430 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) 00431 polarssl_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); 00432 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) 00433 polarssl_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); 00434 if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) 00435 polarssl_snprintf( buf, buflen, "SSL - Memory allocation failed" ); 00436 if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FAILED) ) 00437 polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); 00438 if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) 00439 polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); 00440 if( use_ret == -(POLARSSL_ERR_SSL_COMPRESSION_FAILED) ) 00441 polarssl_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); 00442 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) 00443 polarssl_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); 00444 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) 00445 polarssl_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); 00446 if( use_ret == -(POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED) ) 00447 polarssl_snprintf( buf, buflen, "SSL - Session ticket has expired" ); 00448 if( use_ret == -(POLARSSL_ERR_SSL_PK_TYPE_MISMATCH) ) 00449 polarssl_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); 00450 if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_IDENTITY) ) 00451 polarssl_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); 00452 if( use_ret == -(POLARSSL_ERR_SSL_INTERNAL_ERROR) ) 00453 polarssl_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); 00454 if( use_ret == -(POLARSSL_ERR_SSL_COUNTER_WRAPPING) ) 00455 polarssl_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); 00456 if( use_ret == -(POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) ) 00457 polarssl_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" ); 00458 if( use_ret == -(POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE) ) 00459 polarssl_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); 00460 #endif /* POLARSSL_SSL_TLS_C */ 00461 00462 #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) 00463 if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) 00464 polarssl_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); 00465 if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_OID) ) 00466 polarssl_snprintf( buf, buflen, "X509 - Requested OID is unknown" ); 00467 if( use_ret == -(POLARSSL_ERR_X509_INVALID_FORMAT) ) 00468 polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); 00469 if( use_ret == -(POLARSSL_ERR_X509_INVALID_VERSION) ) 00470 polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); 00471 if( use_ret == -(POLARSSL_ERR_X509_INVALID_SERIAL) ) 00472 polarssl_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); 00473 if( use_ret == -(POLARSSL_ERR_X509_INVALID_ALG) ) 00474 polarssl_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); 00475 if( use_ret == -(POLARSSL_ERR_X509_INVALID_NAME) ) 00476 polarssl_snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); 00477 if( use_ret == -(POLARSSL_ERR_X509_INVALID_DATE) ) 00478 polarssl_snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); 00479 if( use_ret == -(POLARSSL_ERR_X509_INVALID_SIGNATURE) ) 00480 polarssl_snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); 00481 if( use_ret == -(POLARSSL_ERR_X509_INVALID_EXTENSIONS) ) 00482 polarssl_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); 00483 if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_VERSION) ) 00484 polarssl_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); 00485 if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_SIG_ALG) ) 00486 polarssl_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); 00487 if( use_ret == -(POLARSSL_ERR_X509_SIG_MISMATCH) ) 00488 polarssl_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::x509_crt sig_oid)" ); 00489 if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) 00490 polarssl_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); 00491 if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) 00492 polarssl_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); 00493 if( use_ret == -(POLARSSL_ERR_X509_BAD_INPUT_DATA) ) 00494 polarssl_snprintf( buf, buflen, "X509 - Input invalid" ); 00495 if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) 00496 polarssl_snprintf( buf, buflen, "X509 - Allocation of memory failed" ); 00497 if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) 00498 polarssl_snprintf( buf, buflen, "X509 - Read/write of file failed" ); 00499 #endif /* POLARSSL_X509_USE,X509_CREATE_C */ 00500 // END generated code 00501 00502 if( strlen( buf ) == 0 ) 00503 polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00504 } 00505 00506 use_ret = ret & ~0xFF80; 00507 00508 if( use_ret == 0 ) 00509 return; 00510 00511 // If high level code is present, make a concatenation between both 00512 // error strings. 00513 // 00514 len = strlen( buf ); 00515 00516 if( len > 0 ) 00517 { 00518 if( buflen - len < 5 ) 00519 return; 00520 00521 polarssl_snprintf( buf + len, buflen - len, " : " ); 00522 00523 buf += len + 3; 00524 buflen -= len + 3; 00525 } 00526 00527 // Low level error codes 00528 // 00529 // BEGIN generated code 00530 #if defined(POLARSSL_AES_C) 00531 if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) 00532 polarssl_snprintf( buf, buflen, "AES - Invalid key length" ); 00533 if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) 00534 polarssl_snprintf( buf, buflen, "AES - Invalid data input length" ); 00535 #endif /* POLARSSL_AES_C */ 00536 00537 #if defined(POLARSSL_ASN1_PARSE_C) 00538 if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) 00539 polarssl_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); 00540 if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) 00541 polarssl_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); 00542 if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) 00543 polarssl_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); 00544 if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) 00545 polarssl_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); 00546 if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) 00547 polarssl_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); 00548 if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) 00549 polarssl_snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); 00550 if( use_ret == -(POLARSSL_ERR_ASN1_BUF_TOO_SMALL) ) 00551 polarssl_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); 00552 #endif /* POLARSSL_ASN1_PARSE_C */ 00553 00554 #if defined(POLARSSL_BASE64_C) 00555 if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) 00556 polarssl_snprintf( buf, buflen, "BASE64 - Output buffer too small" ); 00557 if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) 00558 polarssl_snprintf( buf, buflen, "BASE64 - Invalid character in input" ); 00559 #endif /* POLARSSL_BASE64_C */ 00560 00561 #if defined(POLARSSL_BIGNUM_C) 00562 if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) 00563 polarssl_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); 00564 if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) 00565 polarssl_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); 00566 if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) 00567 polarssl_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); 00568 if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) 00569 polarssl_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); 00570 if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) 00571 polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); 00572 if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) 00573 polarssl_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); 00574 if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) 00575 polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); 00576 if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) 00577 polarssl_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); 00578 #endif /* POLARSSL_BIGNUM_C */ 00579 00580 #if defined(POLARSSL_BLOWFISH_C) 00581 if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) 00582 polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); 00583 if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) 00584 polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); 00585 #endif /* POLARSSL_BLOWFISH_C */ 00586 00587 #if defined(POLARSSL_CAMELLIA_C) 00588 if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) 00589 polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); 00590 if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) 00591 polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); 00592 #endif /* POLARSSL_CAMELLIA_C */ 00593 00594 #if defined(POLARSSL_CCM_C) 00595 if( use_ret == -(POLARSSL_ERR_CCM_BAD_INPUT) ) 00596 polarssl_snprintf( buf, buflen, "CCM - Bad input parameters to function" ); 00597 if( use_ret == -(POLARSSL_ERR_CCM_AUTH_FAILED) ) 00598 polarssl_snprintf( buf, buflen, "CCM - Authenticated decryption failed" ); 00599 #endif /* POLARSSL_CCM_C */ 00600 00601 #if defined(POLARSSL_CTR_DRBG_C) 00602 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) 00603 polarssl_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); 00604 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) 00605 polarssl_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); 00606 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) 00607 polarssl_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); 00608 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) 00609 polarssl_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); 00610 #endif /* POLARSSL_CTR_DRBG_C */ 00611 00612 #if defined(POLARSSL_DES_C) 00613 if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) 00614 polarssl_snprintf( buf, buflen, "DES - The data input has an invalid length" ); 00615 #endif /* POLARSSL_DES_C */ 00616 00617 #if defined(POLARSSL_ENTROPY_C) 00618 if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) 00619 polarssl_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); 00620 if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) 00621 polarssl_snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); 00622 if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) 00623 polarssl_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); 00624 if( use_ret == -(POLARSSL_ERR_ENTROPY_FILE_IO_ERROR) ) 00625 polarssl_snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); 00626 #endif /* POLARSSL_ENTROPY_C */ 00627 00628 #if defined(POLARSSL_GCM_C) 00629 if( use_ret == -(POLARSSL_ERR_GCM_AUTH_FAILED) ) 00630 polarssl_snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); 00631 if( use_ret == -(POLARSSL_ERR_GCM_BAD_INPUT) ) 00632 polarssl_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); 00633 #endif /* POLARSSL_GCM_C */ 00634 00635 #if defined(POLARSSL_HMAC_DRBG_C) 00636 if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) 00637 polarssl_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); 00638 if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) 00639 polarssl_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); 00640 if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR) ) 00641 polarssl_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); 00642 if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) 00643 polarssl_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); 00644 #endif /* POLARSSL_HMAC_DRBG_C */ 00645 00646 #if defined(POLARSSL_MD2_C) 00647 if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) 00648 polarssl_snprintf( buf, buflen, "MD2 - Read/write error in file" ); 00649 #endif /* POLARSSL_MD2_C */ 00650 00651 #if defined(POLARSSL_MD4_C) 00652 if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) 00653 polarssl_snprintf( buf, buflen, "MD4 - Read/write error in file" ); 00654 #endif /* POLARSSL_MD4_C */ 00655 00656 #if defined(POLARSSL_MD5_C) 00657 if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) 00658 polarssl_snprintf( buf, buflen, "MD5 - Read/write error in file" ); 00659 #endif /* POLARSSL_MD5_C */ 00660 00661 #if defined(POLARSSL_NET_C) 00662 if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) 00663 polarssl_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); 00664 if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) 00665 polarssl_snprintf( buf, buflen, "NET - Failed to open a socket" ); 00666 if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) 00667 polarssl_snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); 00668 if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) 00669 polarssl_snprintf( buf, buflen, "NET - Binding of the socket failed" ); 00670 if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) 00671 polarssl_snprintf( buf, buflen, "NET - Could not listen on the socket" ); 00672 if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) 00673 polarssl_snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); 00674 if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) 00675 polarssl_snprintf( buf, buflen, "NET - Reading information from the socket failed" ); 00676 if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) 00677 polarssl_snprintf( buf, buflen, "NET - Sending information through the socket failed" ); 00678 if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) 00679 polarssl_snprintf( buf, buflen, "NET - Connection was reset by peer" ); 00680 if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) 00681 polarssl_snprintf( buf, buflen, "NET - Connection requires a read call" ); 00682 if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) 00683 polarssl_snprintf( buf, buflen, "NET - Connection requires a write call" ); 00684 #endif /* POLARSSL_NET_C */ 00685 00686 #if defined(POLARSSL_OID_C) 00687 if( use_ret == -(POLARSSL_ERR_OID_NOT_FOUND) ) 00688 polarssl_snprintf( buf, buflen, "OID - OID is not found" ); 00689 if( use_ret == -(POLARSSL_ERR_OID_BUF_TOO_SMALL) ) 00690 polarssl_snprintf( buf, buflen, "OID - output buffer is too small" ); 00691 #endif /* POLARSSL_OID_C */ 00692 00693 #if defined(POLARSSL_PADLOCK_C) 00694 if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) 00695 polarssl_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); 00696 #endif /* POLARSSL_PADLOCK_C */ 00697 00698 #if defined(POLARSSL_PBKDF2_C) 00699 if( use_ret == -(POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA) ) 00700 polarssl_snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" ); 00701 #endif /* POLARSSL_PBKDF2_C */ 00702 00703 #if defined(POLARSSL_RIPEMD160_C) 00704 if( use_ret == -(POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR) ) 00705 polarssl_snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" ); 00706 #endif /* POLARSSL_RIPEMD160_C */ 00707 00708 #if defined(POLARSSL_SHA1_C) 00709 if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) 00710 polarssl_snprintf( buf, buflen, "SHA1 - Read/write error in file" ); 00711 #endif /* POLARSSL_SHA1_C */ 00712 00713 #if defined(POLARSSL_SHA256_C) 00714 if( use_ret == -(POLARSSL_ERR_SHA256_FILE_IO_ERROR) ) 00715 polarssl_snprintf( buf, buflen, "SHA256 - Read/write error in file" ); 00716 #endif /* POLARSSL_SHA256_C */ 00717 00718 #if defined(POLARSSL_SHA512_C) 00719 if( use_ret == -(POLARSSL_ERR_SHA512_FILE_IO_ERROR) ) 00720 polarssl_snprintf( buf, buflen, "SHA512 - Read/write error in file" ); 00721 #endif /* POLARSSL_SHA512_C */ 00722 00723 #if defined(POLARSSL_THREADING_C) 00724 if( use_ret == -(POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE) ) 00725 polarssl_snprintf( buf, buflen, "THREADING - The selected feature is not available" ); 00726 if( use_ret == -(POLARSSL_ERR_THREADING_BAD_INPUT_DATA) ) 00727 polarssl_snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); 00728 if( use_ret == -(POLARSSL_ERR_THREADING_MUTEX_ERROR) ) 00729 polarssl_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); 00730 #endif /* POLARSSL_THREADING_C */ 00731 00732 #if defined(POLARSSL_XTEA_C) 00733 if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) 00734 polarssl_snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); 00735 #endif /* POLARSSL_XTEA_C */ 00736 // END generated code 00737 00738 if( strlen( buf ) != 0 ) 00739 return; 00740 00741 polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00742 } 00743 00744 #if defined(POLARSSL_ERROR_STRERROR_BC) 00745 void error_strerror( int ret, char *buf, size_t buflen ) 00746 { 00747 polarssl_strerror( ret, buf, buflen ); 00748 } 00749 #endif /* POLARSSL_ERROR_STRERROR_BC */ 00750 00751 #else /* POLARSSL_ERROR_C */ 00752 00753 #if defined(POLARSSL_ERROR_STRERROR_DUMMY) 00754 00755 /* 00756 * Provide an non-function in case POLARSSL_ERROR_C is not defined 00757 */ 00758 void polarssl_strerror( int ret, char *buf, size_t buflen ) 00759 { 00760 ((void) ret); 00761 00762 if( buflen > 0 ) 00763 buf[0] = '\0'; 00764 } 00765 00766 #if defined(POLARSSL_ERROR_STRERROR_BC) 00767 void error_strerror( int ret, char *buf, size_t buflen ) 00768 { 00769 polarssl_strerror( ret, buf, buflen ); 00770 } 00771 #endif /* POLARSSL_ERROR_STRERROR_BC */ 00772 #endif /* POLARSSL_ERROR_STRERROR_DUMMY */ 00773 00774 #endif /* POLARSSL_ERROR_C */ 00775
Generated on Tue Jul 12 2022 13:50:37 by 1.7.2