mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /*
kenjiArai 0:5b88d5760320 2 * Error message information
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
kenjiArai 0:5b88d5760320 5 * SPDX-License-Identifier: Apache-2.0
kenjiArai 0:5b88d5760320 6 *
kenjiArai 0:5b88d5760320 7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
kenjiArai 0:5b88d5760320 8 * not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 9 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 10 *
kenjiArai 0:5b88d5760320 11 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 12 *
kenjiArai 0:5b88d5760320 13 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
kenjiArai 0:5b88d5760320 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 16 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 17 * limitations under the License.
kenjiArai 0:5b88d5760320 18 *
kenjiArai 0:5b88d5760320 19 * This file is part of mbed TLS (https://tls.mbed.org)
kenjiArai 0:5b88d5760320 20 */
kenjiArai 0:5b88d5760320 21
kenjiArai 0:5b88d5760320 22 #if !defined(MBEDTLS_CONFIG_FILE)
kenjiArai 0:5b88d5760320 23 #include "mbedtls/config.h"
kenjiArai 0:5b88d5760320 24 #else
kenjiArai 0:5b88d5760320 25 #include MBEDTLS_CONFIG_FILE
kenjiArai 0:5b88d5760320 26 #endif
kenjiArai 0:5b88d5760320 27
kenjiArai 0:5b88d5760320 28 #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
kenjiArai 0:5b88d5760320 29 #include "mbedtls/error.h"
kenjiArai 0:5b88d5760320 30 #include <string.h>
kenjiArai 0:5b88d5760320 31 #endif
kenjiArai 0:5b88d5760320 32
kenjiArai 0:5b88d5760320 33 #if defined(MBEDTLS_PLATFORM_C)
kenjiArai 0:5b88d5760320 34 #include "mbedtls/platform.h"
kenjiArai 0:5b88d5760320 35 #else
kenjiArai 0:5b88d5760320 36 #define mbedtls_snprintf snprintf
kenjiArai 0:5b88d5760320 37 #define mbedtls_time_t time_t
kenjiArai 0:5b88d5760320 38 #endif
kenjiArai 0:5b88d5760320 39
kenjiArai 0:5b88d5760320 40 #if defined(MBEDTLS_ERROR_C)
kenjiArai 0:5b88d5760320 41
kenjiArai 0:5b88d5760320 42 #include <stdio.h>
kenjiArai 0:5b88d5760320 43
kenjiArai 0:5b88d5760320 44 #if defined(MBEDTLS_AES_C)
kenjiArai 0:5b88d5760320 45 #include "mbedtls/aes.h"
kenjiArai 0:5b88d5760320 46 #endif
kenjiArai 0:5b88d5760320 47
kenjiArai 0:5b88d5760320 48 #if defined(MBEDTLS_ARC4_C)
kenjiArai 0:5b88d5760320 49 #include "mbedtls/arc4.h"
kenjiArai 0:5b88d5760320 50 #endif
kenjiArai 0:5b88d5760320 51
kenjiArai 0:5b88d5760320 52 #if defined(MBEDTLS_ARIA_C)
kenjiArai 0:5b88d5760320 53 #include "mbedtls/aria.h"
kenjiArai 0:5b88d5760320 54 #endif
kenjiArai 0:5b88d5760320 55
kenjiArai 0:5b88d5760320 56 #if defined(MBEDTLS_BASE64_C)
kenjiArai 0:5b88d5760320 57 #include "mbedtls/base64.h"
kenjiArai 0:5b88d5760320 58 #endif
kenjiArai 0:5b88d5760320 59
kenjiArai 0:5b88d5760320 60 #if defined(MBEDTLS_BIGNUM_C)
kenjiArai 0:5b88d5760320 61 #include "mbedtls/bignum.h"
kenjiArai 0:5b88d5760320 62 #endif
kenjiArai 0:5b88d5760320 63
kenjiArai 0:5b88d5760320 64 #if defined(MBEDTLS_BLOWFISH_C)
kenjiArai 0:5b88d5760320 65 #include "mbedtls/blowfish.h"
kenjiArai 0:5b88d5760320 66 #endif
kenjiArai 0:5b88d5760320 67
kenjiArai 0:5b88d5760320 68 #if defined(MBEDTLS_CAMELLIA_C)
kenjiArai 0:5b88d5760320 69 #include "mbedtls/camellia.h"
kenjiArai 0:5b88d5760320 70 #endif
kenjiArai 0:5b88d5760320 71
kenjiArai 0:5b88d5760320 72 #if defined(MBEDTLS_CCM_C)
kenjiArai 0:5b88d5760320 73 #include "mbedtls/ccm.h"
kenjiArai 0:5b88d5760320 74 #endif
kenjiArai 0:5b88d5760320 75
kenjiArai 0:5b88d5760320 76 #if defined(MBEDTLS_CHACHA20_C)
kenjiArai 0:5b88d5760320 77 #include "mbedtls/chacha20.h"
kenjiArai 0:5b88d5760320 78 #endif
kenjiArai 0:5b88d5760320 79
kenjiArai 0:5b88d5760320 80 #if defined(MBEDTLS_CHACHAPOLY_C)
kenjiArai 0:5b88d5760320 81 #include "mbedtls/chachapoly.h"
kenjiArai 0:5b88d5760320 82 #endif
kenjiArai 0:5b88d5760320 83
kenjiArai 0:5b88d5760320 84 #if defined(MBEDTLS_CIPHER_C)
kenjiArai 0:5b88d5760320 85 #include "mbedtls/cipher.h"
kenjiArai 0:5b88d5760320 86 #endif
kenjiArai 0:5b88d5760320 87
kenjiArai 0:5b88d5760320 88 #if defined(MBEDTLS_CMAC_C)
kenjiArai 0:5b88d5760320 89 #include "mbedtls/cmac.h"
kenjiArai 0:5b88d5760320 90 #endif
kenjiArai 0:5b88d5760320 91
kenjiArai 0:5b88d5760320 92 #if defined(MBEDTLS_CTR_DRBG_C)
kenjiArai 0:5b88d5760320 93 #include "mbedtls/ctr_drbg.h"
kenjiArai 0:5b88d5760320 94 #endif
kenjiArai 0:5b88d5760320 95
kenjiArai 0:5b88d5760320 96 #if defined(MBEDTLS_DES_C)
kenjiArai 0:5b88d5760320 97 #include "mbedtls/des.h"
kenjiArai 0:5b88d5760320 98 #endif
kenjiArai 0:5b88d5760320 99
kenjiArai 0:5b88d5760320 100 #if defined(MBEDTLS_DHM_C)
kenjiArai 0:5b88d5760320 101 #include "mbedtls/dhm.h"
kenjiArai 0:5b88d5760320 102 #endif
kenjiArai 0:5b88d5760320 103
kenjiArai 0:5b88d5760320 104 #if defined(MBEDTLS_ECP_C)
kenjiArai 0:5b88d5760320 105 #include "mbedtls/ecp.h"
kenjiArai 0:5b88d5760320 106 #endif
kenjiArai 0:5b88d5760320 107
kenjiArai 0:5b88d5760320 108 #if defined(MBEDTLS_ENTROPY_C)
kenjiArai 0:5b88d5760320 109 #include "mbedtls/entropy.h"
kenjiArai 0:5b88d5760320 110 #endif
kenjiArai 0:5b88d5760320 111
kenjiArai 0:5b88d5760320 112 #if defined(MBEDTLS_GCM_C)
kenjiArai 0:5b88d5760320 113 #include "mbedtls/gcm.h"
kenjiArai 0:5b88d5760320 114 #endif
kenjiArai 0:5b88d5760320 115
kenjiArai 0:5b88d5760320 116 #if defined(MBEDTLS_HKDF_C)
kenjiArai 0:5b88d5760320 117 #include "mbedtls/hkdf.h"
kenjiArai 0:5b88d5760320 118 #endif
kenjiArai 0:5b88d5760320 119
kenjiArai 0:5b88d5760320 120 #if defined(MBEDTLS_HMAC_DRBG_C)
kenjiArai 0:5b88d5760320 121 #include "mbedtls/hmac_drbg.h"
kenjiArai 0:5b88d5760320 122 #endif
kenjiArai 0:5b88d5760320 123
kenjiArai 0:5b88d5760320 124 #if defined(MBEDTLS_MD_C)
kenjiArai 0:5b88d5760320 125 #include "mbedtls/md.h"
kenjiArai 0:5b88d5760320 126 #endif
kenjiArai 0:5b88d5760320 127
kenjiArai 0:5b88d5760320 128 #if defined(MBEDTLS_MD2_C)
kenjiArai 0:5b88d5760320 129 #include "mbedtls/md2.h"
kenjiArai 0:5b88d5760320 130 #endif
kenjiArai 0:5b88d5760320 131
kenjiArai 0:5b88d5760320 132 #if defined(MBEDTLS_MD4_C)
kenjiArai 0:5b88d5760320 133 #include "mbedtls/md4.h"
kenjiArai 0:5b88d5760320 134 #endif
kenjiArai 0:5b88d5760320 135
kenjiArai 0:5b88d5760320 136 #if defined(MBEDTLS_MD5_C)
kenjiArai 0:5b88d5760320 137 #include "mbedtls/md5.h"
kenjiArai 0:5b88d5760320 138 #endif
kenjiArai 0:5b88d5760320 139
kenjiArai 0:5b88d5760320 140 #if defined(MBEDTLS_OID_C)
kenjiArai 0:5b88d5760320 141 #include "mbedtls/oid.h"
kenjiArai 0:5b88d5760320 142 #endif
kenjiArai 0:5b88d5760320 143
kenjiArai 0:5b88d5760320 144 #if defined(MBEDTLS_PADLOCK_C)
kenjiArai 0:5b88d5760320 145 #include "mbedtls/padlock.h"
kenjiArai 0:5b88d5760320 146 #endif
kenjiArai 0:5b88d5760320 147
kenjiArai 0:5b88d5760320 148 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
kenjiArai 0:5b88d5760320 149 #include "mbedtls/pem.h"
kenjiArai 0:5b88d5760320 150 #endif
kenjiArai 0:5b88d5760320 151
kenjiArai 0:5b88d5760320 152 #if defined(MBEDTLS_PK_C)
kenjiArai 0:5b88d5760320 153 #include "mbedtls/pk.h"
kenjiArai 0:5b88d5760320 154 #endif
kenjiArai 0:5b88d5760320 155
kenjiArai 0:5b88d5760320 156 #if defined(MBEDTLS_PKCS12_C)
kenjiArai 0:5b88d5760320 157 #include "mbedtls/pkcs12.h"
kenjiArai 0:5b88d5760320 158 #endif
kenjiArai 0:5b88d5760320 159
kenjiArai 0:5b88d5760320 160 #if defined(MBEDTLS_PKCS5_C)
kenjiArai 0:5b88d5760320 161 #include "mbedtls/pkcs5.h"
kenjiArai 0:5b88d5760320 162 #endif
kenjiArai 0:5b88d5760320 163
kenjiArai 0:5b88d5760320 164 #if defined(MBEDTLS_PLATFORM_C)
kenjiArai 0:5b88d5760320 165 #include "mbedtls/platform.h"
kenjiArai 0:5b88d5760320 166 #endif
kenjiArai 0:5b88d5760320 167
kenjiArai 0:5b88d5760320 168 #if defined(MBEDTLS_POLY1305_C)
kenjiArai 0:5b88d5760320 169 #include "mbedtls/poly1305.h"
kenjiArai 0:5b88d5760320 170 #endif
kenjiArai 0:5b88d5760320 171
kenjiArai 0:5b88d5760320 172 #if defined(MBEDTLS_RIPEMD160_C)
kenjiArai 0:5b88d5760320 173 #include "mbedtls/ripemd160.h"
kenjiArai 0:5b88d5760320 174 #endif
kenjiArai 0:5b88d5760320 175
kenjiArai 0:5b88d5760320 176 #if defined(MBEDTLS_RSA_C)
kenjiArai 0:5b88d5760320 177 #include "mbedtls/rsa.h"
kenjiArai 0:5b88d5760320 178 #endif
kenjiArai 0:5b88d5760320 179
kenjiArai 0:5b88d5760320 180 #if defined(MBEDTLS_SHA1_C)
kenjiArai 0:5b88d5760320 181 #include "mbedtls/sha1.h"
kenjiArai 0:5b88d5760320 182 #endif
kenjiArai 0:5b88d5760320 183
kenjiArai 0:5b88d5760320 184 #if defined(MBEDTLS_SHA256_C)
kenjiArai 0:5b88d5760320 185 #include "mbedtls/sha256.h"
kenjiArai 0:5b88d5760320 186 #endif
kenjiArai 0:5b88d5760320 187
kenjiArai 0:5b88d5760320 188 #if defined(MBEDTLS_SHA512_C)
kenjiArai 0:5b88d5760320 189 #include "mbedtls/sha512.h"
kenjiArai 0:5b88d5760320 190 #endif
kenjiArai 0:5b88d5760320 191
kenjiArai 0:5b88d5760320 192 #if defined(MBEDTLS_THREADING_C)
kenjiArai 0:5b88d5760320 193 #include "mbedtls/threading.h"
kenjiArai 0:5b88d5760320 194 #endif
kenjiArai 0:5b88d5760320 195
kenjiArai 0:5b88d5760320 196 #if defined(MBEDTLS_XTEA_C)
kenjiArai 0:5b88d5760320 197 #include "mbedtls/xtea.h"
kenjiArai 0:5b88d5760320 198 #endif
kenjiArai 0:5b88d5760320 199
kenjiArai 0:5b88d5760320 200 #if defined(MBEDTLS_NET_C)
kenjiArai 0:5b88d5760320 201 #include "mbedtls/net_sockets.h"
kenjiArai 0:5b88d5760320 202 #endif
kenjiArai 0:5b88d5760320 203
kenjiArai 0:5b88d5760320 204 #if defined(MBEDTLS_SSL_TLS_C)
kenjiArai 0:5b88d5760320 205 #include "mbedtls/ssl.h"
kenjiArai 0:5b88d5760320 206 #endif
kenjiArai 0:5b88d5760320 207
kenjiArai 0:5b88d5760320 208 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
kenjiArai 0:5b88d5760320 209 #include "mbedtls/x509.h"
kenjiArai 0:5b88d5760320 210 #endif
kenjiArai 0:5b88d5760320 211
kenjiArai 0:5b88d5760320 212
kenjiArai 0:5b88d5760320 213 void mbedtls_strerror( int ret, char *buf, size_t buflen )
kenjiArai 0:5b88d5760320 214 {
kenjiArai 0:5b88d5760320 215 size_t len;
kenjiArai 0:5b88d5760320 216 int use_ret;
kenjiArai 0:5b88d5760320 217
kenjiArai 0:5b88d5760320 218 if( buflen == 0 )
kenjiArai 0:5b88d5760320 219 return;
kenjiArai 0:5b88d5760320 220
kenjiArai 0:5b88d5760320 221 memset( buf, 0x00, buflen );
kenjiArai 0:5b88d5760320 222
kenjiArai 0:5b88d5760320 223 if( ret < 0 )
kenjiArai 0:5b88d5760320 224 ret = -ret;
kenjiArai 0:5b88d5760320 225
kenjiArai 0:5b88d5760320 226 if( ret & 0xFF80 )
kenjiArai 0:5b88d5760320 227 {
kenjiArai 0:5b88d5760320 228 use_ret = ret & 0xFF80;
kenjiArai 0:5b88d5760320 229
kenjiArai 0:5b88d5760320 230 // High level error codes
kenjiArai 0:5b88d5760320 231 //
kenjiArai 0:5b88d5760320 232 // BEGIN generated code
kenjiArai 0:5b88d5760320 233 #if defined(MBEDTLS_CIPHER_C)
kenjiArai 0:5b88d5760320 234 if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 235 mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" );
kenjiArai 0:5b88d5760320 236 if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 237 mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters" );
kenjiArai 0:5b88d5760320 238 if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 239 mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" );
kenjiArai 0:5b88d5760320 240 if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) )
kenjiArai 0:5b88d5760320 241 mbedtls_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" );
kenjiArai 0:5b88d5760320 242 if( use_ret == -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED) )
kenjiArai 0:5b88d5760320 243 mbedtls_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" );
kenjiArai 0:5b88d5760320 244 if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) )
kenjiArai 0:5b88d5760320 245 mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" );
kenjiArai 0:5b88d5760320 246 if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT) )
kenjiArai 0:5b88d5760320 247 mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid. For example, because it was freed" );
kenjiArai 0:5b88d5760320 248 if( use_ret == -(MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 249 mbedtls_snprintf( buf, buflen, "CIPHER - Cipher hardware accelerator failed" );
kenjiArai 0:5b88d5760320 250 #endif /* MBEDTLS_CIPHER_C */
kenjiArai 0:5b88d5760320 251
kenjiArai 0:5b88d5760320 252 #if defined(MBEDTLS_DHM_C)
kenjiArai 0:5b88d5760320 253 if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 254 mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters" );
kenjiArai 0:5b88d5760320 255 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) )
kenjiArai 0:5b88d5760320 256 mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" );
kenjiArai 0:5b88d5760320 257 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) )
kenjiArai 0:5b88d5760320 258 mbedtls_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" );
kenjiArai 0:5b88d5760320 259 if( use_ret == -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED) )
kenjiArai 0:5b88d5760320 260 mbedtls_snprintf( buf, buflen, "DHM - Reading of the public values failed" );
kenjiArai 0:5b88d5760320 261 if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED) )
kenjiArai 0:5b88d5760320 262 mbedtls_snprintf( buf, buflen, "DHM - Making of the public value failed" );
kenjiArai 0:5b88d5760320 263 if( use_ret == -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED) )
kenjiArai 0:5b88d5760320 264 mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" );
kenjiArai 0:5b88d5760320 265 if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) )
kenjiArai 0:5b88d5760320 266 mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" );
kenjiArai 0:5b88d5760320 267 if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 268 mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" );
kenjiArai 0:5b88d5760320 269 if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 270 mbedtls_snprintf( buf, buflen, "DHM - Read or write of file failed" );
kenjiArai 0:5b88d5760320 271 if( use_ret == -(MBEDTLS_ERR_DHM_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 272 mbedtls_snprintf( buf, buflen, "DHM - DHM hardware accelerator failed" );
kenjiArai 0:5b88d5760320 273 if( use_ret == -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED) )
kenjiArai 0:5b88d5760320 274 mbedtls_snprintf( buf, buflen, "DHM - Setting the modulus and generator failed" );
kenjiArai 0:5b88d5760320 275 #endif /* MBEDTLS_DHM_C */
kenjiArai 0:5b88d5760320 276
kenjiArai 0:5b88d5760320 277 #if defined(MBEDTLS_ECP_C)
kenjiArai 0:5b88d5760320 278 if( use_ret == -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 279 mbedtls_snprintf( buf, buflen, "ECP - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 280 if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 281 mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" );
kenjiArai 0:5b88d5760320 282 if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 283 mbedtls_snprintf( buf, buflen, "ECP - The requested feature is not available, for example, the requested curve is not supported" );
kenjiArai 0:5b88d5760320 284 if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) )
kenjiArai 0:5b88d5760320 285 mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" );
kenjiArai 0:5b88d5760320 286 if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 287 mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" );
kenjiArai 0:5b88d5760320 288 if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) )
kenjiArai 0:5b88d5760320 289 mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as ephemeral key, failed" );
kenjiArai 0:5b88d5760320 290 if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) )
kenjiArai 0:5b88d5760320 291 mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" );
kenjiArai 0:5b88d5760320 292 if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) )
kenjiArai 0:5b88d5760320 293 mbedtls_snprintf( buf, buflen, "ECP - The buffer contains a valid signature followed by more data" );
kenjiArai 0:5b88d5760320 294 if( use_ret == -(MBEDTLS_ERR_ECP_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 295 mbedtls_snprintf( buf, buflen, "ECP - The ECP hardware accelerator failed" );
kenjiArai 0:5b88d5760320 296 if( use_ret == -(MBEDTLS_ERR_ECP_IN_PROGRESS) )
kenjiArai 0:5b88d5760320 297 mbedtls_snprintf( buf, buflen, "ECP - Operation in progress, call again with the same parameters to continue" );
kenjiArai 0:5b88d5760320 298 #endif /* MBEDTLS_ECP_C */
kenjiArai 0:5b88d5760320 299
kenjiArai 0:5b88d5760320 300 #if defined(MBEDTLS_MD_C)
kenjiArai 0:5b88d5760320 301 if( use_ret == -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 302 mbedtls_snprintf( buf, buflen, "MD - The selected feature is not available" );
kenjiArai 0:5b88d5760320 303 if( use_ret == -(MBEDTLS_ERR_MD_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 304 mbedtls_snprintf( buf, buflen, "MD - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 305 if( use_ret == -(MBEDTLS_ERR_MD_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 306 mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" );
kenjiArai 0:5b88d5760320 307 if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 308 mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" );
kenjiArai 0:5b88d5760320 309 if( use_ret == -(MBEDTLS_ERR_MD_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 310 mbedtls_snprintf( buf, buflen, "MD - MD hardware accelerator failed" );
kenjiArai 0:5b88d5760320 311 #endif /* MBEDTLS_MD_C */
kenjiArai 0:5b88d5760320 312
kenjiArai 0:5b88d5760320 313 #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
kenjiArai 0:5b88d5760320 314 if( use_ret == -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) )
kenjiArai 0:5b88d5760320 315 mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" );
kenjiArai 0:5b88d5760320 316 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) )
kenjiArai 0:5b88d5760320 317 mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" );
kenjiArai 0:5b88d5760320 318 if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 319 mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" );
kenjiArai 0:5b88d5760320 320 if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) )
kenjiArai 0:5b88d5760320 321 mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" );
kenjiArai 0:5b88d5760320 322 if( use_ret == -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG) )
kenjiArai 0:5b88d5760320 323 mbedtls_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" );
kenjiArai 0:5b88d5760320 324 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED) )
kenjiArai 0:5b88d5760320 325 mbedtls_snprintf( buf, buflen, "PEM - Private key password can't be empty" );
kenjiArai 0:5b88d5760320 326 if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH) )
kenjiArai 0:5b88d5760320 327 mbedtls_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" );
kenjiArai 0:5b88d5760320 328 if( use_ret == -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 329 mbedtls_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" );
kenjiArai 0:5b88d5760320 330 if( use_ret == -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 331 mbedtls_snprintf( buf, buflen, "PEM - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 332 #endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */
kenjiArai 0:5b88d5760320 333
kenjiArai 0:5b88d5760320 334 #if defined(MBEDTLS_PK_C)
kenjiArai 0:5b88d5760320 335 if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 336 mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" );
kenjiArai 0:5b88d5760320 337 if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) )
kenjiArai 0:5b88d5760320 338 mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" );
kenjiArai 0:5b88d5760320 339 if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 340 mbedtls_snprintf( buf, buflen, "PK - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 341 if( use_ret == -(MBEDTLS_ERR_PK_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 342 mbedtls_snprintf( buf, buflen, "PK - Read/write of file failed" );
kenjiArai 0:5b88d5760320 343 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION) )
kenjiArai 0:5b88d5760320 344 mbedtls_snprintf( buf, buflen, "PK - Unsupported key version" );
kenjiArai 0:5b88d5760320 345 if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT) )
kenjiArai 0:5b88d5760320 346 mbedtls_snprintf( buf, buflen, "PK - Invalid key tag or value" );
kenjiArai 0:5b88d5760320 347 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG) )
kenjiArai 0:5b88d5760320 348 mbedtls_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" );
kenjiArai 0:5b88d5760320 349 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED) )
kenjiArai 0:5b88d5760320 350 mbedtls_snprintf( buf, buflen, "PK - Private key password can't be empty" );
kenjiArai 0:5b88d5760320 351 if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH) )
kenjiArai 0:5b88d5760320 352 mbedtls_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" );
kenjiArai 0:5b88d5760320 353 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_PUBKEY) )
kenjiArai 0:5b88d5760320 354 mbedtls_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" );
kenjiArai 0:5b88d5760320 355 if( use_ret == -(MBEDTLS_ERR_PK_INVALID_ALG) )
kenjiArai 0:5b88d5760320 356 mbedtls_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" );
kenjiArai 0:5b88d5760320 357 if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE) )
kenjiArai 0:5b88d5760320 358 mbedtls_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" );
kenjiArai 0:5b88d5760320 359 if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 360 mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
kenjiArai 0:5b88d5760320 361 if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) )
kenjiArai 0:5b88d5760320 362 mbedtls_snprintf( buf, buflen, "PK - The buffer contains a valid signature followed by more data" );
kenjiArai 0:5b88d5760320 363 if( use_ret == -(MBEDTLS_ERR_PK_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 364 mbedtls_snprintf( buf, buflen, "PK - PK hardware accelerator failed" );
kenjiArai 0:5b88d5760320 365 #endif /* MBEDTLS_PK_C */
kenjiArai 0:5b88d5760320 366
kenjiArai 0:5b88d5760320 367 #if defined(MBEDTLS_PKCS12_C)
kenjiArai 0:5b88d5760320 368 if( use_ret == -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 369 mbedtls_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 370 if( use_ret == -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 371 mbedtls_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" );
kenjiArai 0:5b88d5760320 372 if( use_ret == -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT) )
kenjiArai 0:5b88d5760320 373 mbedtls_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" );
kenjiArai 0:5b88d5760320 374 if( use_ret == -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) )
kenjiArai 0:5b88d5760320 375 mbedtls_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" );
kenjiArai 0:5b88d5760320 376 #endif /* MBEDTLS_PKCS12_C */
kenjiArai 0:5b88d5760320 377
kenjiArai 0:5b88d5760320 378 #if defined(MBEDTLS_PKCS5_C)
kenjiArai 0:5b88d5760320 379 if( use_ret == -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 380 mbedtls_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 381 if( use_ret == -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT) )
kenjiArai 0:5b88d5760320 382 mbedtls_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" );
kenjiArai 0:5b88d5760320 383 if( use_ret == -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 384 mbedtls_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" );
kenjiArai 0:5b88d5760320 385 if( use_ret == -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH) )
kenjiArai 0:5b88d5760320 386 mbedtls_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" );
kenjiArai 0:5b88d5760320 387 #endif /* MBEDTLS_PKCS5_C */
kenjiArai 0:5b88d5760320 388
kenjiArai 0:5b88d5760320 389 #if defined(MBEDTLS_RSA_C)
kenjiArai 0:5b88d5760320 390 if( use_ret == -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 391 mbedtls_snprintf( buf, buflen, "RSA - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 392 if( use_ret == -(MBEDTLS_ERR_RSA_INVALID_PADDING) )
kenjiArai 0:5b88d5760320 393 mbedtls_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" );
kenjiArai 0:5b88d5760320 394 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) )
kenjiArai 0:5b88d5760320 395 mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" );
kenjiArai 0:5b88d5760320 396 if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) )
kenjiArai 0:5b88d5760320 397 mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the validity check of the library" );
kenjiArai 0:5b88d5760320 398 if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) )
kenjiArai 0:5b88d5760320 399 mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" );
kenjiArai 0:5b88d5760320 400 if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) )
kenjiArai 0:5b88d5760320 401 mbedtls_snprintf( buf, buflen, "RSA - The private key operation failed" );
kenjiArai 0:5b88d5760320 402 if( use_ret == -(MBEDTLS_ERR_RSA_VERIFY_FAILED) )
kenjiArai 0:5b88d5760320 403 mbedtls_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" );
kenjiArai 0:5b88d5760320 404 if( use_ret == -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE) )
kenjiArai 0:5b88d5760320 405 mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" );
kenjiArai 0:5b88d5760320 406 if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) )
kenjiArai 0:5b88d5760320 407 mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" );
kenjiArai 0:5b88d5760320 408 if( use_ret == -(MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION) )
kenjiArai 0:5b88d5760320 409 mbedtls_snprintf( buf, buflen, "RSA - The implementation does not offer the requested operation, for example, because of security violations or lack of functionality" );
kenjiArai 0:5b88d5760320 410 if( use_ret == -(MBEDTLS_ERR_RSA_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 411 mbedtls_snprintf( buf, buflen, "RSA - RSA hardware accelerator failed" );
kenjiArai 0:5b88d5760320 412 #endif /* MBEDTLS_RSA_C */
kenjiArai 0:5b88d5760320 413
kenjiArai 0:5b88d5760320 414 #if defined(MBEDTLS_SSL_TLS_C)
kenjiArai 0:5b88d5760320 415 if( use_ret == -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 416 mbedtls_snprintf( buf, buflen, "SSL - The requested feature is not available" );
kenjiArai 0:5b88d5760320 417 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 418 mbedtls_snprintf( buf, buflen, "SSL - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 419 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_MAC) )
kenjiArai 0:5b88d5760320 420 mbedtls_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" );
kenjiArai 0:5b88d5760320 421 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_RECORD) )
kenjiArai 0:5b88d5760320 422 mbedtls_snprintf( buf, buflen, "SSL - An invalid SSL record was received" );
kenjiArai 0:5b88d5760320 423 if( use_ret == -(MBEDTLS_ERR_SSL_CONN_EOF) )
kenjiArai 0:5b88d5760320 424 mbedtls_snprintf( buf, buflen, "SSL - The connection indicated an EOF" );
kenjiArai 0:5b88d5760320 425 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER) )
kenjiArai 0:5b88d5760320 426 mbedtls_snprintf( buf, buflen, "SSL - An unknown cipher was received" );
kenjiArai 0:5b88d5760320 427 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN) )
kenjiArai 0:5b88d5760320 428 mbedtls_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" );
kenjiArai 0:5b88d5760320 429 if( use_ret == -(MBEDTLS_ERR_SSL_NO_RNG) )
kenjiArai 0:5b88d5760320 430 mbedtls_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" );
kenjiArai 0:5b88d5760320 431 if( use_ret == -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE) )
kenjiArai 0:5b88d5760320 432 mbedtls_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" );
kenjiArai 0:5b88d5760320 433 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE) )
kenjiArai 0:5b88d5760320 434 mbedtls_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" );
kenjiArai 0:5b88d5760320 435 if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED) )
kenjiArai 0:5b88d5760320 436 mbedtls_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" );
kenjiArai 0:5b88d5760320 437 if( use_ret == -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED) )
kenjiArai 0:5b88d5760320 438 mbedtls_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" );
kenjiArai 0:5b88d5760320 439 if( use_ret == -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) )
kenjiArai 0:5b88d5760320 440 mbedtls_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" );
kenjiArai 0:5b88d5760320 441 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) )
kenjiArai 0:5b88d5760320 442 mbedtls_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" );
kenjiArai 0:5b88d5760320 443 if( use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) )
kenjiArai 0:5b88d5760320 444 {
kenjiArai 0:5b88d5760320 445 mbedtls_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" );
kenjiArai 0:5b88d5760320 446 return;
kenjiArai 0:5b88d5760320 447 }
kenjiArai 0:5b88d5760320 448 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED) )
kenjiArai 0:5b88d5760320 449 mbedtls_snprintf( buf, buflen, "SSL - Verification of our peer failed" );
kenjiArai 0:5b88d5760320 450 if( use_ret == -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) )
kenjiArai 0:5b88d5760320 451 mbedtls_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" );
kenjiArai 0:5b88d5760320 452 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO) )
kenjiArai 0:5b88d5760320 453 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" );
kenjiArai 0:5b88d5760320 454 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO) )
kenjiArai 0:5b88d5760320 455 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" );
kenjiArai 0:5b88d5760320 456 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE) )
kenjiArai 0:5b88d5760320 457 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" );
kenjiArai 0:5b88d5760320 458 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) )
kenjiArai 0:5b88d5760320 459 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" );
kenjiArai 0:5b88d5760320 460 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) )
kenjiArai 0:5b88d5760320 461 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" );
kenjiArai 0:5b88d5760320 462 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) )
kenjiArai 0:5b88d5760320 463 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" );
kenjiArai 0:5b88d5760320 464 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) )
kenjiArai 0:5b88d5760320 465 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" );
kenjiArai 0:5b88d5760320 466 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) )
kenjiArai 0:5b88d5760320 467 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" );
kenjiArai 0:5b88d5760320 468 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) )
kenjiArai 0:5b88d5760320 469 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" );
kenjiArai 0:5b88d5760320 470 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) )
kenjiArai 0:5b88d5760320 471 mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" );
kenjiArai 0:5b88d5760320 472 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) )
kenjiArai 0:5b88d5760320 473 mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" );
kenjiArai 0:5b88d5760320 474 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) )
kenjiArai 0:5b88d5760320 475 mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" );
kenjiArai 0:5b88d5760320 476 if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 477 mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" );
kenjiArai 0:5b88d5760320 478 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 479 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" );
kenjiArai 0:5b88d5760320 480 if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH) )
kenjiArai 0:5b88d5760320 481 mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" );
kenjiArai 0:5b88d5760320 482 if( use_ret == -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED) )
kenjiArai 0:5b88d5760320 483 mbedtls_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" );
kenjiArai 0:5b88d5760320 484 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION) )
kenjiArai 0:5b88d5760320 485 mbedtls_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" );
kenjiArai 0:5b88d5760320 486 if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) )
kenjiArai 0:5b88d5760320 487 mbedtls_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" );
kenjiArai 0:5b88d5760320 488 if( use_ret == -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED) )
kenjiArai 0:5b88d5760320 489 mbedtls_snprintf( buf, buflen, "SSL - Session ticket has expired" );
kenjiArai 0:5b88d5760320 490 if( use_ret == -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH) )
kenjiArai 0:5b88d5760320 491 mbedtls_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" );
kenjiArai 0:5b88d5760320 492 if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY) )
kenjiArai 0:5b88d5760320 493 mbedtls_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" );
kenjiArai 0:5b88d5760320 494 if( use_ret == -(MBEDTLS_ERR_SSL_INTERNAL_ERROR) )
kenjiArai 0:5b88d5760320 495 mbedtls_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" );
kenjiArai 0:5b88d5760320 496 if( use_ret == -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING) )
kenjiArai 0:5b88d5760320 497 mbedtls_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" );
kenjiArai 0:5b88d5760320 498 if( use_ret == -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) )
kenjiArai 0:5b88d5760320 499 mbedtls_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" );
kenjiArai 0:5b88d5760320 500 if( use_ret == -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) )
kenjiArai 0:5b88d5760320 501 mbedtls_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" );
kenjiArai 0:5b88d5760320 502 if( use_ret == -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 503 mbedtls_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" );
kenjiArai 0:5b88d5760320 504 if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) )
kenjiArai 0:5b88d5760320 505 mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" );
kenjiArai 0:5b88d5760320 506 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) )
kenjiArai 0:5b88d5760320 507 mbedtls_snprintf( buf, buflen, "SSL - No data of requested type currently available on underlying transport" );
kenjiArai 0:5b88d5760320 508 if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) )
kenjiArai 0:5b88d5760320 509 mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" );
kenjiArai 0:5b88d5760320 510 if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) )
kenjiArai 0:5b88d5760320 511 mbedtls_snprintf( buf, buflen, "SSL - The operation timed out" );
kenjiArai 0:5b88d5760320 512 if( use_ret == -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT) )
kenjiArai 0:5b88d5760320 513 mbedtls_snprintf( buf, buflen, "SSL - The client initiated a reconnect from the same port" );
kenjiArai 0:5b88d5760320 514 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD) )
kenjiArai 0:5b88d5760320 515 mbedtls_snprintf( buf, buflen, "SSL - Record header looks valid but is not expected" );
kenjiArai 0:5b88d5760320 516 if( use_ret == -(MBEDTLS_ERR_SSL_NON_FATAL) )
kenjiArai 0:5b88d5760320 517 mbedtls_snprintf( buf, buflen, "SSL - The alert message received indicates a non-fatal error" );
kenjiArai 0:5b88d5760320 518 if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH) )
kenjiArai 0:5b88d5760320 519 mbedtls_snprintf( buf, buflen, "SSL - Couldn't set the hash for verifying CertificateVerify" );
kenjiArai 0:5b88d5760320 520 if( use_ret == -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING) )
kenjiArai 0:5b88d5760320 521 mbedtls_snprintf( buf, buflen, "SSL - Internal-only message signaling that further message-processing should be done" );
kenjiArai 0:5b88d5760320 522 if( use_ret == -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS) )
kenjiArai 0:5b88d5760320 523 mbedtls_snprintf( buf, buflen, "SSL - The asynchronous operation is not completed yet" );
kenjiArai 0:5b88d5760320 524 if( use_ret == -(MBEDTLS_ERR_SSL_EARLY_MESSAGE) )
kenjiArai 0:5b88d5760320 525 mbedtls_snprintf( buf, buflen, "SSL - Internal-only message signaling that a message arrived early" );
kenjiArai 0:5b88d5760320 526 if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_CID) )
kenjiArai 0:5b88d5760320 527 mbedtls_snprintf( buf, buflen, "SSL - An encrypted DTLS-frame with an unexpected CID was received" );
kenjiArai 1:9db0e321a9f4 528 if( use_ret == -(MBEDTLS_ERR_SSL_VERSION_MISMATCH) )
kenjiArai 1:9db0e321a9f4 529 mbedtls_snprintf( buf, buflen, "SSL - An operation failed due to an unexpected version or configuration" );
kenjiArai 0:5b88d5760320 530 if( use_ret == -(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) )
kenjiArai 0:5b88d5760320 531 mbedtls_snprintf( buf, buflen, "SSL - A cryptographic operation is in progress. Try again later" );
kenjiArai 0:5b88d5760320 532 #endif /* MBEDTLS_SSL_TLS_C */
kenjiArai 0:5b88d5760320 533
kenjiArai 0:5b88d5760320 534 #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
kenjiArai 0:5b88d5760320 535 if( use_ret == -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 536 mbedtls_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" );
kenjiArai 0:5b88d5760320 537 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_OID) )
kenjiArai 0:5b88d5760320 538 mbedtls_snprintf( buf, buflen, "X509 - Requested OID is unknown" );
kenjiArai 0:5b88d5760320 539 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_FORMAT) )
kenjiArai 0:5b88d5760320 540 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" );
kenjiArai 0:5b88d5760320 541 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_VERSION) )
kenjiArai 0:5b88d5760320 542 mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" );
kenjiArai 0:5b88d5760320 543 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SERIAL) )
kenjiArai 0:5b88d5760320 544 mbedtls_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" );
kenjiArai 0:5b88d5760320 545 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_ALG) )
kenjiArai 0:5b88d5760320 546 mbedtls_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" );
kenjiArai 0:5b88d5760320 547 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_NAME) )
kenjiArai 0:5b88d5760320 548 mbedtls_snprintf( buf, buflen, "X509 - The name tag or value is invalid" );
kenjiArai 0:5b88d5760320 549 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_DATE) )
kenjiArai 0:5b88d5760320 550 mbedtls_snprintf( buf, buflen, "X509 - The date tag or value is invalid" );
kenjiArai 0:5b88d5760320 551 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SIGNATURE) )
kenjiArai 0:5b88d5760320 552 mbedtls_snprintf( buf, buflen, "X509 - The signature tag or value invalid" );
kenjiArai 0:5b88d5760320 553 if( use_ret == -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS) )
kenjiArai 0:5b88d5760320 554 mbedtls_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" );
kenjiArai 0:5b88d5760320 555 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_VERSION) )
kenjiArai 0:5b88d5760320 556 mbedtls_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" );
kenjiArai 0:5b88d5760320 557 if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG) )
kenjiArai 0:5b88d5760320 558 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" );
kenjiArai 0:5b88d5760320 559 if( use_ret == -(MBEDTLS_ERR_X509_SIG_MISMATCH) )
kenjiArai 0:5b88d5760320 560 mbedtls_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" );
kenjiArai 0:5b88d5760320 561 if( use_ret == -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) )
kenjiArai 0:5b88d5760320 562 mbedtls_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" );
kenjiArai 0:5b88d5760320 563 if( use_ret == -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT) )
kenjiArai 0:5b88d5760320 564 mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" );
kenjiArai 0:5b88d5760320 565 if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 566 mbedtls_snprintf( buf, buflen, "X509 - Input invalid" );
kenjiArai 0:5b88d5760320 567 if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 568 mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" );
kenjiArai 0:5b88d5760320 569 if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 570 mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" );
kenjiArai 0:5b88d5760320 571 if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 572 mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" );
kenjiArai 0:5b88d5760320 573 if( use_ret == -(MBEDTLS_ERR_X509_FATAL_ERROR) )
kenjiArai 0:5b88d5760320 574 mbedtls_snprintf( buf, buflen, "X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed" );
kenjiArai 0:5b88d5760320 575 #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
kenjiArai 0:5b88d5760320 576 // END generated code
kenjiArai 0:5b88d5760320 577
kenjiArai 0:5b88d5760320 578 if( strlen( buf ) == 0 )
kenjiArai 0:5b88d5760320 579 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
kenjiArai 0:5b88d5760320 580 }
kenjiArai 0:5b88d5760320 581
kenjiArai 0:5b88d5760320 582 use_ret = ret & ~0xFF80;
kenjiArai 0:5b88d5760320 583
kenjiArai 0:5b88d5760320 584 if( use_ret == 0 )
kenjiArai 0:5b88d5760320 585 return;
kenjiArai 0:5b88d5760320 586
kenjiArai 0:5b88d5760320 587 // If high level code is present, make a concatenation between both
kenjiArai 0:5b88d5760320 588 // error strings.
kenjiArai 0:5b88d5760320 589 //
kenjiArai 0:5b88d5760320 590 len = strlen( buf );
kenjiArai 0:5b88d5760320 591
kenjiArai 0:5b88d5760320 592 if( len > 0 )
kenjiArai 0:5b88d5760320 593 {
kenjiArai 0:5b88d5760320 594 if( buflen - len < 5 )
kenjiArai 0:5b88d5760320 595 return;
kenjiArai 0:5b88d5760320 596
kenjiArai 0:5b88d5760320 597 mbedtls_snprintf( buf + len, buflen - len, " : " );
kenjiArai 0:5b88d5760320 598
kenjiArai 0:5b88d5760320 599 buf += len + 3;
kenjiArai 0:5b88d5760320 600 buflen -= len + 3;
kenjiArai 0:5b88d5760320 601 }
kenjiArai 0:5b88d5760320 602
kenjiArai 0:5b88d5760320 603 // Low level error codes
kenjiArai 0:5b88d5760320 604 //
kenjiArai 0:5b88d5760320 605 // BEGIN generated code
kenjiArai 0:5b88d5760320 606 #if defined(MBEDTLS_AES_C)
kenjiArai 0:5b88d5760320 607 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) )
kenjiArai 0:5b88d5760320 608 mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
kenjiArai 0:5b88d5760320 609 if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 610 mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" );
kenjiArai 0:5b88d5760320 611 if( use_ret == -(MBEDTLS_ERR_AES_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 612 mbedtls_snprintf( buf, buflen, "AES - Invalid input data" );
kenjiArai 0:5b88d5760320 613 if( use_ret == -(MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 614 mbedtls_snprintf( buf, buflen, "AES - Feature not available. For example, an unsupported AES key size" );
kenjiArai 0:5b88d5760320 615 if( use_ret == -(MBEDTLS_ERR_AES_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 616 mbedtls_snprintf( buf, buflen, "AES - AES hardware accelerator failed" );
kenjiArai 0:5b88d5760320 617 #endif /* MBEDTLS_AES_C */
kenjiArai 0:5b88d5760320 618
kenjiArai 0:5b88d5760320 619 #if defined(MBEDTLS_ARC4_C)
kenjiArai 0:5b88d5760320 620 if( use_ret == -(MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 621 mbedtls_snprintf( buf, buflen, "ARC4 - ARC4 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 622 #endif /* MBEDTLS_ARC4_C */
kenjiArai 0:5b88d5760320 623
kenjiArai 0:5b88d5760320 624 #if defined(MBEDTLS_ARIA_C)
kenjiArai 0:5b88d5760320 625 if( use_ret == -(MBEDTLS_ERR_ARIA_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 626 mbedtls_snprintf( buf, buflen, "ARIA - Bad input data" );
kenjiArai 0:5b88d5760320 627 if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 628 mbedtls_snprintf( buf, buflen, "ARIA - Invalid data input length" );
kenjiArai 0:5b88d5760320 629 if( use_ret == -(MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 630 mbedtls_snprintf( buf, buflen, "ARIA - Feature not available. For example, an unsupported ARIA key size" );
kenjiArai 0:5b88d5760320 631 if( use_ret == -(MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 632 mbedtls_snprintf( buf, buflen, "ARIA - ARIA hardware accelerator failed" );
kenjiArai 0:5b88d5760320 633 #endif /* MBEDTLS_ARIA_C */
kenjiArai 0:5b88d5760320 634
kenjiArai 0:5b88d5760320 635 #if defined(MBEDTLS_ASN1_PARSE_C)
kenjiArai 0:5b88d5760320 636 if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) )
kenjiArai 0:5b88d5760320 637 mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" );
kenjiArai 0:5b88d5760320 638 if( use_ret == -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) )
kenjiArai 0:5b88d5760320 639 mbedtls_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" );
kenjiArai 0:5b88d5760320 640 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_LENGTH) )
kenjiArai 0:5b88d5760320 641 mbedtls_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" );
kenjiArai 0:5b88d5760320 642 if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) )
kenjiArai 0:5b88d5760320 643 mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
kenjiArai 0:5b88d5760320 644 if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) )
kenjiArai 1:9db0e321a9f4 645 mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid" );
kenjiArai 0:5b88d5760320 646 if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 647 mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
kenjiArai 0:5b88d5760320 648 if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) )
kenjiArai 0:5b88d5760320 649 mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" );
kenjiArai 0:5b88d5760320 650 #endif /* MBEDTLS_ASN1_PARSE_C */
kenjiArai 0:5b88d5760320 651
kenjiArai 0:5b88d5760320 652 #if defined(MBEDTLS_BASE64_C)
kenjiArai 0:5b88d5760320 653 if( use_ret == -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 654 mbedtls_snprintf( buf, buflen, "BASE64 - Output buffer too small" );
kenjiArai 0:5b88d5760320 655 if( use_ret == -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER) )
kenjiArai 0:5b88d5760320 656 mbedtls_snprintf( buf, buflen, "BASE64 - Invalid character in input" );
kenjiArai 0:5b88d5760320 657 #endif /* MBEDTLS_BASE64_C */
kenjiArai 0:5b88d5760320 658
kenjiArai 0:5b88d5760320 659 #if defined(MBEDTLS_BIGNUM_C)
kenjiArai 0:5b88d5760320 660 if( use_ret == -(MBEDTLS_ERR_MPI_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 661 mbedtls_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" );
kenjiArai 0:5b88d5760320 662 if( use_ret == -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 663 mbedtls_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 664 if( use_ret == -(MBEDTLS_ERR_MPI_INVALID_CHARACTER) )
kenjiArai 0:5b88d5760320 665 mbedtls_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" );
kenjiArai 0:5b88d5760320 666 if( use_ret == -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 667 mbedtls_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" );
kenjiArai 0:5b88d5760320 668 if( use_ret == -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE) )
kenjiArai 0:5b88d5760320 669 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" );
kenjiArai 0:5b88d5760320 670 if( use_ret == -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO) )
kenjiArai 0:5b88d5760320 671 mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" );
kenjiArai 0:5b88d5760320 672 if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) )
kenjiArai 0:5b88d5760320 673 mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" );
kenjiArai 0:5b88d5760320 674 if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) )
kenjiArai 0:5b88d5760320 675 mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" );
kenjiArai 0:5b88d5760320 676 #endif /* MBEDTLS_BIGNUM_C */
kenjiArai 0:5b88d5760320 677
kenjiArai 0:5b88d5760320 678 #if defined(MBEDTLS_BLOWFISH_C)
kenjiArai 0:5b88d5760320 679 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 680 mbedtls_snprintf( buf, buflen, "BLOWFISH - Bad input data" );
kenjiArai 0:5b88d5760320 681 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 682 mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" );
kenjiArai 0:5b88d5760320 683 if( use_ret == -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 684 mbedtls_snprintf( buf, buflen, "BLOWFISH - Blowfish hardware accelerator failed" );
kenjiArai 0:5b88d5760320 685 #endif /* MBEDTLS_BLOWFISH_C */
kenjiArai 0:5b88d5760320 686
kenjiArai 0:5b88d5760320 687 #if defined(MBEDTLS_CAMELLIA_C)
kenjiArai 0:5b88d5760320 688 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 689 mbedtls_snprintf( buf, buflen, "CAMELLIA - Bad input data" );
kenjiArai 0:5b88d5760320 690 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 691 mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
kenjiArai 0:5b88d5760320 692 if( use_ret == -(MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 693 mbedtls_snprintf( buf, buflen, "CAMELLIA - Camellia hardware accelerator failed" );
kenjiArai 0:5b88d5760320 694 #endif /* MBEDTLS_CAMELLIA_C */
kenjiArai 0:5b88d5760320 695
kenjiArai 0:5b88d5760320 696 #if defined(MBEDTLS_CCM_C)
kenjiArai 0:5b88d5760320 697 if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) )
kenjiArai 0:5b88d5760320 698 mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to the function" );
kenjiArai 0:5b88d5760320 699 if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) )
kenjiArai 0:5b88d5760320 700 mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
kenjiArai 0:5b88d5760320 701 if( use_ret == -(MBEDTLS_ERR_CCM_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 702 mbedtls_snprintf( buf, buflen, "CCM - CCM hardware accelerator failed" );
kenjiArai 0:5b88d5760320 703 #endif /* MBEDTLS_CCM_C */
kenjiArai 0:5b88d5760320 704
kenjiArai 0:5b88d5760320 705 #if defined(MBEDTLS_CHACHA20_C)
kenjiArai 0:5b88d5760320 706 if( use_ret == -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 707 mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" );
kenjiArai 0:5b88d5760320 708 if( use_ret == -(MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 709 mbedtls_snprintf( buf, buflen, "CHACHA20 - Feature not available. For example, s part of the API is not implemented" );
kenjiArai 0:5b88d5760320 710 if( use_ret == -(MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 711 mbedtls_snprintf( buf, buflen, "CHACHA20 - Chacha20 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 712 #endif /* MBEDTLS_CHACHA20_C */
kenjiArai 0:5b88d5760320 713
kenjiArai 0:5b88d5760320 714 #if defined(MBEDTLS_CHACHAPOLY_C)
kenjiArai 0:5b88d5760320 715 if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE) )
kenjiArai 0:5b88d5760320 716 mbedtls_snprintf( buf, buflen, "CHACHAPOLY - The requested operation is not permitted in the current state" );
kenjiArai 0:5b88d5760320 717 if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED) )
kenjiArai 0:5b88d5760320 718 mbedtls_snprintf( buf, buflen, "CHACHAPOLY - Authenticated decryption failed: data was not authentic" );
kenjiArai 0:5b88d5760320 719 #endif /* MBEDTLS_CHACHAPOLY_C */
kenjiArai 0:5b88d5760320 720
kenjiArai 0:5b88d5760320 721 #if defined(MBEDTLS_CMAC_C)
kenjiArai 0:5b88d5760320 722 if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 723 mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" );
kenjiArai 0:5b88d5760320 724 #endif /* MBEDTLS_CMAC_C */
kenjiArai 0:5b88d5760320 725
kenjiArai 0:5b88d5760320 726 #if defined(MBEDTLS_CTR_DRBG_C)
kenjiArai 0:5b88d5760320 727 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) )
kenjiArai 0:5b88d5760320 728 mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );
kenjiArai 0:5b88d5760320 729 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) )
kenjiArai 0:5b88d5760320 730 mbedtls_snprintf( buf, buflen, "CTR_DRBG - The requested random buffer length is too big" );
kenjiArai 0:5b88d5760320 731 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) )
kenjiArai 0:5b88d5760320 732 mbedtls_snprintf( buf, buflen, "CTR_DRBG - The input (entropy + additional data) is too large" );
kenjiArai 0:5b88d5760320 733 if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 734 mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read or write error in file" );
kenjiArai 0:5b88d5760320 735 #endif /* MBEDTLS_CTR_DRBG_C */
kenjiArai 0:5b88d5760320 736
kenjiArai 0:5b88d5760320 737 #if defined(MBEDTLS_DES_C)
kenjiArai 0:5b88d5760320 738 if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 739 mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" );
kenjiArai 0:5b88d5760320 740 if( use_ret == -(MBEDTLS_ERR_DES_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 741 mbedtls_snprintf( buf, buflen, "DES - DES hardware accelerator failed" );
kenjiArai 0:5b88d5760320 742 #endif /* MBEDTLS_DES_C */
kenjiArai 0:5b88d5760320 743
kenjiArai 0:5b88d5760320 744 #if defined(MBEDTLS_ENTROPY_C)
kenjiArai 0:5b88d5760320 745 if( use_ret == -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED) )
kenjiArai 0:5b88d5760320 746 mbedtls_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" );
kenjiArai 0:5b88d5760320 747 if( use_ret == -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES) )
kenjiArai 0:5b88d5760320 748 mbedtls_snprintf( buf, buflen, "ENTROPY - No more sources can be added" );
kenjiArai 0:5b88d5760320 749 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED) )
kenjiArai 0:5b88d5760320 750 mbedtls_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" );
kenjiArai 0:5b88d5760320 751 if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE) )
kenjiArai 0:5b88d5760320 752 mbedtls_snprintf( buf, buflen, "ENTROPY - No strong sources have been added to poll" );
kenjiArai 0:5b88d5760320 753 if( use_ret == -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 754 mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" );
kenjiArai 0:5b88d5760320 755 #endif /* MBEDTLS_ENTROPY_C */
kenjiArai 0:5b88d5760320 756
kenjiArai 0:5b88d5760320 757 #if defined(MBEDTLS_GCM_C)
kenjiArai 0:5b88d5760320 758 if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) )
kenjiArai 0:5b88d5760320 759 mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" );
kenjiArai 0:5b88d5760320 760 if( use_ret == -(MBEDTLS_ERR_GCM_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 761 mbedtls_snprintf( buf, buflen, "GCM - GCM hardware accelerator failed" );
kenjiArai 0:5b88d5760320 762 if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) )
kenjiArai 0:5b88d5760320 763 mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 764 #endif /* MBEDTLS_GCM_C */
kenjiArai 0:5b88d5760320 765
kenjiArai 0:5b88d5760320 766 #if defined(MBEDTLS_HKDF_C)
kenjiArai 0:5b88d5760320 767 if( use_ret == -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 768 mbedtls_snprintf( buf, buflen, "HKDF - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 769 #endif /* MBEDTLS_HKDF_C */
kenjiArai 0:5b88d5760320 770
kenjiArai 0:5b88d5760320 771 #if defined(MBEDTLS_HMAC_DRBG_C)
kenjiArai 0:5b88d5760320 772 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) )
kenjiArai 0:5b88d5760320 773 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" );
kenjiArai 0:5b88d5760320 774 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG) )
kenjiArai 0:5b88d5760320 775 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" );
kenjiArai 0:5b88d5760320 776 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR) )
kenjiArai 0:5b88d5760320 777 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" );
kenjiArai 0:5b88d5760320 778 if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) )
kenjiArai 0:5b88d5760320 779 mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
kenjiArai 0:5b88d5760320 780 #endif /* MBEDTLS_HMAC_DRBG_C */
kenjiArai 0:5b88d5760320 781
kenjiArai 0:5b88d5760320 782 #if defined(MBEDTLS_MD2_C)
kenjiArai 0:5b88d5760320 783 if( use_ret == -(MBEDTLS_ERR_MD2_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 784 mbedtls_snprintf( buf, buflen, "MD2 - MD2 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 785 #endif /* MBEDTLS_MD2_C */
kenjiArai 0:5b88d5760320 786
kenjiArai 0:5b88d5760320 787 #if defined(MBEDTLS_MD4_C)
kenjiArai 0:5b88d5760320 788 if( use_ret == -(MBEDTLS_ERR_MD4_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 789 mbedtls_snprintf( buf, buflen, "MD4 - MD4 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 790 #endif /* MBEDTLS_MD4_C */
kenjiArai 0:5b88d5760320 791
kenjiArai 0:5b88d5760320 792 #if defined(MBEDTLS_MD5_C)
kenjiArai 0:5b88d5760320 793 if( use_ret == -(MBEDTLS_ERR_MD5_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 794 mbedtls_snprintf( buf, buflen, "MD5 - MD5 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 795 #endif /* MBEDTLS_MD5_C */
kenjiArai 0:5b88d5760320 796
kenjiArai 0:5b88d5760320 797 #if defined(MBEDTLS_OID_C)
kenjiArai 0:5b88d5760320 798 if( use_ret == -(MBEDTLS_ERR_OID_NOT_FOUND) )
kenjiArai 0:5b88d5760320 799 mbedtls_snprintf( buf, buflen, "OID - OID is not found" );
kenjiArai 0:5b88d5760320 800 if( use_ret == -(MBEDTLS_ERR_OID_BUF_TOO_SMALL) )
kenjiArai 0:5b88d5760320 801 mbedtls_snprintf( buf, buflen, "OID - output buffer is too small" );
kenjiArai 0:5b88d5760320 802 #endif /* MBEDTLS_OID_C */
kenjiArai 0:5b88d5760320 803
kenjiArai 0:5b88d5760320 804 #if defined(MBEDTLS_PADLOCK_C)
kenjiArai 0:5b88d5760320 805 if( use_ret == -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED) )
kenjiArai 0:5b88d5760320 806 mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
kenjiArai 0:5b88d5760320 807 #endif /* MBEDTLS_PADLOCK_C */
kenjiArai 0:5b88d5760320 808
kenjiArai 0:5b88d5760320 809 #if defined(MBEDTLS_PLATFORM_C)
kenjiArai 0:5b88d5760320 810 if( use_ret == -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 811 mbedtls_snprintf( buf, buflen, "PLATFORM - Hardware accelerator failed" );
kenjiArai 0:5b88d5760320 812 if( use_ret == -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED) )
kenjiArai 0:5b88d5760320 813 mbedtls_snprintf( buf, buflen, "PLATFORM - The requested feature is not supported by the platform" );
kenjiArai 0:5b88d5760320 814 #endif /* MBEDTLS_PLATFORM_C */
kenjiArai 0:5b88d5760320 815
kenjiArai 0:5b88d5760320 816 #if defined(MBEDTLS_POLY1305_C)
kenjiArai 0:5b88d5760320 817 if( use_ret == -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 818 mbedtls_snprintf( buf, buflen, "POLY1305 - Invalid input parameter(s)" );
kenjiArai 0:5b88d5760320 819 if( use_ret == -(MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 820 mbedtls_snprintf( buf, buflen, "POLY1305 - Feature not available. For example, s part of the API is not implemented" );
kenjiArai 0:5b88d5760320 821 if( use_ret == -(MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 822 mbedtls_snprintf( buf, buflen, "POLY1305 - Poly1305 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 823 #endif /* MBEDTLS_POLY1305_C */
kenjiArai 0:5b88d5760320 824
kenjiArai 0:5b88d5760320 825 #if defined(MBEDTLS_RIPEMD160_C)
kenjiArai 0:5b88d5760320 826 if( use_ret == -(MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 827 mbedtls_snprintf( buf, buflen, "RIPEMD160 - RIPEMD160 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 828 #endif /* MBEDTLS_RIPEMD160_C */
kenjiArai 0:5b88d5760320 829
kenjiArai 0:5b88d5760320 830 #if defined(MBEDTLS_SHA1_C)
kenjiArai 0:5b88d5760320 831 if( use_ret == -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 832 mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 833 if( use_ret == -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 834 mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 input data was malformed" );
kenjiArai 0:5b88d5760320 835 #endif /* MBEDTLS_SHA1_C */
kenjiArai 0:5b88d5760320 836
kenjiArai 0:5b88d5760320 837 #if defined(MBEDTLS_SHA256_C)
kenjiArai 0:5b88d5760320 838 if( use_ret == -(MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 839 mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 840 if( use_ret == -(MBEDTLS_ERR_SHA256_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 841 mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 input data was malformed" );
kenjiArai 0:5b88d5760320 842 #endif /* MBEDTLS_SHA256_C */
kenjiArai 0:5b88d5760320 843
kenjiArai 0:5b88d5760320 844 #if defined(MBEDTLS_SHA512_C)
kenjiArai 0:5b88d5760320 845 if( use_ret == -(MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 846 mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 hardware accelerator failed" );
kenjiArai 0:5b88d5760320 847 if( use_ret == -(MBEDTLS_ERR_SHA512_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 848 mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 input data was malformed" );
kenjiArai 0:5b88d5760320 849 #endif /* MBEDTLS_SHA512_C */
kenjiArai 0:5b88d5760320 850
kenjiArai 0:5b88d5760320 851 #if defined(MBEDTLS_THREADING_C)
kenjiArai 0:5b88d5760320 852 if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) )
kenjiArai 0:5b88d5760320 853 mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" );
kenjiArai 0:5b88d5760320 854 if( use_ret == -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 855 mbedtls_snprintf( buf, buflen, "THREADING - Bad input parameters to function" );
kenjiArai 0:5b88d5760320 856 if( use_ret == -(MBEDTLS_ERR_THREADING_MUTEX_ERROR) )
kenjiArai 0:5b88d5760320 857 mbedtls_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" );
kenjiArai 0:5b88d5760320 858 #endif /* MBEDTLS_THREADING_C */
kenjiArai 0:5b88d5760320 859
kenjiArai 0:5b88d5760320 860 #if defined(MBEDTLS_XTEA_C)
kenjiArai 0:5b88d5760320 861 if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) )
kenjiArai 0:5b88d5760320 862 mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" );
kenjiArai 0:5b88d5760320 863 if( use_ret == -(MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED) )
kenjiArai 0:5b88d5760320 864 mbedtls_snprintf( buf, buflen, "XTEA - XTEA hardware accelerator failed" );
kenjiArai 0:5b88d5760320 865 #endif /* MBEDTLS_XTEA_C */
kenjiArai 0:5b88d5760320 866
kenjiArai 0:5b88d5760320 867 #if defined(MBEDTLS_NET_C)
kenjiArai 0:5b88d5760320 868 if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) )
kenjiArai 0:5b88d5760320 869 mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" );
kenjiArai 0:5b88d5760320 870 if( use_ret == -(MBEDTLS_ERR_NET_CONNECT_FAILED) )
kenjiArai 0:5b88d5760320 871 mbedtls_snprintf( buf, buflen, "NET - The connection to the given server / port failed" );
kenjiArai 0:5b88d5760320 872 if( use_ret == -(MBEDTLS_ERR_NET_BIND_FAILED) )
kenjiArai 0:5b88d5760320 873 mbedtls_snprintf( buf, buflen, "NET - Binding of the socket failed" );
kenjiArai 0:5b88d5760320 874 if( use_ret == -(MBEDTLS_ERR_NET_LISTEN_FAILED) )
kenjiArai 0:5b88d5760320 875 mbedtls_snprintf( buf, buflen, "NET - Could not listen on the socket" );
kenjiArai 0:5b88d5760320 876 if( use_ret == -(MBEDTLS_ERR_NET_ACCEPT_FAILED) )
kenjiArai 0:5b88d5760320 877 mbedtls_snprintf( buf, buflen, "NET - Could not accept the incoming connection" );
kenjiArai 0:5b88d5760320 878 if( use_ret == -(MBEDTLS_ERR_NET_RECV_FAILED) )
kenjiArai 0:5b88d5760320 879 mbedtls_snprintf( buf, buflen, "NET - Reading information from the socket failed" );
kenjiArai 0:5b88d5760320 880 if( use_ret == -(MBEDTLS_ERR_NET_SEND_FAILED) )
kenjiArai 0:5b88d5760320 881 mbedtls_snprintf( buf, buflen, "NET - Sending information through the socket failed" );
kenjiArai 0:5b88d5760320 882 if( use_ret == -(MBEDTLS_ERR_NET_CONN_RESET) )
kenjiArai 0:5b88d5760320 883 mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" );
kenjiArai 0:5b88d5760320 884 if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) )
kenjiArai 0:5b88d5760320 885 mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" );
kenjiArai 0:5b88d5760320 886 if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) )
kenjiArai 0:5b88d5760320 887 mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" );
kenjiArai 0:5b88d5760320 888 if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) )
kenjiArai 0:5b88d5760320 889 mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" );
kenjiArai 0:5b88d5760320 890 if( use_ret == -(MBEDTLS_ERR_NET_POLL_FAILED) )
kenjiArai 0:5b88d5760320 891 mbedtls_snprintf( buf, buflen, "NET - Polling the net context failed" );
kenjiArai 0:5b88d5760320 892 if( use_ret == -(MBEDTLS_ERR_NET_BAD_INPUT_DATA) )
kenjiArai 0:5b88d5760320 893 mbedtls_snprintf( buf, buflen, "NET - Input invalid" );
kenjiArai 0:5b88d5760320 894 #endif /* MBEDTLS_NET_C */
kenjiArai 0:5b88d5760320 895 // END generated code
kenjiArai 0:5b88d5760320 896
kenjiArai 0:5b88d5760320 897 if( strlen( buf ) != 0 )
kenjiArai 0:5b88d5760320 898 return;
kenjiArai 0:5b88d5760320 899
kenjiArai 0:5b88d5760320 900 mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret );
kenjiArai 0:5b88d5760320 901 }
kenjiArai 0:5b88d5760320 902
kenjiArai 0:5b88d5760320 903 #else /* MBEDTLS_ERROR_C */
kenjiArai 0:5b88d5760320 904
kenjiArai 0:5b88d5760320 905 #if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
kenjiArai 0:5b88d5760320 906
kenjiArai 0:5b88d5760320 907 /*
kenjiArai 0:5b88d5760320 908 * Provide an non-function in case MBEDTLS_ERROR_C is not defined
kenjiArai 0:5b88d5760320 909 */
kenjiArai 0:5b88d5760320 910 void mbedtls_strerror( int ret, char *buf, size_t buflen )
kenjiArai 0:5b88d5760320 911 {
kenjiArai 0:5b88d5760320 912 ((void) ret);
kenjiArai 0:5b88d5760320 913
kenjiArai 0:5b88d5760320 914 if( buflen > 0 )
kenjiArai 0:5b88d5760320 915 buf[0] = '\0';
kenjiArai 0:5b88d5760320 916 }
kenjiArai 0:5b88d5760320 917
kenjiArai 0:5b88d5760320 918 #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */
kenjiArai 0:5b88d5760320 919
kenjiArai 0:5b88d5760320 920 #endif /* MBEDTLS_ERROR_C */