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