I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X

Dependencies:   WncControllerK64F

Committer:
JMF
Date:
Thu Nov 17 16:13:29 2016 +0000
Revision:
18:198e9b0acf11
Parent:
12:0071cb144c7a
Updates to mbed os resulted in mutex.h going away and rtos.h needed to be used; This fixes the Mutex typedef failure.  Also cast data buffers from 'char *' to (const std::uint8_t*) to conform with Fred's changes in WncController

Who changed what in which revision?

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