7b21f67e4dde458b564a80de0831cce57fd9809e
[reactos.git] / reactos / dll / 3rdparty / mbedtls / error.c
1 /*
2 * Error message information
3 *
4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
5 * SPDX-License-Identifier: GPL-2.0
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * This file is part of mbed TLS (https://tls.mbed.org)
22 */
23
24 #if !defined(MBEDTLS_CONFIG_FILE)
25 #include "mbedtls/config.h"
26 #else
27 #include MBEDTLS_CONFIG_FILE
28 #endif
29
30 #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
31 #include "mbedtls/error.h"
32 #include <string.h>
33 #endif
34
35 #if defined(MBEDTLS_PLATFORM_C)
36 #include "mbedtls/platform.h"
37 #else
38 #define mbedtls_snprintf snprintf
39 #define mbedtls_time_t time_t
40 #endif
41
42 #if defined(MBEDTLS_ERROR_C)
43
44 #include <stdio.h>
45
46 #if defined(MBEDTLS_AES_C)
47 #include "mbedtls/aes.h"
48 #endif
49
50 #if defined(MBEDTLS_BASE64_C)
51 #include "mbedtls/base64.h"
52 #endif
53
54 #if defined(MBEDTLS_BIGNUM_C)
55 #include "mbedtls/bignum.h"
56 #endif
57
58 #if defined(MBEDTLS_BLOWFISH_C)
59 #include "mbedtls/blowfish.h"
60 #endif
61
62 #if defined(MBEDTLS_CAMELLIA_C)
63 #include "mbedtls/camellia.h"
64 #endif
65
66 #if defined(MBEDTLS_CCM_C)
67 #include "mbedtls/ccm.h"
68 #endif
69
70 #if defined(MBEDTLS_CIPHER_C)
71 #include "mbedtls/cipher.h"
72 #endif
73
74 #if defined(MBEDTLS_CTR_DRBG_C)
75 #include "mbedtls/ctr_drbg.h"
76 #endif
77
78 #if defined(MBEDTLS_DES_C)
79 #include "mbedtls/des.h"
80 #endif
81
82 #if defined(MBEDTLS_DHM_C)
83 #include "mbedtls/dhm.h"
84 #endif
85
86 #if defined(MBEDTLS_ECP_C)
87 #include "mbedtls/ecp.h"
88 #endif
89
90 #if defined(MBEDTLS_ENTROPY_C)
91 #include "mbedtls/entropy.h"
92 #endif
93
94 #if defined(MBEDTLS_GCM_C)
95 #include "mbedtls/gcm.h"
96 #endif
97
98 #if defined(MBEDTLS_HMAC_DRBG_C)
99 #include "mbedtls/hmac_drbg.h"
100 #endif
101
102 #if defined(MBEDTLS_MD_C)
103 #include "mbedtls/md.h"
104 #endif
105
106 #if defined(MBEDTLS_NET_C)
107 #include "mbedtls/net.h"
108 #endif
109
110 #if defined(MBEDTLS_OID_C)
111 #include "mbedtls/oid.h"
112 #endif
113
114 #if defined(MBEDTLS_PADLOCK_C)
115 #include "mbedtls/padlock.h"
116 #endif
117
118 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
119 #include "mbedtls/pem.h"
120 #endif
121
122 #if defined(MBEDTLS_PK_C)
123 #include "mbedtls/pk.h"
124 #endif
125
126 #if defined(MBEDTLS_PKCS12_C)
127 #include "mbedtls/pkcs12.h"
128 #endif
129
130 #if defined(MBEDTLS_PKCS5_C)
131 #include "mbedtls/pkcs5.h"
132 #endif
133
134 #if defined(MBEDTLS_RSA_C)
135 #include "mbedtls/rsa.h"
136 #endif
137
138 #if defined(MBEDTLS_SSL_TLS_C)
139 #include "mbedtls/ssl.h"
140 #endif
141
142 #if defined(MBEDTLS_THREADING_C)
143 #include "mbedtls/threading.h"
144 #endif
145
146 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
147 #include "mbedtls/x509.h"
148 #endif
149
150 #if defined(MBEDTLS_XTEA_C)
151 #include "mbedtls/xtea.h"
152 #endif
153
154
155 void mbedtls_strerror( int ret, char *buf, size_t buflen )
156 {
157 size_t len;
158 int use_ret;
159
160 if( buflen == 0 )
161 return;
162
163 memset( buf, 0x00, buflen );
164
165 if( ret < 0 )
166 ret = -ret;
167
168 if( ret & 0xFF80 )
169 {
170 use_ret = ret & 0xFF80;
171
172 // High level error codes
173 //
174 // BEGIN generated code
175 #if defined(MBEDTLS_CIPHER_C)
176 if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) )
177 mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" );
178 if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) )
179 mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" );
180 if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) )
181 mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" );
182 if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) )
183 mbedtls_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" );
184 if( use_ret == -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED) )
185 mbedtls_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" );
186 if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) )
187 mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" );
188 if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT) )
189 mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid, eg because it was free()ed" );
190 #endif /* MBEDTLS_CIPHER_C */
191
192 #if defined(MBEDTLS_DHM_C)
193 if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) )
194 mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters to function" );
195 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) )
196 mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" );
197 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) )
198 mbedtls_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" );
199 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED) )
200 mbedtls_snprintf( buf, buflen, "DHM - Reading of the public values failed" );
201 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED) )
202 mbedtls_snprintf( buf, buflen, "DHM - Making of the public value failed" );
203 if( use_ret == -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED) )
204 mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" );
205 if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) )
206 mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" );
207 if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) )
208 mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" );
209 if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) )
210 mbedtls_snprintf( buf, buflen, "DHM - Read/write of file failed" );
211 #endif /* MBEDTLS_DHM_C */
212
213 #if defined(MBEDTLS_ECP_C)
214 if( use_ret == -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA) )
215 mbedtls_snprintf( buf, buflen, "ECP - Bad input parameters to function" );
216 if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) )
217 mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" );
218 if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) )
219 mbedtls_snprintf( buf, buflen, "ECP - Requested curve not available" );
220 if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) )
221 mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" );
222 if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) )
223 mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" );
224 if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) )
225 mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" );
226 if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) )
227 mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" );
228 if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) )
229 mbedtls_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" );
230 #endif /* MBEDTLS_ECP_C */
231
232 #if defined(MBEDTLS_MD_C)
233 if( use_ret == -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE) )
234 mbedtls_snprintf( buf, buflen, "MD - The selected feature is not available" );
235 if( use_ret == -(MBEDTLS_ERR_MD_BAD_INPUT_DATA) )
236 mbedtls_snprintf( buf, buflen, "MD - Bad input parameters to function" );
237 if( use_ret == -(MBEDTLS_ERR_MD_ALLOC_FAILED) )
238 mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" );
239 if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) )
240 mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" );
241 #endif /* MBEDTLS_MD_C */
242
243 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
244 if( use_ret == -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) )
245 mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" );
246 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) )
247 mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" );
248 if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) )
249 mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" );
250 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) )
251 mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" );
252 if( use_ret == -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG) )
253 mbedtls_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" );
254 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED) )
255 mbedtls_snprintf( buf, buflen, "PEM - Private key password can't be empty" );
256 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH) )
257 mbedtls_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" );
258 if( use_ret == -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE) )
259 mbedtls_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" );
260 if( use_ret == -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA) )
261 mbedtls_snprintf( buf, buflen, "PEM - Bad input parameters to function" );
262 #endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
263
264 #if defined(MBEDTLS_PK_C)
265 if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) )
266 mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" );
267 if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) )
268 mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
269 if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) )
270 mbedtls_snprintf( buf, buflen, "PK - Bad input parameters to function" );
271 if( use_ret == -(MBEDTLS_ERR_PK_FILE_IO_ERROR) )
272 mbedtls_snprintf( buf, buflen, "PK - Read/write of file failed" );
273 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION) )
274 mbedtls_snprintf( buf, buflen, "PK - Unsupported key version" );
275 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT) )
276 mbedtls_snprintf( buf, buflen, "PK - Invalid key tag or value" );
277 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG) )
278 mbedtls_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
279 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED) )
280 mbedtls_snprintf( buf, buflen, "PK - Private key password can't be empty" );
281 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH) )
282 mbedtls_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" );
283 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_PUBKEY) )
284 mbedtls_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
285 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_ALG) )
286 mbedtls_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" );
287 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE) )
288 mbedtls_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
289 if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) )
290 mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
291 if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) )
292 mbedtls_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" );
293 #endif /* MBEDTLS_PK_C */
294
295 #if defined(MBEDTLS_PKCS12_C)
296 if( use_ret == -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA) )
297 mbedtls_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" );
298 if( use_ret == -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE) )
299 mbedtls_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
300 if( use_ret == -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT) )
301 mbedtls_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" );
302 if( use_ret == -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) )
303 mbedtls_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" );
304 #endif /* MBEDTLS_PKCS12_C */
305
306 #if defined(MBEDTLS_PKCS5_C)
307 if( use_ret == -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA) )
308 mbedtls_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" );
309 if( use_ret == -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT) )
310 mbedtls_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" );
311 if( use_ret == -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE) )
312 mbedtls_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" );
313 if( use_ret == -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH) )
314 mbedtls_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" );
315 #endif /* MBEDTLS_PKCS5_C */
316
317 #if defined(MBEDTLS_RSA_C)
318 if( use_ret == -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA) )
319 mbedtls_snprintf( buf, buflen, "RSA - Bad input parameters to function" );
320 if( use_ret == -(MBEDTLS_ERR_RSA_INVALID_PADDING) )
321 mbedtls_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" );
322 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) )
323 mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" );
324 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) )
325 mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" );
326 if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) )
327 mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" );
328 if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) )
329 mbedtls_snprintf( buf, buflen, "RSA - The private key operation failed" );
330 if( use_ret == -(MBEDTLS_ERR_RSA_VERIFY_FAILED) )
331 mbedtls_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" );
332 if( use_ret == -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE) )
333 mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" );
334 if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) )
335 mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" );
336 #endif /* MBEDTLS_RSA_C */
337
338 #if defined(MBEDTLS_SSL_TLS_C)
339 if( use_ret == -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) )
340 mbedtls_snprintf( buf, buflen, "SSL - The requested feature is not available" );
341 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA) )
342 mbedtls_snprintf( buf, buflen, "SSL - Bad input parameters to function" );
343 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_MAC) )
344 mbedtls_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" );
345 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_RECORD) )
346 mbedtls_snprintf( buf, buflen, "SSL - An invalid SSL record was received" );
347 if( use_ret == -(MBEDTLS_ERR_SSL_CONN_EOF) )
348 mbedtls_snprintf( buf, buflen, "SSL - The connection indicated an EOF" );
349 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER) )
350 mbedtls_snprintf( buf, buflen, "SSL - An unknown cipher was received" );
351 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN) )
352 mbedtls_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" );
353 if( use_ret == -(MBEDTLS_ERR_SSL_NO_RNG) )
354 mbedtls_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" );
355 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE) )
356 mbedtls_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" );
357 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE) )
358 mbedtls_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" );
359 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED) )
360 mbedtls_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" );
361 if( use_ret == -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED) )
362 mbedtls_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" );
363 if( use_ret == -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) )
364 mbedtls_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" );
365 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) )
366 mbedtls_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" );
367 if( use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) )
368 {
369 mbedtls_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" );
370 return;
371 }
372 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED) )
373 mbedtls_snprintf( buf, buflen, "SSL - Verification of our peer failed" );
374 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) )
375 mbedtls_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" );
376 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO) )
377 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" );
378 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO) )
379 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" );
380 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE) )
381 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" );
382 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) )
383 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" );
384 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) )
385 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" );
386 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) )
387 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" );
388 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) )
389 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" );
390 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) )
391 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" );
392 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) )
393 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" );
394 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) )
395 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" );
396 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) )
397 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" );
398 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) )
399 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" );
400 if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) )
401 mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" );
402 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) )
403 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" );
404 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH) )
405 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" );
406 if( use_ret == -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED) )
407 mbedtls_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" );
408 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION) )
409 mbedtls_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" );
410 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) )
411 mbedtls_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" );
412 if( use_ret == -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED) )
413 mbedtls_snprintf( buf, buflen, "SSL - Session ticket has expired" );
414 if( use_ret == -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH) )
415 mbedtls_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
416 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY) )
417 mbedtls_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" );
418 if( use_ret == -(MBEDTLS_ERR_SSL_INTERNAL_ERROR) )
419 mbedtls_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" );
420 if( use_ret == -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING) )
421 mbedtls_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" );
422 if( use_ret == -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) )
423 mbedtls_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" );
424 if( use_ret == -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) )
425 mbedtls_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" );
426 if( use_ret == -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) )
427 mbedtls_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" );
428 if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) )
429 mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" );
430 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) )
431 mbedtls_snprintf( buf, buflen, "SSL - Connection requires a read call" );
432 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) )
433 mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" );
434 if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) )
435 mbedtls_snprintf( buf, buflen, "SSL - The operation timed out" );
436 if( use_ret == -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT) )
437 mbedtls_snprintf( buf, buflen, "SSL - The client initiated a reconnect from the same port" );
438 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD) )
439 mbedtls_snprintf( buf, buflen, "SSL - Record header looks valid but is not expected" );
440 #endif /* MBEDTLS_SSL_TLS_C */
441
442 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
443 if( use_ret == -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE) )
444 mbedtls_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
445 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_OID) )
446 mbedtls_snprintf( buf, buflen, "X509 - Requested OID is unknown" );
447 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_FORMAT) )
448 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
449 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_VERSION) )
450 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" );
451 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SERIAL) )
452 mbedtls_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" );
453 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_ALG) )
454 mbedtls_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" );
455 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_NAME) )
456 mbedtls_snprintf( buf, buflen, "X509 - The name tag or value is invalid" );
457 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_DATE) )
458 mbedtls_snprintf( buf, buflen, "X509 - The date tag or value is invalid" );
459 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SIGNATURE) )
460 mbedtls_snprintf( buf, buflen, "X509 - The signature tag or value invalid" );
461 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS) )
462 mbedtls_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" );
463 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_VERSION) )
464 mbedtls_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" );
465 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG) )
466 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" );
467 if( use_ret == -(MBEDTLS_ERR_X509_SIG_MISMATCH) )
468 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" );
469 if( use_ret == -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) )
470 mbedtls_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
471 if( use_ret == -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT) )
472 mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" );
473 if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) )
474 mbedtls_snprintf( buf, buflen, "X509 - Input invalid" );
475 if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) )
476 mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" );
477 if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) )
478 mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" );
479 if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) )
480 mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" );
481 #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
482 // END generated code
483
484 if( strlen( buf ) == 0 )
485 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
486 }
487
488 use_ret = ret & ~0xFF80;
489
490 if( use_ret == 0 )
491 return;
492
493 // If high level code is present, make a concatenation between both
494 // error strings.
495 //
496 len = strlen( buf );
497
498 if( len > 0 )
499 {
500 if( buflen - len < 5 )
501 return;
502
503 mbedtls_snprintf( buf + len, buflen - len, " : " );
504
505 buf += len + 3;
506 buflen -= len + 3;
507 }
508
509 // Low level error codes
510 //
511 // BEGIN generated code
512 #if defined(MBEDTLS_AES_C)
513 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) )
514 mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
515 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) )
516 mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" );
517 #endif /* MBEDTLS_AES_C */
518
519 #if defined(MBEDTLS_ASN1_PARSE_C)
520 if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) )
521 mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" );
522 if( use_ret == -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) )
523 mbedtls_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" );
524 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_LENGTH) )
525 mbedtls_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" );
526 if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) )
527 mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
528 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) )
529 mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" );
530 if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) )
531 mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
532 if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) )
533 mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" );
534 #endif /* MBEDTLS_ASN1_PARSE_C */
535
536 #if defined(MBEDTLS_BASE64_C)
537 if( use_ret == -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) )
538 mbedtls_snprintf( buf, buflen, "BASE64 - Output buffer too small" );
539 if( use_ret == -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER) )
540 mbedtls_snprintf( buf, buflen, "BASE64 - Invalid character in input" );
541 #endif /* MBEDTLS_BASE64_C */
542
543 #if defined(MBEDTLS_BIGNUM_C)
544 if( use_ret == -(MBEDTLS_ERR_MPI_FILE_IO_ERROR) )
545 mbedtls_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" );
546 if( use_ret == -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA) )
547 mbedtls_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" );
548 if( use_ret == -(MBEDTLS_ERR_MPI_INVALID_CHARACTER) )
549 mbedtls_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" );
550 if( use_ret == -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL) )
551 mbedtls_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" );
552 if( use_ret == -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE) )
553 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" );
554 if( use_ret == -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO) )
555 mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" );
556 if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) )
557 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" );
558 if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) )
559 mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" );
560 #endif /* MBEDTLS_BIGNUM_C */
561
562 #if defined(MBEDTLS_BLOWFISH_C)
563 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) )
564 mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" );
565 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) )
566 mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" );
567 #endif /* MBEDTLS_BLOWFISH_C */
568
569 #if defined(MBEDTLS_CAMELLIA_C)
570 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH) )
571 mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" );
572 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) )
573 mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
574 #endif /* MBEDTLS_CAMELLIA_C */
575
576 #if defined(MBEDTLS_CCM_C)
577 if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) )
578 mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to function" );
579 if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) )
580 mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
581 #endif /* MBEDTLS_CCM_C */
582
583 #if defined(MBEDTLS_CTR_DRBG_C)
584 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) )
585 mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );
586 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) )
587 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" );
588 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) )
589 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" );
590 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) )
591 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" );
592 #endif /* MBEDTLS_CTR_DRBG_C */
593
594 #if defined(MBEDTLS_DES_C)
595 if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) )
596 mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" );
597 #endif /* MBEDTLS_DES_C */
598
599 #if defined(MBEDTLS_ENTROPY_C)
600 if( use_ret == -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED) )
601 mbedtls_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" );
602 if( use_ret == -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES) )
603 mbedtls_snprintf( buf, buflen, "ENTROPY - No more sources can be added" );
604 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED) )
605 mbedtls_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" );
606 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE) )
607 mbedtls_snprintf( buf, buflen, "ENTROPY - No strong sources have been added to poll" );
608 if( use_ret == -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR) )
609 mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" );
610 #endif /* MBEDTLS_ENTROPY_C */
611
612 #if defined(MBEDTLS_GCM_C)
613 if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) )
614 mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" );
615 if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) )
616 mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" );
617 #endif /* MBEDTLS_GCM_C */
618
619 #if defined(MBEDTLS_HMAC_DRBG_C)
620 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) )
621 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" );
622 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG) )
623 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" );
624 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR) )
625 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" );
626 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) )
627 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
628 #endif /* MBEDTLS_HMAC_DRBG_C */
629
630 #if defined(MBEDTLS_NET_C)
631 if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) )
632 mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" );
633 if( use_ret == -(MBEDTLS_ERR_NET_CONNECT_FAILED) )
634 mbedtls_snprintf( buf, buflen, "NET - The connection to the given server / port failed" );
635 if( use_ret == -(MBEDTLS_ERR_NET_BIND_FAILED) )
636 mbedtls_snprintf( buf, buflen, "NET - Binding of the socket failed" );
637 if( use_ret == -(MBEDTLS_ERR_NET_LISTEN_FAILED) )
638 mbedtls_snprintf( buf, buflen, "NET - Could not listen on the socket" );
639 if( use_ret == -(MBEDTLS_ERR_NET_ACCEPT_FAILED) )
640 mbedtls_snprintf( buf, buflen, "NET - Could not accept the incoming connection" );
641 if( use_ret == -(MBEDTLS_ERR_NET_RECV_FAILED) )
642 mbedtls_snprintf( buf, buflen, "NET - Reading information from the socket failed" );
643 if( use_ret == -(MBEDTLS_ERR_NET_SEND_FAILED) )
644 mbedtls_snprintf( buf, buflen, "NET - Sending information through the socket failed" );
645 if( use_ret == -(MBEDTLS_ERR_NET_CONN_RESET) )
646 mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" );
647 if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) )
648 mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" );
649 if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) )
650 mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" );
651 if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) )
652 mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" );
653 #endif /* MBEDTLS_NET_C */
654
655 #if defined(MBEDTLS_OID_C)
656 if( use_ret == -(MBEDTLS_ERR_OID_NOT_FOUND) )
657 mbedtls_snprintf( buf, buflen, "OID - OID is not found" );
658 if( use_ret == -(MBEDTLS_ERR_OID_BUF_TOO_SMALL) )
659 mbedtls_snprintf( buf, buflen, "OID - output buffer is too small" );
660 #endif /* MBEDTLS_OID_C */
661
662 #if defined(MBEDTLS_PADLOCK_C)
663 if( use_ret == -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED) )
664 mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
665 #endif /* MBEDTLS_PADLOCK_C */
666
667 #if defined(MBEDTLS_THREADING_C)
668 if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) )
669 mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" );
670 if( use_ret == -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA) )
671 mbedtls_snprintf( buf, buflen, "THREADING - Bad input parameters to function" );
672 if( use_ret == -(MBEDTLS_ERR_THREADING_MUTEX_ERROR) )
673 mbedtls_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" );
674 #endif /* MBEDTLS_THREADING_C */
675
676 #if defined(MBEDTLS_XTEA_C)
677 if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) )
678 mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" );
679 #endif /* MBEDTLS_XTEA_C */
680 // END generated code
681
682 if( strlen( buf ) != 0 )
683 return;
684
685 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
686 }
687
688 #else /* MBEDTLS_ERROR_C */
689
690 #if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
691
692 /*
693 * Provide an non-function in case MBEDTLS_ERROR_C is not defined
694 */
695 void mbedtls_strerror( int ret, char *buf, size_t buflen )
696 {
697 ((void) ret);
698
699 if( buflen > 0 )
700 buf[0] = '\0';
701 }
702
703 #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */
704
705 #endif /* MBEDTLS_ERROR_C */