This is a fork due to permission issues

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of 6_songs-from-the-cloud by MakingMusicWorkshop

Committer:
timbeight
Date:
Thu May 19 16:02:10 2016 +0000
Revision:
1:0ddbe2d3319c
Parent:
0:f7c60d3e7b8a
This is my first commit while in the class.

Who changed what in which revision?

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