mbedtls ported to mbed-classic
Fork of mbedtls by
Embed:
(wiki syntax)
Show/hide line numbers
error.c
00001 /* 00002 * Error message information 00003 * 00004 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00005 * SPDX-License-Identifier: Apache-2.0 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00008 * not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00015 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 * This file is part of mbed TLS (https://tls.mbed.org) 00020 */ 00021 00022 #if !defined(MBEDTLS_CONFIG_FILE) 00023 #include "mbedtls/config.h" 00024 #else 00025 #include MBEDTLS_CONFIG_FILE 00026 #endif 00027 00028 #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) 00029 #include "mbedtls/error.h" 00030 #include <string.h> 00031 #endif 00032 00033 #if defined(MBEDTLS_PLATFORM_C) 00034 #include "mbedtls/platform.h" 00035 #else 00036 #define mbedtls_snprintf snprintf 00037 #endif 00038 00039 #if defined(MBEDTLS_ERROR_C) 00040 00041 #include <stdio.h> 00042 00043 #if defined(MBEDTLS_AES_C) 00044 #include "mbedtls/aes.h" 00045 #endif 00046 00047 #if defined(MBEDTLS_BASE64_C) 00048 #include "mbedtls/base64.h" 00049 #endif 00050 00051 #if defined(MBEDTLS_BIGNUM_C) 00052 #include "mbedtls/bignum.h" 00053 #endif 00054 00055 #if defined(MBEDTLS_BLOWFISH_C) 00056 #include "mbedtls/blowfish.h" 00057 #endif 00058 00059 #if defined(MBEDTLS_CAMELLIA_C) 00060 #include "mbedtls/camellia.h" 00061 #endif 00062 00063 #if defined(MBEDTLS_CCM_C) 00064 #include "mbedtls/ccm.h" 00065 #endif 00066 00067 #if defined(MBEDTLS_CIPHER_C) 00068 #include "mbedtls/cipher.h" 00069 #endif 00070 00071 #if defined(MBEDTLS_CTR_DRBG_C) 00072 #include "mbedtls/ctr_drbg.h" 00073 #endif 00074 00075 #if defined(MBEDTLS_DES_C) 00076 #include "mbedtls/des.h" 00077 #endif 00078 00079 #if defined(MBEDTLS_DHM_C) 00080 #include "mbedtls/dhm.h" 00081 #endif 00082 00083 #if defined(MBEDTLS_ECP_C) 00084 #include "mbedtls/ecp.h" 00085 #endif 00086 00087 #if defined(MBEDTLS_ENTROPY_C) 00088 #include "mbedtls/entropy.h" 00089 #endif 00090 00091 #if defined(MBEDTLS_GCM_C) 00092 #include "mbedtls/gcm.h" 00093 #endif 00094 00095 #if defined(MBEDTLS_HMAC_DRBG_C) 00096 #include "mbedtls/hmac_drbg.h" 00097 #endif 00098 00099 #if defined(MBEDTLS_MD_C) 00100 #include "mbedtls/md.h" 00101 #endif 00102 00103 #if defined(MBEDTLS_NET_C) 00104 #include "mbedtls/net.h" 00105 #endif 00106 00107 #if defined(MBEDTLS_OID_C) 00108 #include "mbedtls/oid.h" 00109 #endif 00110 00111 #if defined(MBEDTLS_PADLOCK_C) 00112 #include "mbedtls/padlock.h" 00113 #endif 00114 00115 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) 00116 #include "mbedtls/pem.h" 00117 #endif 00118 00119 #if defined(MBEDTLS_PK_C) 00120 #include "mbedtls/pk.h" 00121 #endif 00122 00123 #if defined(MBEDTLS_PKCS12_C) 00124 #include "mbedtls/pkcs12.h" 00125 #endif 00126 00127 #if defined(MBEDTLS_PKCS5_C) 00128 #include "mbedtls/pkcs5.h" 00129 #endif 00130 00131 #if defined(MBEDTLS_RSA_C) 00132 #include "mbedtls/rsa.h" 00133 #endif 00134 00135 #if defined(MBEDTLS_SSL_TLS_C) 00136 #include "mbedtls/ssl.h" 00137 #endif 00138 00139 #if defined(MBEDTLS_THREADING_C) 00140 #include "mbedtls/threading.h" 00141 #endif 00142 00143 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) 00144 #include "mbedtls/x509.h" 00145 #endif 00146 00147 #if defined(MBEDTLS_XTEA_C) 00148 #include "mbedtls/xtea.h" 00149 #endif 00150 00151 00152 void mbedtls_strerror( int ret, char *buf, size_t buflen ) 00153 { 00154 size_t len; 00155 int use_ret; 00156 00157 if( buflen == 0 ) 00158 return; 00159 00160 memset( buf, 0x00, buflen ); 00161 00162 if( ret < 0 ) 00163 ret = -ret; 00164 00165 if( ret & 0xFF80 ) 00166 { 00167 use_ret = ret & 0xFF80; 00168 00169 // High level error codes 00170 // 00171 // BEGIN generated code 00172 #if defined(MBEDTLS_CIPHER_C) 00173 if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) ) 00174 mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); 00175 if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) ) 00176 mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); 00177 if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) ) 00178 mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); 00179 if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) ) 00180 mbedtls_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); 00181 if( use_ret == -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) 00182 mbedtls_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); 00183 if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) ) 00184 mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); 00185 #endif /* MBEDTLS_CIPHER_C */ 00186 00187 #if defined(MBEDTLS_DHM_C) 00188 if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) ) 00189 mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters to function" ); 00190 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) ) 00191 mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); 00192 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) ) 00193 mbedtls_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); 00194 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED) ) 00195 mbedtls_snprintf( buf, buflen, "DHM - Reading of the public values failed" ); 00196 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED) ) 00197 mbedtls_snprintf( buf, buflen, "DHM - Making of the public value failed" ); 00198 if( use_ret == -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED) ) 00199 mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); 00200 if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) ) 00201 mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); 00202 if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) ) 00203 mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" ); 00204 if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) ) 00205 mbedtls_snprintf( buf, buflen, "DHM - Read/write of file failed" ); 00206 #endif /* MBEDTLS_DHM_C */ 00207 00208 #if defined(MBEDTLS_ECP_C) 00209 if( use_ret == -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA) ) 00210 mbedtls_snprintf( buf, buflen, "ECP - Bad input parameters to function" ); 00211 if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) ) 00212 mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); 00213 if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) ) 00214 mbedtls_snprintf( buf, buflen, "ECP - Requested curve not available" ); 00215 if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) ) 00216 mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" ); 00217 if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) ) 00218 mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" ); 00219 if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) ) 00220 mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); 00221 if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) ) 00222 mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" ); 00223 if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) ) 00224 mbedtls_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" ); 00225 #endif /* MBEDTLS_ECP_C */ 00226 00227 #if defined(MBEDTLS_MD_C) 00228 if( use_ret == -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE) ) 00229 mbedtls_snprintf( buf, buflen, "MD - The selected feature is not available" ); 00230 if( use_ret == -(MBEDTLS_ERR_MD_BAD_INPUT_DATA) ) 00231 mbedtls_snprintf( buf, buflen, "MD - Bad input parameters to function" ); 00232 if( use_ret == -(MBEDTLS_ERR_MD_ALLOC_FAILED) ) 00233 mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" ); 00234 if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) ) 00235 mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" ); 00236 #endif /* MBEDTLS_MD_C */ 00237 00238 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) 00239 if( use_ret == -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) 00240 mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" ); 00241 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) ) 00242 mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" ); 00243 if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) ) 00244 mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" ); 00245 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) ) 00246 mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); 00247 if( use_ret == -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG) ) 00248 mbedtls_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); 00249 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED) ) 00250 mbedtls_snprintf( buf, buflen, "PEM - Private key password can't be empty" ); 00251 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH) ) 00252 mbedtls_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); 00253 if( use_ret == -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE) ) 00254 mbedtls_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); 00255 if( use_ret == -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA) ) 00256 mbedtls_snprintf( buf, buflen, "PEM - Bad input parameters to function" ); 00257 #endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */ 00258 00259 #if defined(MBEDTLS_PK_C) 00260 if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) ) 00261 mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" ); 00262 if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) ) 00263 mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); 00264 if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) ) 00265 mbedtls_snprintf( buf, buflen, "PK - Bad input parameters to function" ); 00266 if( use_ret == -(MBEDTLS_ERR_PK_FILE_IO_ERROR) ) 00267 mbedtls_snprintf( buf, buflen, "PK - Read/write of file failed" ); 00268 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION) ) 00269 mbedtls_snprintf( buf, buflen, "PK - Unsupported key version" ); 00270 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT) ) 00271 mbedtls_snprintf( buf, buflen, "PK - Invalid key tag or value" ); 00272 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG) ) 00273 mbedtls_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); 00274 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED) ) 00275 mbedtls_snprintf( buf, buflen, "PK - Private key password can't be empty" ); 00276 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH) ) 00277 mbedtls_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); 00278 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_PUBKEY) ) 00279 mbedtls_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); 00280 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_ALG) ) 00281 mbedtls_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); 00282 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE) ) 00283 mbedtls_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); 00284 if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) ) 00285 mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); 00286 if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) ) 00287 mbedtls_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" ); 00288 #endif /* MBEDTLS_PK_C */ 00289 00290 #if defined(MBEDTLS_PKCS12_C) 00291 if( use_ret == -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA) ) 00292 mbedtls_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); 00293 if( use_ret == -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE) ) 00294 mbedtls_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); 00295 if( use_ret == -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT) ) 00296 mbedtls_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); 00297 if( use_ret == -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) ) 00298 mbedtls_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); 00299 #endif /* MBEDTLS_PKCS12_C */ 00300 00301 #if defined(MBEDTLS_PKCS5_C) 00302 if( use_ret == -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA) ) 00303 mbedtls_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); 00304 if( use_ret == -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT) ) 00305 mbedtls_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); 00306 if( use_ret == -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE) ) 00307 mbedtls_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); 00308 if( use_ret == -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH) ) 00309 mbedtls_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); 00310 #endif /* MBEDTLS_PKCS5_C */ 00311 00312 #if defined(MBEDTLS_RSA_C) 00313 if( use_ret == -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA) ) 00314 mbedtls_snprintf( buf, buflen, "RSA - Bad input parameters to function" ); 00315 if( use_ret == -(MBEDTLS_ERR_RSA_INVALID_PADDING) ) 00316 mbedtls_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); 00317 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) ) 00318 mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); 00319 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) ) 00320 mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" ); 00321 if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) ) 00322 mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" ); 00323 if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) ) 00324 mbedtls_snprintf( buf, buflen, "RSA - The private key operation failed" ); 00325 if( use_ret == -(MBEDTLS_ERR_RSA_VERIFY_FAILED) ) 00326 mbedtls_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); 00327 if( use_ret == -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE) ) 00328 mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); 00329 if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) ) 00330 mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); 00331 #endif /* MBEDTLS_RSA_C */ 00332 00333 #if defined(MBEDTLS_SSL_TLS_C) 00334 if( use_ret == -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) ) 00335 mbedtls_snprintf( buf, buflen, "SSL - The requested feature is not available" ); 00336 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA) ) 00337 mbedtls_snprintf( buf, buflen, "SSL - Bad input parameters to function" ); 00338 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_MAC) ) 00339 mbedtls_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); 00340 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_RECORD) ) 00341 mbedtls_snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); 00342 if( use_ret == -(MBEDTLS_ERR_SSL_CONN_EOF) ) 00343 mbedtls_snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); 00344 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER) ) 00345 mbedtls_snprintf( buf, buflen, "SSL - An unknown cipher was received" ); 00346 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN) ) 00347 mbedtls_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); 00348 if( use_ret == -(MBEDTLS_ERR_SSL_NO_RNG) ) 00349 mbedtls_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); 00350 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE) ) 00351 mbedtls_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); 00352 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE) ) 00353 mbedtls_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" ); 00354 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED) ) 00355 mbedtls_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); 00356 if( use_ret == -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED) ) 00357 mbedtls_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); 00358 if( use_ret == -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) ) 00359 mbedtls_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); 00360 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) ) 00361 mbedtls_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); 00362 if( use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) ) 00363 { 00364 mbedtls_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); 00365 return; 00366 } 00367 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED) ) 00368 mbedtls_snprintf( buf, buflen, "SSL - Verification of our peer failed" ); 00369 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) ) 00370 mbedtls_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); 00371 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO) ) 00372 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); 00373 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO) ) 00374 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); 00375 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE) ) 00376 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); 00377 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) 00378 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); 00379 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) 00380 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); 00381 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) 00382 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); 00383 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) 00384 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); 00385 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) 00386 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); 00387 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) 00388 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); 00389 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) 00390 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); 00391 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) 00392 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); 00393 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) ) 00394 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); 00395 if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) ) 00396 mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" ); 00397 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) ) 00398 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); 00399 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) 00400 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); 00401 if( use_ret == -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED) ) 00402 mbedtls_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); 00403 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) 00404 mbedtls_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); 00405 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) 00406 mbedtls_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); 00407 if( use_ret == -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED) ) 00408 mbedtls_snprintf( buf, buflen, "SSL - Session ticket has expired" ); 00409 if( use_ret == -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH) ) 00410 mbedtls_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); 00411 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY) ) 00412 mbedtls_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); 00413 if( use_ret == -(MBEDTLS_ERR_SSL_INTERNAL_ERROR) ) 00414 mbedtls_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); 00415 if( use_ret == -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING) ) 00416 mbedtls_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); 00417 if( use_ret == -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) ) 00418 mbedtls_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" ); 00419 if( use_ret == -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) ) 00420 mbedtls_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" ); 00421 if( use_ret == -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) ) 00422 mbedtls_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" ); 00423 if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) ) 00424 mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); 00425 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) ) 00426 mbedtls_snprintf( buf, buflen, "SSL - Connection requires a read call" ); 00427 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) ) 00428 mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" ); 00429 if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) ) 00430 mbedtls_snprintf( buf, buflen, "SSL - The operation timed out" ); 00431 if( use_ret == -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT) ) 00432 mbedtls_snprintf( buf, buflen, "SSL - The client initiated a reconnect from the same port" ); 00433 #endif /* MBEDTLS_SSL_TLS_C */ 00434 00435 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) 00436 if( use_ret == -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE) ) 00437 mbedtls_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); 00438 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_OID) ) 00439 mbedtls_snprintf( buf, buflen, "X509 - Requested OID is unknown" ); 00440 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_FORMAT) ) 00441 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); 00442 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_VERSION) ) 00443 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); 00444 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SERIAL) ) 00445 mbedtls_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); 00446 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_ALG) ) 00447 mbedtls_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); 00448 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_NAME) ) 00449 mbedtls_snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); 00450 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_DATE) ) 00451 mbedtls_snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); 00452 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SIGNATURE) ) 00453 mbedtls_snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); 00454 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS) ) 00455 mbedtls_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); 00456 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_VERSION) ) 00457 mbedtls_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); 00458 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG) ) 00459 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); 00460 if( use_ret == -(MBEDTLS_ERR_X509_SIG_MISMATCH) ) 00461 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" ); 00462 if( use_ret == -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) ) 00463 mbedtls_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); 00464 if( use_ret == -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT) ) 00465 mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); 00466 if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) ) 00467 mbedtls_snprintf( buf, buflen, "X509 - Input invalid" ); 00468 if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) ) 00469 mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" ); 00470 if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) ) 00471 mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" ); 00472 if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) ) 00473 mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" ); 00474 #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ 00475 // END generated code 00476 00477 if( strlen( buf ) == 0 ) 00478 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00479 } 00480 00481 use_ret = ret & ~0xFF80; 00482 00483 if( use_ret == 0 ) 00484 return; 00485 00486 // If high level code is present, make a concatenation between both 00487 // error strings. 00488 // 00489 len = strlen( buf ); 00490 00491 if( len > 0 ) 00492 { 00493 if( buflen - len < 5 ) 00494 return; 00495 00496 mbedtls_snprintf( buf + len, buflen - len, " : " ); 00497 00498 buf += len + 3; 00499 buflen -= len + 3; 00500 } 00501 00502 // Low level error codes 00503 // 00504 // BEGIN generated code 00505 #if defined(MBEDTLS_AES_C) 00506 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) ) 00507 mbedtls_snprintf( buf, buflen, "AES - Invalid key length" ); 00508 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) ) 00509 mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" ); 00510 #endif /* MBEDTLS_AES_C */ 00511 00512 #if defined(MBEDTLS_ASN1_PARSE_C) 00513 if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) ) 00514 mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); 00515 if( use_ret == -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) ) 00516 mbedtls_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); 00517 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_LENGTH) ) 00518 mbedtls_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); 00519 if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) ) 00520 mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); 00521 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) ) 00522 mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); 00523 if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) ) 00524 mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); 00525 if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) ) 00526 mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); 00527 #endif /* MBEDTLS_ASN1_PARSE_C */ 00528 00529 #if defined(MBEDTLS_BASE64_C) 00530 if( use_ret == -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) ) 00531 mbedtls_snprintf( buf, buflen, "BASE64 - Output buffer too small" ); 00532 if( use_ret == -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER) ) 00533 mbedtls_snprintf( buf, buflen, "BASE64 - Invalid character in input" ); 00534 #endif /* MBEDTLS_BASE64_C */ 00535 00536 #if defined(MBEDTLS_BIGNUM_C) 00537 if( use_ret == -(MBEDTLS_ERR_MPI_FILE_IO_ERROR) ) 00538 mbedtls_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); 00539 if( use_ret == -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA) ) 00540 mbedtls_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); 00541 if( use_ret == -(MBEDTLS_ERR_MPI_INVALID_CHARACTER) ) 00542 mbedtls_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); 00543 if( use_ret == -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL) ) 00544 mbedtls_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); 00545 if( use_ret == -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE) ) 00546 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); 00547 if( use_ret == -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO) ) 00548 mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); 00549 if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) ) 00550 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); 00551 if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) ) 00552 mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); 00553 #endif /* MBEDTLS_BIGNUM_C */ 00554 00555 #if defined(MBEDTLS_BLOWFISH_C) 00556 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) 00557 mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); 00558 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) 00559 mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); 00560 #endif /* MBEDTLS_BLOWFISH_C */ 00561 00562 #if defined(MBEDTLS_CAMELLIA_C) 00563 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) 00564 mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); 00565 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) 00566 mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); 00567 #endif /* MBEDTLS_CAMELLIA_C */ 00568 00569 #if defined(MBEDTLS_CCM_C) 00570 if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) ) 00571 mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to function" ); 00572 if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) ) 00573 mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" ); 00574 #endif /* MBEDTLS_CCM_C */ 00575 00576 #if defined(MBEDTLS_CTR_DRBG_C) 00577 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) 00578 mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); 00579 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) 00580 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); 00581 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) ) 00582 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); 00583 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) ) 00584 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); 00585 #endif /* MBEDTLS_CTR_DRBG_C */ 00586 00587 #if defined(MBEDTLS_DES_C) 00588 if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) ) 00589 mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" ); 00590 #endif /* MBEDTLS_DES_C */ 00591 00592 #if defined(MBEDTLS_ENTROPY_C) 00593 if( use_ret == -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED) ) 00594 mbedtls_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); 00595 if( use_ret == -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES) ) 00596 mbedtls_snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); 00597 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED) ) 00598 mbedtls_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); 00599 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE) ) 00600 mbedtls_snprintf( buf, buflen, "ENTROPY - No strong sources have been added to poll" ); 00601 if( use_ret == -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR) ) 00602 mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); 00603 #endif /* MBEDTLS_ENTROPY_C */ 00604 00605 #if defined(MBEDTLS_GCM_C) 00606 if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) ) 00607 mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); 00608 if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) ) 00609 mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); 00610 #endif /* MBEDTLS_GCM_C */ 00611 00612 #if defined(MBEDTLS_HMAC_DRBG_C) 00613 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) 00614 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); 00615 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) 00616 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); 00617 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR) ) 00618 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); 00619 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) 00620 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); 00621 #endif /* MBEDTLS_HMAC_DRBG_C */ 00622 00623 #if defined(MBEDTLS_NET_C) 00624 if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) ) 00625 mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" ); 00626 if( use_ret == -(MBEDTLS_ERR_NET_CONNECT_FAILED) ) 00627 mbedtls_snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); 00628 if( use_ret == -(MBEDTLS_ERR_NET_BIND_FAILED) ) 00629 mbedtls_snprintf( buf, buflen, "NET - Binding of the socket failed" ); 00630 if( use_ret == -(MBEDTLS_ERR_NET_LISTEN_FAILED) ) 00631 mbedtls_snprintf( buf, buflen, "NET - Could not listen on the socket" ); 00632 if( use_ret == -(MBEDTLS_ERR_NET_ACCEPT_FAILED) ) 00633 mbedtls_snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); 00634 if( use_ret == -(MBEDTLS_ERR_NET_RECV_FAILED) ) 00635 mbedtls_snprintf( buf, buflen, "NET - Reading information from the socket failed" ); 00636 if( use_ret == -(MBEDTLS_ERR_NET_SEND_FAILED) ) 00637 mbedtls_snprintf( buf, buflen, "NET - Sending information through the socket failed" ); 00638 if( use_ret == -(MBEDTLS_ERR_NET_CONN_RESET) ) 00639 mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" ); 00640 if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) ) 00641 mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); 00642 if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) ) 00643 mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" ); 00644 if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) ) 00645 mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" ); 00646 #endif /* MBEDTLS_NET_C */ 00647 00648 #if defined(MBEDTLS_OID_C) 00649 if( use_ret == -(MBEDTLS_ERR_OID_NOT_FOUND) ) 00650 mbedtls_snprintf( buf, buflen, "OID - OID is not found" ); 00651 if( use_ret == -(MBEDTLS_ERR_OID_BUF_TOO_SMALL) ) 00652 mbedtls_snprintf( buf, buflen, "OID - output buffer is too small" ); 00653 #endif /* MBEDTLS_OID_C */ 00654 00655 #if defined(MBEDTLS_PADLOCK_C) 00656 if( use_ret == -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED) ) 00657 mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); 00658 #endif /* MBEDTLS_PADLOCK_C */ 00659 00660 #if defined(MBEDTLS_THREADING_C) 00661 if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) ) 00662 mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" ); 00663 if( use_ret == -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA) ) 00664 mbedtls_snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); 00665 if( use_ret == -(MBEDTLS_ERR_THREADING_MUTEX_ERROR) ) 00666 mbedtls_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); 00667 #endif /* MBEDTLS_THREADING_C */ 00668 00669 #if defined(MBEDTLS_XTEA_C) 00670 if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) ) 00671 mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); 00672 #endif /* MBEDTLS_XTEA_C */ 00673 // END generated code 00674 00675 if( strlen( buf ) != 0 ) 00676 return; 00677 00678 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); 00679 } 00680 00681 #else /* MBEDTLS_ERROR_C */ 00682 00683 #if defined(MBEDTLS_ERROR_STRERROR_DUMMY) 00684 00685 /* 00686 * Provide an non-function in case MBEDTLS_ERROR_C is not defined 00687 */ 00688 void mbedtls_strerror( int ret, char *buf, size_t buflen ) 00689 { 00690 ((void) ret); 00691 00692 if( buflen > 0 ) 00693 buf[0] = '\0'; 00694 } 00695 00696 #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ 00697 00698 #endif /* MBEDTLS_ERROR_C */
Generated on Tue Jul 12 2022 12:52:43 by 1.7.2