mbed TLS Build

Dependents:   Encrypt_Decrypt1 mbed_blink_tls encrypt encrypt

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

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