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