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