PolarSSL v1.1.4
|
00001 /* 00002 * Error message information 00003 * 00004 * Copyright (C) 2006-2010, Brainspark B.V. 00005 * 00006 * This file is part of PolarSSL (http://www.polarssl.org) 00007 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> 00008 * 00009 * All rights reserved. 00010 * 00011 * This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License along 00022 * with this program; if not, write to the Free Software Foundation, Inc., 00023 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00024 */ 00025 00026 #include "polarssl/config.h" 00027 00028 #if defined(POLARSSL_ERROR_C) 00029 00030 #if defined(POLARSSL_AES_C) 00031 #include "polarssl/aes.h" 00032 #endif 00033 00034 #if defined(POLARSSL_BASE64_C) 00035 #include "polarssl/base64.h" 00036 #endif 00037 00038 #if defined(POLARSSL_BIGNUM_C) 00039 #include "polarssl/bignum.h" 00040 #endif 00041 00042 #if defined(POLARSSL_CAMELLIA_C) 00043 #include "polarssl/camellia.h" 00044 #endif 00045 00046 #if defined(POLARSSL_CIPHER_C) 00047 #include "polarssl/cipher.h" 00048 #endif 00049 00050 #if defined(POLARSSL_CTR_DRBG_C) 00051 #include "polarssl/ctr_drbg.h" 00052 #endif 00053 00054 #if defined(POLARSSL_DES_C) 00055 #include "polarssl/des.h" 00056 #endif 00057 00058 #if defined(POLARSSL_DHM_C) 00059 #include "polarssl/dhm.h" 00060 #endif 00061 00062 #if defined(POLARSSL_ENTROPY_C) 00063 #include "polarssl/entropy.h" 00064 #endif 00065 00066 #if defined(POLARSSL_MD_C) 00067 #include "polarssl/md.h" 00068 #endif 00069 00070 #if defined(POLARSSL_MD2_C) 00071 #include "polarssl/md2.h" 00072 #endif 00073 00074 #if defined(POLARSSL_MD4_C) 00075 #include "polarssl/md4.h" 00076 #endif 00077 00078 #if defined(POLARSSL_MD5_C) 00079 #include "polarssl/md5.h" 00080 #endif 00081 00082 #if defined(POLARSSL_NET_C) 00083 #include "polarssl/net.h" 00084 #endif 00085 00086 #if defined(POLARSSL_PADLOCK_C) 00087 #include "polarssl/padlock.h" 00088 #endif 00089 00090 #if defined(POLARSSL_PEM_C) 00091 #include "polarssl/pem.h" 00092 #endif 00093 00094 #if defined(POLARSSL_RSA_C) 00095 #include "polarssl/rsa.h" 00096 #endif 00097 00098 #if defined(POLARSSL_SHA1_C) 00099 #include "polarssl/sha1.h" 00100 #endif 00101 00102 #if defined(POLARSSL_SHA2_C) 00103 #include "polarssl/sha2.h" 00104 #endif 00105 00106 #if defined(POLARSSL_SHA4_C) 00107 #include "polarssl/sha4.h" 00108 #endif 00109 00110 #if defined(POLARSSL_SSL_TLS_C) 00111 #include "polarssl/ssl.h" 00112 #endif 00113 00114 #if defined(POLARSSL_X509_PARSE_C) 00115 #include "polarssl/x509.h" 00116 #endif 00117 00118 #if defined(POLARSSL_XTEA_C) 00119 #include "polarssl/xtea.h" 00120 #endif 00121 00122 00123 #include <string.h> 00124 00125 #if defined _MSC_VER && !defined snprintf 00126 #define snprintf _snprintf 00127 #endif 00128 00129 void error_strerror( int ret, char *buf, size_t buflen ) 00130 { 00131 size_t len; 00132 int use_ret; 00133 00134 memset( buf, 0x00, buflen ); 00135 00136 if( ret < 0 ) 00137 ret = -ret; 00138 00139 if( ret & 0xFF80 ) 00140 { 00141 use_ret = ret & 0xFF80; 00142 00143 // High level error codes 00144 // 00145 #if defined(POLARSSL_CIPHER_C) 00146 if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) 00147 snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); 00148 if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) 00149 snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); 00150 if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) 00151 snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); 00152 if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) 00153 snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); 00154 if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) 00155 snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); 00156 #endif /* POLARSSL_CIPHER_C */ 00157 00158 #if defined(POLARSSL_DHM_C) 00159 if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) 00160 snprintf( buf, buflen, "DHM - Bad input parameters to function" ); 00161 if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) 00162 snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); 00163 if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) 00164 snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); 00165 if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) 00166 snprintf( buf, buflen, "DHM - Reading of the public values failed" ); 00167 if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) 00168 snprintf( buf, buflen, "DHM - Makeing of the public value failed" ); 00169 if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) 00170 snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); 00171 #endif /* POLARSSL_DHM_C */ 00172 00173 #if defined(POLARSSL_MD_C) 00174 if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) 00175 snprintf( buf, buflen, "MD - The selected feature is not available" ); 00176 if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) 00177 snprintf( buf, buflen, "MD - Bad input parameters to function" ); 00178 if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) 00179 snprintf( buf, buflen, "MD - Failed to allocate memory" ); 00180 if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) 00181 snprintf( buf, buflen, "MD - Opening or reading of file failed" ); 00182 #endif /* POLARSSL_MD_C */ 00183 00184 #if defined(POLARSSL_PEM_C) 00185 if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_PRESENT) ) 00186 snprintf( buf, buflen, "PEM - No PEM header found" ); 00187 if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) 00188 snprintf( buf, buflen, "PEM - PEM string is not as expected" ); 00189 if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) 00190 snprintf( buf, buflen, "PEM - Failed to allocate memory" ); 00191 if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) 00192 snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); 00193 if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) 00194 snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); 00195 if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) 00196 snprintf( buf, buflen, "PEM - Private key password can't be empty" ); 00197 if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) 00198 snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); 00199 if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) 00200 snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); 00201 #endif /* POLARSSL_PEM_C */ 00202 00203 #if defined(POLARSSL_RSA_C) 00204 if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) 00205 snprintf( buf, buflen, "RSA - Bad input parameters to function" ); 00206 if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) 00207 snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); 00208 if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) 00209 snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); 00210 if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) 00211 snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" ); 00212 if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) 00213 snprintf( buf, buflen, "RSA - The public key operation failed" ); 00214 if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) 00215 snprintf( buf, buflen, "RSA - The private key operation failed" ); 00216 if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) 00217 snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); 00218 if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) 00219 snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); 00220 if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) 00221 snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); 00222 #endif /* POLARSSL_RSA_C */ 00223 00224 #if defined(POLARSSL_SSL_TLS_C) 00225 if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) 00226 snprintf( buf, buflen, "SSL - The requested feature is not available" ); 00227 if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) 00228 snprintf( buf, buflen, "SSL - Bad input parameters to function" ); 00229 if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) 00230 snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); 00231 if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) 00232 snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); 00233 if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) 00234 snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); 00235 if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) 00236 snprintf( buf, buflen, "SSL - An unknown cipher was received" ); 00237 if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) 00238 snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); 00239 if( use_ret == -(POLARSSL_ERR_SSL_NO_SESSION_FOUND) ) 00240 snprintf( buf, buflen, "SSL - No session to recover was found" ); 00241 if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) 00242 snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); 00243 if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) 00244 snprintf( buf, buflen, "SSL - DESCRIPTION MISSING" ); 00245 if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) 00246 snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); 00247 if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) 00248 snprintf( buf, buflen, "SSL - The own private key is not set, but needed" ); 00249 if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) 00250 snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); 00251 if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) 00252 snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); 00253 if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) 00254 snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); 00255 if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) 00256 snprintf( buf, buflen, "SSL - Verification of our peer failed" ); 00257 if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) 00258 snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); 00259 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) 00260 snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); 00261 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) 00262 snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); 00263 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) 00264 snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); 00265 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) 00266 snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); 00267 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) 00268 snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); 00269 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) 00270 snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); 00271 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) 00272 snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); 00273 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP) ) 00274 snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Read Public" ); 00275 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS) ) 00276 snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Calculate Secret" ); 00277 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) 00278 snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); 00279 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) 00280 snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); 00281 if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) 00282 snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); 00283 if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) 00284 snprintf( buf, buflen, "SSL - Memory allocation failed" ); 00285 #endif /* POLARSSL_SSL_TLS_C */ 00286 00287 #if defined(POLARSSL_X509_PARSE_C) 00288 if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) 00289 snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); 00290 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PEM) ) 00291 snprintf( buf, buflen, "X509 - The PEM-encoded certificate contains invalid elements, e.g. invalid character" ); 00292 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_FORMAT) ) 00293 snprintf( buf, buflen, "X509 - The certificate format is invalid, e.g. different type expected" ); 00294 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_VERSION) ) 00295 snprintf( buf, buflen, "X509 - The certificate version element is invalid" ); 00296 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SERIAL) ) 00297 snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); 00298 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_ALG) ) 00299 snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); 00300 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_NAME) ) 00301 snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); 00302 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_DATE) ) 00303 snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); 00304 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PUBKEY) ) 00305 snprintf( buf, buflen, "X509 - The pubkey tag or value is invalid (only RSA is supported)" ); 00306 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE) ) 00307 snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); 00308 if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS) ) 00309 snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); 00310 if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION) ) 00311 snprintf( buf, buflen, "X509 - Certificate or CRL has an unsupported version number" ); 00312 if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG) ) 00313 snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); 00314 if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_PK_ALG) ) 00315 snprintf( buf, buflen, "X509 - Key algorithm is unsupported (only RSA is supported)" ); 00316 if( use_ret == -(POLARSSL_ERR_X509_CERT_SIG_MISMATCH) ) 00317 snprintf( buf, buflen, "X509 - Certificate signature algorithms do not match. (see \\c ::x509_cert sig_oid)" ); 00318 if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) 00319 snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); 00320 if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_VERSION) ) 00321 snprintf( buf, buflen, "X509 - Unsupported RSA key version" ); 00322 if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_FORMAT) ) 00323 snprintf( buf, buflen, "X509 - Invalid RSA key tag or value" ); 00324 if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) 00325 snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); 00326 if( use_ret == -(POLARSSL_ERR_X509_INVALID_INPUT) ) 00327 snprintf( buf, buflen, "X509 - Input invalid" ); 00328 if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) 00329 snprintf( buf, buflen, "X509 - Allocation of memory failed" ); 00330 if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) 00331 snprintf( buf, buflen, "X509 - Read/write of file failed" ); 00332 #endif /* POLARSSL_X509_PARSE_C */ 00333 00334 if( strlen( buf ) == 0 ) 00335 snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00336 } 00337 00338 use_ret = ret & ~0xFF80; 00339 00340 if( use_ret == 0 ) 00341 return; 00342 00343 // If high level code is present, make a concatenation between both 00344 // error strings. 00345 // 00346 len = strlen( buf ); 00347 00348 if( len > 0 ) 00349 { 00350 if( buflen - len < 5 ) 00351 return; 00352 00353 snprintf( buf + len, buflen - len, " : " ); 00354 00355 buf += len + 3; 00356 buflen -= len + 3; 00357 } 00358 00359 // Low level error codes 00360 // 00361 #if defined(POLARSSL_AES_C) 00362 if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) 00363 snprintf( buf, buflen, "AES - Invalid key length" ); 00364 if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) 00365 snprintf( buf, buflen, "AES - Invalid data input length" ); 00366 #endif /* POLARSSL_AES_C */ 00367 00368 #if defined(POLARSSL_ASN1_PARSE_C) 00369 if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) 00370 snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); 00371 if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) 00372 snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); 00373 if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) 00374 snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); 00375 if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) 00376 snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); 00377 if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) 00378 snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); 00379 if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) 00380 snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); 00381 #endif /* POLARSSL_ASN1_PARSE_C */ 00382 00383 #if defined(POLARSSL_BASE64_C) 00384 if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) 00385 snprintf( buf, buflen, "BASE64 - Output buffer too small" ); 00386 if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) 00387 snprintf( buf, buflen, "BASE64 - Invalid character in input" ); 00388 #endif /* POLARSSL_BASE64_C */ 00389 00390 #if defined(POLARSSL_BIGNUM_C) 00391 if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) 00392 snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); 00393 if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) 00394 snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); 00395 if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) 00396 snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); 00397 if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) 00398 snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); 00399 if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) 00400 snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); 00401 if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) 00402 snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); 00403 if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) 00404 snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); 00405 if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) 00406 snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); 00407 #endif /* POLARSSL_BIGNUM_C */ 00408 00409 #if defined(POLARSSL_CAMELLIA_C) 00410 if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) 00411 snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); 00412 if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) 00413 snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); 00414 #endif /* POLARSSL_CAMELLIA_C */ 00415 00416 #if defined(POLARSSL_CTR_DRBG_C) 00417 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) 00418 snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); 00419 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) 00420 snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); 00421 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) 00422 snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); 00423 if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) 00424 snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); 00425 #endif /* POLARSSL_CTR_DRBG_C */ 00426 00427 #if defined(POLARSSL_DES_C) 00428 if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) 00429 snprintf( buf, buflen, "DES - The data input has an invalid length" ); 00430 #endif /* POLARSSL_DES_C */ 00431 00432 #if defined(POLARSSL_ENTROPY_C) 00433 if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) 00434 snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); 00435 if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) 00436 snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); 00437 if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) 00438 snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); 00439 #endif /* POLARSSL_ENTROPY_C */ 00440 00441 #if defined(POLARSSL_MD2_C) 00442 if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) 00443 snprintf( buf, buflen, "MD2 - Read/write error in file" ); 00444 #endif /* POLARSSL_MD2_C */ 00445 00446 #if defined(POLARSSL_MD4_C) 00447 if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) 00448 snprintf( buf, buflen, "MD4 - Read/write error in file" ); 00449 #endif /* POLARSSL_MD4_C */ 00450 00451 #if defined(POLARSSL_MD5_C) 00452 if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) 00453 snprintf( buf, buflen, "MD5 - Read/write error in file" ); 00454 #endif /* POLARSSL_MD5_C */ 00455 00456 #if defined(POLARSSL_NET_C) 00457 if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) 00458 snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); 00459 if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) 00460 snprintf( buf, buflen, "NET - Failed to open a socket" ); 00461 if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) 00462 snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); 00463 if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) 00464 snprintf( buf, buflen, "NET - Binding of the socket failed" ); 00465 if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) 00466 snprintf( buf, buflen, "NET - Could not listen on the socket" ); 00467 if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) 00468 snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); 00469 if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) 00470 snprintf( buf, buflen, "NET - Reading information from the socket failed" ); 00471 if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) 00472 snprintf( buf, buflen, "NET - Sending information through the socket failed" ); 00473 if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) 00474 snprintf( buf, buflen, "NET - Connection was reset by peer" ); 00475 if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) 00476 snprintf( buf, buflen, "NET - Connection requires a read call" ); 00477 if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) 00478 snprintf( buf, buflen, "NET - Connection requires a write call" ); 00479 #endif /* POLARSSL_NET_C */ 00480 00481 #if defined(POLARSSL_PADLOCK_C) 00482 if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) 00483 snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); 00484 #endif /* POLARSSL_PADLOCK_C */ 00485 00486 #if defined(POLARSSL_SHA1_C) 00487 if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) 00488 snprintf( buf, buflen, "SHA1 - Read/write error in file" ); 00489 #endif /* POLARSSL_SHA1_C */ 00490 00491 #if defined(POLARSSL_SHA2_C) 00492 if( use_ret == -(POLARSSL_ERR_SHA2_FILE_IO_ERROR) ) 00493 snprintf( buf, buflen, "SHA2 - Read/write error in file" ); 00494 #endif /* POLARSSL_SHA2_C */ 00495 00496 #if defined(POLARSSL_SHA4_C) 00497 if( use_ret == -(POLARSSL_ERR_SHA4_FILE_IO_ERROR) ) 00498 snprintf( buf, buflen, "SHA4 - Read/write error in file" ); 00499 #endif /* POLARSSL_SHA4_C */ 00500 00501 #if defined(POLARSSL_XTEA_C) 00502 if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) 00503 snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); 00504 #endif /* POLARSSL_XTEA_C */ 00505 00506 if( strlen( buf ) != 0 ) 00507 return; 00508 00509 snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00510 } 00511 00512 #endif /* POLARSSL_VERBOSE_ERROR */