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