Pinned to some recent date

Committer:
Simon Cooksey
Date:
Thu Nov 17 16:43:53 2016 +0000
Revision:
0:fb7af294d5d9
Initial commit

Who changed what in which revision?

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