mbed TLS library
Dependents: HTTPClient-SSL WS_SERVER
polarssl/error.c@0:137634ff4186, 2015-06-11 (annotated)
- Committer:
- ansond
- Date:
- Thu Jun 11 03:27:03 2015 +0000
- Revision:
- 0:137634ff4186
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:137634ff4186 | 1 | /* |
ansond | 0:137634ff4186 | 2 | * Error message information |
ansond | 0:137634ff4186 | 3 | * |
ansond | 0:137634ff4186 | 4 | * Copyright (C) 2006-2014, ARM Limited, All Rights Reserved |
ansond | 0:137634ff4186 | 5 | * |
ansond | 0:137634ff4186 | 6 | * This file is part of mbed TLS (https://tls.mbed.org) |
ansond | 0:137634ff4186 | 7 | * |
ansond | 0:137634ff4186 | 8 | * This program is free software; you can redistribute it and/or modify |
ansond | 0:137634ff4186 | 9 | * it under the terms of the GNU General Public License as published by |
ansond | 0:137634ff4186 | 10 | * the Free Software Foundation; either version 2 of the License, or |
ansond | 0:137634ff4186 | 11 | * (at your option) any later version. |
ansond | 0:137634ff4186 | 12 | * |
ansond | 0:137634ff4186 | 13 | * This program is distributed in the hope that it will be useful, |
ansond | 0:137634ff4186 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ansond | 0:137634ff4186 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ansond | 0:137634ff4186 | 16 | * GNU General Public License for more details. |
ansond | 0:137634ff4186 | 17 | * |
ansond | 0:137634ff4186 | 18 | * You should have received a copy of the GNU General Public License along |
ansond | 0:137634ff4186 | 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
ansond | 0:137634ff4186 | 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ansond | 0:137634ff4186 | 21 | */ |
ansond | 0:137634ff4186 | 22 | |
ansond | 0:137634ff4186 | 23 | #if !defined(POLARSSL_CONFIG_FILE) |
ansond | 0:137634ff4186 | 24 | #include "polarssl/config.h" |
ansond | 0:137634ff4186 | 25 | #else |
ansond | 0:137634ff4186 | 26 | #include POLARSSL_CONFIG_FILE |
ansond | 0:137634ff4186 | 27 | #endif |
ansond | 0:137634ff4186 | 28 | |
ansond | 0:137634ff4186 | 29 | #if defined(POLARSSL_ERROR_C) || defined(POLARSSL_ERROR_STRERROR_DUMMY) |
ansond | 0:137634ff4186 | 30 | #include "polarssl/error.h" |
ansond | 0:137634ff4186 | 31 | #include <string.h> |
ansond | 0:137634ff4186 | 32 | #endif |
ansond | 0:137634ff4186 | 33 | |
ansond | 0:137634ff4186 | 34 | #if defined(POLARSSL_PLATFORM_C) |
ansond | 0:137634ff4186 | 35 | #include "polarssl/platform.h" |
ansond | 0:137634ff4186 | 36 | #else |
ansond | 0:137634ff4186 | 37 | #define polarssl_snprintf snprintf |
ansond | 0:137634ff4186 | 38 | #endif |
ansond | 0:137634ff4186 | 39 | |
ansond | 0:137634ff4186 | 40 | #if defined(POLARSSL_ERROR_C) |
ansond | 0:137634ff4186 | 41 | |
ansond | 0:137634ff4186 | 42 | #include <stdio.h> |
ansond | 0:137634ff4186 | 43 | |
ansond | 0:137634ff4186 | 44 | #if defined(POLARSSL_AES_C) |
ansond | 0:137634ff4186 | 45 | #include "polarssl/aes.h" |
ansond | 0:137634ff4186 | 46 | #endif |
ansond | 0:137634ff4186 | 47 | |
ansond | 0:137634ff4186 | 48 | #if defined(POLARSSL_BASE64_C) |
ansond | 0:137634ff4186 | 49 | #include "polarssl/base64.h" |
ansond | 0:137634ff4186 | 50 | #endif |
ansond | 0:137634ff4186 | 51 | |
ansond | 0:137634ff4186 | 52 | #if defined(POLARSSL_BIGNUM_C) |
ansond | 0:137634ff4186 | 53 | #include "polarssl/bignum.h" |
ansond | 0:137634ff4186 | 54 | #endif |
ansond | 0:137634ff4186 | 55 | |
ansond | 0:137634ff4186 | 56 | #if defined(POLARSSL_BLOWFISH_C) |
ansond | 0:137634ff4186 | 57 | #include "polarssl/blowfish.h" |
ansond | 0:137634ff4186 | 58 | #endif |
ansond | 0:137634ff4186 | 59 | |
ansond | 0:137634ff4186 | 60 | #if defined(POLARSSL_CAMELLIA_C) |
ansond | 0:137634ff4186 | 61 | #include "polarssl/camellia.h" |
ansond | 0:137634ff4186 | 62 | #endif |
ansond | 0:137634ff4186 | 63 | |
ansond | 0:137634ff4186 | 64 | #if defined(POLARSSL_CCM_C) |
ansond | 0:137634ff4186 | 65 | #include "polarssl/ccm.h" |
ansond | 0:137634ff4186 | 66 | #endif |
ansond | 0:137634ff4186 | 67 | |
ansond | 0:137634ff4186 | 68 | #if defined(POLARSSL_CIPHER_C) |
ansond | 0:137634ff4186 | 69 | #include "polarssl/cipher.h" |
ansond | 0:137634ff4186 | 70 | #endif |
ansond | 0:137634ff4186 | 71 | |
ansond | 0:137634ff4186 | 72 | #if defined(POLARSSL_CTR_DRBG_C) |
ansond | 0:137634ff4186 | 73 | #include "polarssl/ctr_drbg.h" |
ansond | 0:137634ff4186 | 74 | #endif |
ansond | 0:137634ff4186 | 75 | |
ansond | 0:137634ff4186 | 76 | #if defined(POLARSSL_DES_C) |
ansond | 0:137634ff4186 | 77 | #include "polarssl/des.h" |
ansond | 0:137634ff4186 | 78 | #endif |
ansond | 0:137634ff4186 | 79 | |
ansond | 0:137634ff4186 | 80 | #if defined(POLARSSL_DHM_C) |
ansond | 0:137634ff4186 | 81 | #include "polarssl/dhm.h" |
ansond | 0:137634ff4186 | 82 | #endif |
ansond | 0:137634ff4186 | 83 | |
ansond | 0:137634ff4186 | 84 | #if defined(POLARSSL_ECP_C) |
ansond | 0:137634ff4186 | 85 | #include "polarssl/ecp.h" |
ansond | 0:137634ff4186 | 86 | #endif |
ansond | 0:137634ff4186 | 87 | |
ansond | 0:137634ff4186 | 88 | #if defined(POLARSSL_ENTROPY_C) |
ansond | 0:137634ff4186 | 89 | #include "polarssl/entropy.h" |
ansond | 0:137634ff4186 | 90 | #endif |
ansond | 0:137634ff4186 | 91 | |
ansond | 0:137634ff4186 | 92 | #if defined(POLARSSL_GCM_C) |
ansond | 0:137634ff4186 | 93 | #include "polarssl/gcm.h" |
ansond | 0:137634ff4186 | 94 | #endif |
ansond | 0:137634ff4186 | 95 | |
ansond | 0:137634ff4186 | 96 | #if defined(POLARSSL_HMAC_DRBG_C) |
ansond | 0:137634ff4186 | 97 | #include "polarssl/hmac_drbg.h" |
ansond | 0:137634ff4186 | 98 | #endif |
ansond | 0:137634ff4186 | 99 | |
ansond | 0:137634ff4186 | 100 | #if defined(POLARSSL_MD_C) |
ansond | 0:137634ff4186 | 101 | #include "polarssl/md.h" |
ansond | 0:137634ff4186 | 102 | #endif |
ansond | 0:137634ff4186 | 103 | |
ansond | 0:137634ff4186 | 104 | #if defined(POLARSSL_MD2_C) |
ansond | 0:137634ff4186 | 105 | #include "polarssl/md2.h" |
ansond | 0:137634ff4186 | 106 | #endif |
ansond | 0:137634ff4186 | 107 | |
ansond | 0:137634ff4186 | 108 | #if defined(POLARSSL_MD4_C) |
ansond | 0:137634ff4186 | 109 | #include "polarssl/md4.h" |
ansond | 0:137634ff4186 | 110 | #endif |
ansond | 0:137634ff4186 | 111 | |
ansond | 0:137634ff4186 | 112 | #if defined(POLARSSL_MD5_C) |
ansond | 0:137634ff4186 | 113 | #include "polarssl/md5.h" |
ansond | 0:137634ff4186 | 114 | #endif |
ansond | 0:137634ff4186 | 115 | |
ansond | 0:137634ff4186 | 116 | #if defined(POLARSSL_NET_C) |
ansond | 0:137634ff4186 | 117 | #include "polarssl/net.h" |
ansond | 0:137634ff4186 | 118 | #endif |
ansond | 0:137634ff4186 | 119 | |
ansond | 0:137634ff4186 | 120 | #if defined(POLARSSL_OID_C) |
ansond | 0:137634ff4186 | 121 | #include "polarssl/oid.h" |
ansond | 0:137634ff4186 | 122 | #endif |
ansond | 0:137634ff4186 | 123 | |
ansond | 0:137634ff4186 | 124 | #if defined(POLARSSL_PADLOCK_C) |
ansond | 0:137634ff4186 | 125 | #include "polarssl/padlock.h" |
ansond | 0:137634ff4186 | 126 | #endif |
ansond | 0:137634ff4186 | 127 | |
ansond | 0:137634ff4186 | 128 | #if defined(POLARSSL_PBKDF2_C) |
ansond | 0:137634ff4186 | 129 | #include "polarssl/pbkdf2.h" |
ansond | 0:137634ff4186 | 130 | #endif |
ansond | 0:137634ff4186 | 131 | |
ansond | 0:137634ff4186 | 132 | #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) |
ansond | 0:137634ff4186 | 133 | #include "polarssl/pem.h" |
ansond | 0:137634ff4186 | 134 | #endif |
ansond | 0:137634ff4186 | 135 | |
ansond | 0:137634ff4186 | 136 | #if defined(POLARSSL_PK_C) |
ansond | 0:137634ff4186 | 137 | #include "polarssl/pk.h" |
ansond | 0:137634ff4186 | 138 | #endif |
ansond | 0:137634ff4186 | 139 | |
ansond | 0:137634ff4186 | 140 | #if defined(POLARSSL_PKCS12_C) |
ansond | 0:137634ff4186 | 141 | #include "polarssl/pkcs12.h" |
ansond | 0:137634ff4186 | 142 | #endif |
ansond | 0:137634ff4186 | 143 | |
ansond | 0:137634ff4186 | 144 | #if defined(POLARSSL_PKCS5_C) |
ansond | 0:137634ff4186 | 145 | #include "polarssl/pkcs5.h" |
ansond | 0:137634ff4186 | 146 | #endif |
ansond | 0:137634ff4186 | 147 | |
ansond | 0:137634ff4186 | 148 | #if defined(POLARSSL_RIPEMD160_C) |
ansond | 0:137634ff4186 | 149 | #include "polarssl/ripemd160.h" |
ansond | 0:137634ff4186 | 150 | #endif |
ansond | 0:137634ff4186 | 151 | |
ansond | 0:137634ff4186 | 152 | #if defined(POLARSSL_RSA_C) |
ansond | 0:137634ff4186 | 153 | #include "polarssl/rsa.h" |
ansond | 0:137634ff4186 | 154 | #endif |
ansond | 0:137634ff4186 | 155 | |
ansond | 0:137634ff4186 | 156 | #if defined(POLARSSL_SHA1_C) |
ansond | 0:137634ff4186 | 157 | #include "polarssl/sha1.h" |
ansond | 0:137634ff4186 | 158 | #endif |
ansond | 0:137634ff4186 | 159 | |
ansond | 0:137634ff4186 | 160 | #if defined(POLARSSL_SHA256_C) |
ansond | 0:137634ff4186 | 161 | #include "polarssl/sha256.h" |
ansond | 0:137634ff4186 | 162 | #endif |
ansond | 0:137634ff4186 | 163 | |
ansond | 0:137634ff4186 | 164 | #if defined(POLARSSL_SHA512_C) |
ansond | 0:137634ff4186 | 165 | #include "polarssl/sha512.h" |
ansond | 0:137634ff4186 | 166 | #endif |
ansond | 0:137634ff4186 | 167 | |
ansond | 0:137634ff4186 | 168 | #if defined(POLARSSL_SSL_TLS_C) |
ansond | 0:137634ff4186 | 169 | #include "polarssl/ssl.h" |
ansond | 0:137634ff4186 | 170 | #endif |
ansond | 0:137634ff4186 | 171 | |
ansond | 0:137634ff4186 | 172 | #if defined(POLARSSL_THREADING_C) |
ansond | 0:137634ff4186 | 173 | #include "polarssl/threading.h" |
ansond | 0:137634ff4186 | 174 | #endif |
ansond | 0:137634ff4186 | 175 | |
ansond | 0:137634ff4186 | 176 | #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) |
ansond | 0:137634ff4186 | 177 | #include "polarssl/x509.h" |
ansond | 0:137634ff4186 | 178 | #endif |
ansond | 0:137634ff4186 | 179 | |
ansond | 0:137634ff4186 | 180 | #if defined(POLARSSL_XTEA_C) |
ansond | 0:137634ff4186 | 181 | #include "polarssl/xtea.h" |
ansond | 0:137634ff4186 | 182 | #endif |
ansond | 0:137634ff4186 | 183 | |
ansond | 0:137634ff4186 | 184 | #if defined(_MSC_VER) && !defined snprintf && !defined(EFIX64) && \ |
ansond | 0:137634ff4186 | 185 | !defined(EFI32) |
ansond | 0:137634ff4186 | 186 | #define snprintf _snprintf |
ansond | 0:137634ff4186 | 187 | #endif |
ansond | 0:137634ff4186 | 188 | |
ansond | 0:137634ff4186 | 189 | void polarssl_strerror( int ret, char *buf, size_t buflen ) |
ansond | 0:137634ff4186 | 190 | { |
ansond | 0:137634ff4186 | 191 | size_t len; |
ansond | 0:137634ff4186 | 192 | int use_ret; |
ansond | 0:137634ff4186 | 193 | |
ansond | 0:137634ff4186 | 194 | if( buflen == 0 ) |
ansond | 0:137634ff4186 | 195 | return; |
ansond | 0:137634ff4186 | 196 | |
ansond | 0:137634ff4186 | 197 | memset( buf, 0x00, buflen ); |
ansond | 0:137634ff4186 | 198 | /* Reduce buflen to make sure MSVC _snprintf() ends with \0 as well */ |
ansond | 0:137634ff4186 | 199 | buflen -= 1; |
ansond | 0:137634ff4186 | 200 | |
ansond | 0:137634ff4186 | 201 | if( ret < 0 ) |
ansond | 0:137634ff4186 | 202 | ret = -ret; |
ansond | 0:137634ff4186 | 203 | |
ansond | 0:137634ff4186 | 204 | if( ret & 0xFF80 ) |
ansond | 0:137634ff4186 | 205 | { |
ansond | 0:137634ff4186 | 206 | use_ret = ret & 0xFF80; |
ansond | 0:137634ff4186 | 207 | |
ansond | 0:137634ff4186 | 208 | // High level error codes |
ansond | 0:137634ff4186 | 209 | // |
ansond | 0:137634ff4186 | 210 | // BEGIN generated code |
ansond | 0:137634ff4186 | 211 | #if defined(POLARSSL_CIPHER_C) |
ansond | 0:137634ff4186 | 212 | if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 213 | polarssl_snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); |
ansond | 0:137634ff4186 | 214 | if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 215 | polarssl_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 216 | if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 217 | polarssl_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); |
ansond | 0:137634ff4186 | 218 | if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) |
ansond | 0:137634ff4186 | 219 | polarssl_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); |
ansond | 0:137634ff4186 | 220 | if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) |
ansond | 0:137634ff4186 | 221 | polarssl_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); |
ansond | 0:137634ff4186 | 222 | if( use_ret == -(POLARSSL_ERR_CIPHER_AUTH_FAILED) ) |
ansond | 0:137634ff4186 | 223 | polarssl_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); |
ansond | 0:137634ff4186 | 224 | #endif /* POLARSSL_CIPHER_C */ |
ansond | 0:137634ff4186 | 225 | |
ansond | 0:137634ff4186 | 226 | #if defined(POLARSSL_DHM_C) |
ansond | 0:137634ff4186 | 227 | if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 228 | polarssl_snprintf( buf, buflen, "DHM - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 229 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) |
ansond | 0:137634ff4186 | 230 | polarssl_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); |
ansond | 0:137634ff4186 | 231 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) |
ansond | 0:137634ff4186 | 232 | polarssl_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); |
ansond | 0:137634ff4186 | 233 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) |
ansond | 0:137634ff4186 | 234 | polarssl_snprintf( buf, buflen, "DHM - Reading of the public values failed" ); |
ansond | 0:137634ff4186 | 235 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) |
ansond | 0:137634ff4186 | 236 | polarssl_snprintf( buf, buflen, "DHM - Making of the public value failed" ); |
ansond | 0:137634ff4186 | 237 | if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) |
ansond | 0:137634ff4186 | 238 | polarssl_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); |
ansond | 0:137634ff4186 | 239 | if( use_ret == -(POLARSSL_ERR_DHM_INVALID_FORMAT) ) |
ansond | 0:137634ff4186 | 240 | polarssl_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); |
ansond | 0:137634ff4186 | 241 | if( use_ret == -(POLARSSL_ERR_DHM_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 242 | polarssl_snprintf( buf, buflen, "DHM - Allocation of memory failed" ); |
ansond | 0:137634ff4186 | 243 | if( use_ret == -(POLARSSL_ERR_DHM_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 244 | polarssl_snprintf( buf, buflen, "DHM - Read/write of file failed" ); |
ansond | 0:137634ff4186 | 245 | #endif /* POLARSSL_DHM_C */ |
ansond | 0:137634ff4186 | 246 | |
ansond | 0:137634ff4186 | 247 | #if defined(POLARSSL_ECP_C) |
ansond | 0:137634ff4186 | 248 | if( use_ret == -(POLARSSL_ERR_ECP_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 249 | polarssl_snprintf( buf, buflen, "ECP - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 250 | if( use_ret == -(POLARSSL_ERR_ECP_BUFFER_TOO_SMALL) ) |
ansond | 0:137634ff4186 | 251 | polarssl_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); |
ansond | 0:137634ff4186 | 252 | if( use_ret == -(POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 253 | polarssl_snprintf( buf, buflen, "ECP - Requested curve not available" ); |
ansond | 0:137634ff4186 | 254 | if( use_ret == -(POLARSSL_ERR_ECP_VERIFY_FAILED) ) |
ansond | 0:137634ff4186 | 255 | polarssl_snprintf( buf, buflen, "ECP - The signature is not valid" ); |
ansond | 0:137634ff4186 | 256 | if( use_ret == -(POLARSSL_ERR_ECP_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 257 | polarssl_snprintf( buf, buflen, "ECP - Memory allocation failed" ); |
ansond | 0:137634ff4186 | 258 | if( use_ret == -(POLARSSL_ERR_ECP_RANDOM_FAILED) ) |
ansond | 0:137634ff4186 | 259 | polarssl_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); |
ansond | 0:137634ff4186 | 260 | if( use_ret == -(POLARSSL_ERR_ECP_INVALID_KEY) ) |
ansond | 0:137634ff4186 | 261 | polarssl_snprintf( buf, buflen, "ECP - Invalid private or public key" ); |
ansond | 0:137634ff4186 | 262 | if( use_ret == -(POLARSSL_ERR_ECP_SIG_LEN_MISMATCH) ) |
ansond | 0:137634ff4186 | 263 | polarssl_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" ); |
ansond | 0:137634ff4186 | 264 | #endif /* POLARSSL_ECP_C */ |
ansond | 0:137634ff4186 | 265 | |
ansond | 0:137634ff4186 | 266 | #if defined(POLARSSL_MD_C) |
ansond | 0:137634ff4186 | 267 | if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 268 | polarssl_snprintf( buf, buflen, "MD - The selected feature is not available" ); |
ansond | 0:137634ff4186 | 269 | if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 270 | polarssl_snprintf( buf, buflen, "MD - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 271 | if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 272 | polarssl_snprintf( buf, buflen, "MD - Failed to allocate memory" ); |
ansond | 0:137634ff4186 | 273 | if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 274 | polarssl_snprintf( buf, buflen, "MD - Opening or reading of file failed" ); |
ansond | 0:137634ff4186 | 275 | #endif /* POLARSSL_MD_C */ |
ansond | 0:137634ff4186 | 276 | |
ansond | 0:137634ff4186 | 277 | #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) |
ansond | 0:137634ff4186 | 278 | if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) |
ansond | 0:137634ff4186 | 279 | polarssl_snprintf( buf, buflen, "PEM - No PEM header or footer found" ); |
ansond | 0:137634ff4186 | 280 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) |
ansond | 0:137634ff4186 | 281 | polarssl_snprintf( buf, buflen, "PEM - PEM string is not as expected" ); |
ansond | 0:137634ff4186 | 282 | if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 283 | polarssl_snprintf( buf, buflen, "PEM - Failed to allocate memory" ); |
ansond | 0:137634ff4186 | 284 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) |
ansond | 0:137634ff4186 | 285 | polarssl_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); |
ansond | 0:137634ff4186 | 286 | if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) |
ansond | 0:137634ff4186 | 287 | polarssl_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); |
ansond | 0:137634ff4186 | 288 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) |
ansond | 0:137634ff4186 | 289 | polarssl_snprintf( buf, buflen, "PEM - Private key password can't be empty" ); |
ansond | 0:137634ff4186 | 290 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) |
ansond | 0:137634ff4186 | 291 | polarssl_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); |
ansond | 0:137634ff4186 | 292 | if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 293 | polarssl_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); |
ansond | 0:137634ff4186 | 294 | if( use_ret == -(POLARSSL_ERR_PEM_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 295 | polarssl_snprintf( buf, buflen, "PEM - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 296 | #endif /* POLARSSL_PEM_PARSE_C || POLARSSL_PEM_WRITE_C */ |
ansond | 0:137634ff4186 | 297 | |
ansond | 0:137634ff4186 | 298 | #if defined(POLARSSL_PK_C) |
ansond | 0:137634ff4186 | 299 | if( use_ret == -(POLARSSL_ERR_PK_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 300 | polarssl_snprintf( buf, buflen, "PK - Memory alloation failed" ); |
ansond | 0:137634ff4186 | 301 | if( use_ret == -(POLARSSL_ERR_PK_TYPE_MISMATCH) ) |
ansond | 0:137634ff4186 | 302 | polarssl_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); |
ansond | 0:137634ff4186 | 303 | if( use_ret == -(POLARSSL_ERR_PK_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 304 | polarssl_snprintf( buf, buflen, "PK - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 305 | if( use_ret == -(POLARSSL_ERR_PK_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 306 | polarssl_snprintf( buf, buflen, "PK - Read/write of file failed" ); |
ansond | 0:137634ff4186 | 307 | if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_VERSION) ) |
ansond | 0:137634ff4186 | 308 | polarssl_snprintf( buf, buflen, "PK - Unsupported key version" ); |
ansond | 0:137634ff4186 | 309 | if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_FORMAT) ) |
ansond | 0:137634ff4186 | 310 | polarssl_snprintf( buf, buflen, "PK - Invalid key tag or value" ); |
ansond | 0:137634ff4186 | 311 | if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_PK_ALG) ) |
ansond | 0:137634ff4186 | 312 | polarssl_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); |
ansond | 0:137634ff4186 | 313 | if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_REQUIRED) ) |
ansond | 0:137634ff4186 | 314 | polarssl_snprintf( buf, buflen, "PK - Private key password can't be empty" ); |
ansond | 0:137634ff4186 | 315 | if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_MISMATCH) ) |
ansond | 0:137634ff4186 | 316 | polarssl_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); |
ansond | 0:137634ff4186 | 317 | if( use_ret == -(POLARSSL_ERR_PK_INVALID_PUBKEY) ) |
ansond | 0:137634ff4186 | 318 | polarssl_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); |
ansond | 0:137634ff4186 | 319 | if( use_ret == -(POLARSSL_ERR_PK_INVALID_ALG) ) |
ansond | 0:137634ff4186 | 320 | polarssl_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); |
ansond | 0:137634ff4186 | 321 | if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE) ) |
ansond | 0:137634ff4186 | 322 | polarssl_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); |
ansond | 0:137634ff4186 | 323 | if( use_ret == -(POLARSSL_ERR_PK_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 324 | polarssl_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); |
ansond | 0:137634ff4186 | 325 | if( use_ret == -(POLARSSL_ERR_PK_SIG_LEN_MISMATCH) ) |
ansond | 0:137634ff4186 | 326 | polarssl_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" ); |
ansond | 0:137634ff4186 | 327 | #endif /* POLARSSL_PK_C */ |
ansond | 0:137634ff4186 | 328 | |
ansond | 0:137634ff4186 | 329 | #if defined(POLARSSL_PKCS12_C) |
ansond | 0:137634ff4186 | 330 | if( use_ret == -(POLARSSL_ERR_PKCS12_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 331 | polarssl_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 332 | if( use_ret == -(POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 333 | polarssl_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); |
ansond | 0:137634ff4186 | 334 | if( use_ret == -(POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT) ) |
ansond | 0:137634ff4186 | 335 | polarssl_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); |
ansond | 0:137634ff4186 | 336 | if( use_ret == -(POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH) ) |
ansond | 0:137634ff4186 | 337 | polarssl_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); |
ansond | 0:137634ff4186 | 338 | #endif /* POLARSSL_PKCS12_C */ |
ansond | 0:137634ff4186 | 339 | |
ansond | 0:137634ff4186 | 340 | #if defined(POLARSSL_PKCS5_C) |
ansond | 0:137634ff4186 | 341 | if( use_ret == -(POLARSSL_ERR_PKCS5_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 342 | polarssl_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 343 | if( use_ret == -(POLARSSL_ERR_PKCS5_INVALID_FORMAT) ) |
ansond | 0:137634ff4186 | 344 | polarssl_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); |
ansond | 0:137634ff4186 | 345 | if( use_ret == -(POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 346 | polarssl_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); |
ansond | 0:137634ff4186 | 347 | if( use_ret == -(POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH) ) |
ansond | 0:137634ff4186 | 348 | polarssl_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); |
ansond | 0:137634ff4186 | 349 | #endif /* POLARSSL_PKCS5_C */ |
ansond | 0:137634ff4186 | 350 | |
ansond | 0:137634ff4186 | 351 | #if defined(POLARSSL_RSA_C) |
ansond | 0:137634ff4186 | 352 | if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 353 | polarssl_snprintf( buf, buflen, "RSA - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 354 | if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) |
ansond | 0:137634ff4186 | 355 | polarssl_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); |
ansond | 0:137634ff4186 | 356 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) |
ansond | 0:137634ff4186 | 357 | polarssl_snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); |
ansond | 0:137634ff4186 | 358 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) |
ansond | 0:137634ff4186 | 359 | polarssl_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" ); |
ansond | 0:137634ff4186 | 360 | if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) |
ansond | 0:137634ff4186 | 361 | polarssl_snprintf( buf, buflen, "RSA - The public key operation failed" ); |
ansond | 0:137634ff4186 | 362 | if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) |
ansond | 0:137634ff4186 | 363 | polarssl_snprintf( buf, buflen, "RSA - The private key operation failed" ); |
ansond | 0:137634ff4186 | 364 | if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) |
ansond | 0:137634ff4186 | 365 | polarssl_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); |
ansond | 0:137634ff4186 | 366 | if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) |
ansond | 0:137634ff4186 | 367 | polarssl_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); |
ansond | 0:137634ff4186 | 368 | if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) |
ansond | 0:137634ff4186 | 369 | polarssl_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); |
ansond | 0:137634ff4186 | 370 | #endif /* POLARSSL_RSA_C */ |
ansond | 0:137634ff4186 | 371 | |
ansond | 0:137634ff4186 | 372 | #if defined(POLARSSL_SSL_TLS_C) |
ansond | 0:137634ff4186 | 373 | if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 374 | polarssl_snprintf( buf, buflen, "SSL - The requested feature is not available" ); |
ansond | 0:137634ff4186 | 375 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 376 | polarssl_snprintf( buf, buflen, "SSL - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 377 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) |
ansond | 0:137634ff4186 | 378 | polarssl_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); |
ansond | 0:137634ff4186 | 379 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) |
ansond | 0:137634ff4186 | 380 | polarssl_snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); |
ansond | 0:137634ff4186 | 381 | if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) |
ansond | 0:137634ff4186 | 382 | polarssl_snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); |
ansond | 0:137634ff4186 | 383 | if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) |
ansond | 0:137634ff4186 | 384 | polarssl_snprintf( buf, buflen, "SSL - An unknown cipher was received" ); |
ansond | 0:137634ff4186 | 385 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) |
ansond | 0:137634ff4186 | 386 | polarssl_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); |
ansond | 0:137634ff4186 | 387 | if( use_ret == -(POLARSSL_ERR_SSL_NO_RNG) ) |
ansond | 0:137634ff4186 | 388 | polarssl_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); |
ansond | 0:137634ff4186 | 389 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) |
ansond | 0:137634ff4186 | 390 | polarssl_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); |
ansond | 0:137634ff4186 | 391 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) |
ansond | 0:137634ff4186 | 392 | polarssl_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" ); |
ansond | 0:137634ff4186 | 393 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) |
ansond | 0:137634ff4186 | 394 | polarssl_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); |
ansond | 0:137634ff4186 | 395 | if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) |
ansond | 0:137634ff4186 | 396 | polarssl_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); |
ansond | 0:137634ff4186 | 397 | if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) |
ansond | 0:137634ff4186 | 398 | polarssl_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); |
ansond | 0:137634ff4186 | 399 | if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) |
ansond | 0:137634ff4186 | 400 | polarssl_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); |
ansond | 0:137634ff4186 | 401 | if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) |
ansond | 0:137634ff4186 | 402 | { |
ansond | 0:137634ff4186 | 403 | polarssl_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); |
ansond | 0:137634ff4186 | 404 | return; |
ansond | 0:137634ff4186 | 405 | } |
ansond | 0:137634ff4186 | 406 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) |
ansond | 0:137634ff4186 | 407 | polarssl_snprintf( buf, buflen, "SSL - Verification of our peer failed" ); |
ansond | 0:137634ff4186 | 408 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) |
ansond | 0:137634ff4186 | 409 | polarssl_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); |
ansond | 0:137634ff4186 | 410 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) |
ansond | 0:137634ff4186 | 411 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); |
ansond | 0:137634ff4186 | 412 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) |
ansond | 0:137634ff4186 | 413 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); |
ansond | 0:137634ff4186 | 414 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) |
ansond | 0:137634ff4186 | 415 | polarssl_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); |
ansond | 0:137634ff4186 | 416 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) |
ansond | 0:137634ff4186 | 417 | polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); |
ansond | 0:137634ff4186 | 418 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) |
ansond | 0:137634ff4186 | 419 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); |
ansond | 0:137634ff4186 | 420 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) |
ansond | 0:137634ff4186 | 421 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); |
ansond | 0:137634ff4186 | 422 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) |
ansond | 0:137634ff4186 | 423 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); |
ansond | 0:137634ff4186 | 424 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) |
ansond | 0:137634ff4186 | 425 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); |
ansond | 0:137634ff4186 | 426 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) |
ansond | 0:137634ff4186 | 427 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); |
ansond | 0:137634ff4186 | 428 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) |
ansond | 0:137634ff4186 | 429 | polarssl_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); |
ansond | 0:137634ff4186 | 430 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) |
ansond | 0:137634ff4186 | 431 | polarssl_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); |
ansond | 0:137634ff4186 | 432 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) |
ansond | 0:137634ff4186 | 433 | polarssl_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); |
ansond | 0:137634ff4186 | 434 | if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 435 | polarssl_snprintf( buf, buflen, "SSL - Memory allocation failed" ); |
ansond | 0:137634ff4186 | 436 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FAILED) ) |
ansond | 0:137634ff4186 | 437 | polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); |
ansond | 0:137634ff4186 | 438 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) |
ansond | 0:137634ff4186 | 439 | polarssl_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); |
ansond | 0:137634ff4186 | 440 | if( use_ret == -(POLARSSL_ERR_SSL_COMPRESSION_FAILED) ) |
ansond | 0:137634ff4186 | 441 | polarssl_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); |
ansond | 0:137634ff4186 | 442 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) |
ansond | 0:137634ff4186 | 443 | polarssl_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); |
ansond | 0:137634ff4186 | 444 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) |
ansond | 0:137634ff4186 | 445 | polarssl_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); |
ansond | 0:137634ff4186 | 446 | if( use_ret == -(POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED) ) |
ansond | 0:137634ff4186 | 447 | polarssl_snprintf( buf, buflen, "SSL - Session ticket has expired" ); |
ansond | 0:137634ff4186 | 448 | if( use_ret == -(POLARSSL_ERR_SSL_PK_TYPE_MISMATCH) ) |
ansond | 0:137634ff4186 | 449 | polarssl_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); |
ansond | 0:137634ff4186 | 450 | if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_IDENTITY) ) |
ansond | 0:137634ff4186 | 451 | polarssl_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); |
ansond | 0:137634ff4186 | 452 | if( use_ret == -(POLARSSL_ERR_SSL_INTERNAL_ERROR) ) |
ansond | 0:137634ff4186 | 453 | polarssl_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); |
ansond | 0:137634ff4186 | 454 | if( use_ret == -(POLARSSL_ERR_SSL_COUNTER_WRAPPING) ) |
ansond | 0:137634ff4186 | 455 | polarssl_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); |
ansond | 0:137634ff4186 | 456 | if( use_ret == -(POLARSSL_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) ) |
ansond | 0:137634ff4186 | 457 | polarssl_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" ); |
ansond | 0:137634ff4186 | 458 | if( use_ret == -(POLARSSL_ERR_SSL_NO_USABLE_CIPHERSUITE) ) |
ansond | 0:137634ff4186 | 459 | polarssl_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); |
ansond | 0:137634ff4186 | 460 | #endif /* POLARSSL_SSL_TLS_C */ |
ansond | 0:137634ff4186 | 461 | |
ansond | 0:137634ff4186 | 462 | #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) |
ansond | 0:137634ff4186 | 463 | if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 464 | polarssl_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); |
ansond | 0:137634ff4186 | 465 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_OID) ) |
ansond | 0:137634ff4186 | 466 | polarssl_snprintf( buf, buflen, "X509 - Requested OID is unknown" ); |
ansond | 0:137634ff4186 | 467 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_FORMAT) ) |
ansond | 0:137634ff4186 | 468 | polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); |
ansond | 0:137634ff4186 | 469 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_VERSION) ) |
ansond | 0:137634ff4186 | 470 | polarssl_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); |
ansond | 0:137634ff4186 | 471 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_SERIAL) ) |
ansond | 0:137634ff4186 | 472 | polarssl_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); |
ansond | 0:137634ff4186 | 473 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_ALG) ) |
ansond | 0:137634ff4186 | 474 | polarssl_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); |
ansond | 0:137634ff4186 | 475 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_NAME) ) |
ansond | 0:137634ff4186 | 476 | polarssl_snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); |
ansond | 0:137634ff4186 | 477 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_DATE) ) |
ansond | 0:137634ff4186 | 478 | polarssl_snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); |
ansond | 0:137634ff4186 | 479 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_SIGNATURE) ) |
ansond | 0:137634ff4186 | 480 | polarssl_snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); |
ansond | 0:137634ff4186 | 481 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_EXTENSIONS) ) |
ansond | 0:137634ff4186 | 482 | polarssl_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); |
ansond | 0:137634ff4186 | 483 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_VERSION) ) |
ansond | 0:137634ff4186 | 484 | polarssl_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); |
ansond | 0:137634ff4186 | 485 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_SIG_ALG) ) |
ansond | 0:137634ff4186 | 486 | polarssl_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); |
ansond | 0:137634ff4186 | 487 | if( use_ret == -(POLARSSL_ERR_X509_SIG_MISMATCH) ) |
ansond | 0:137634ff4186 | 488 | polarssl_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::x509_crt sig_oid)" ); |
ansond | 0:137634ff4186 | 489 | if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) |
ansond | 0:137634ff4186 | 490 | polarssl_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); |
ansond | 0:137634ff4186 | 491 | if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) |
ansond | 0:137634ff4186 | 492 | polarssl_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); |
ansond | 0:137634ff4186 | 493 | if( use_ret == -(POLARSSL_ERR_X509_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 494 | polarssl_snprintf( buf, buflen, "X509 - Input invalid" ); |
ansond | 0:137634ff4186 | 495 | if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 496 | polarssl_snprintf( buf, buflen, "X509 - Allocation of memory failed" ); |
ansond | 0:137634ff4186 | 497 | if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 498 | polarssl_snprintf( buf, buflen, "X509 - Read/write of file failed" ); |
ansond | 0:137634ff4186 | 499 | #endif /* POLARSSL_X509_USE,X509_CREATE_C */ |
ansond | 0:137634ff4186 | 500 | // END generated code |
ansond | 0:137634ff4186 | 501 | |
ansond | 0:137634ff4186 | 502 | if( strlen( buf ) == 0 ) |
ansond | 0:137634ff4186 | 503 | polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
ansond | 0:137634ff4186 | 504 | } |
ansond | 0:137634ff4186 | 505 | |
ansond | 0:137634ff4186 | 506 | use_ret = ret & ~0xFF80; |
ansond | 0:137634ff4186 | 507 | |
ansond | 0:137634ff4186 | 508 | if( use_ret == 0 ) |
ansond | 0:137634ff4186 | 509 | return; |
ansond | 0:137634ff4186 | 510 | |
ansond | 0:137634ff4186 | 511 | // If high level code is present, make a concatenation between both |
ansond | 0:137634ff4186 | 512 | // error strings. |
ansond | 0:137634ff4186 | 513 | // |
ansond | 0:137634ff4186 | 514 | len = strlen( buf ); |
ansond | 0:137634ff4186 | 515 | |
ansond | 0:137634ff4186 | 516 | if( len > 0 ) |
ansond | 0:137634ff4186 | 517 | { |
ansond | 0:137634ff4186 | 518 | if( buflen - len < 5 ) |
ansond | 0:137634ff4186 | 519 | return; |
ansond | 0:137634ff4186 | 520 | |
ansond | 0:137634ff4186 | 521 | polarssl_snprintf( buf + len, buflen - len, " : " ); |
ansond | 0:137634ff4186 | 522 | |
ansond | 0:137634ff4186 | 523 | buf += len + 3; |
ansond | 0:137634ff4186 | 524 | buflen -= len + 3; |
ansond | 0:137634ff4186 | 525 | } |
ansond | 0:137634ff4186 | 526 | |
ansond | 0:137634ff4186 | 527 | // Low level error codes |
ansond | 0:137634ff4186 | 528 | // |
ansond | 0:137634ff4186 | 529 | // BEGIN generated code |
ansond | 0:137634ff4186 | 530 | #if defined(POLARSSL_AES_C) |
ansond | 0:137634ff4186 | 531 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) |
ansond | 0:137634ff4186 | 532 | polarssl_snprintf( buf, buflen, "AES - Invalid key length" ); |
ansond | 0:137634ff4186 | 533 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) |
ansond | 0:137634ff4186 | 534 | polarssl_snprintf( buf, buflen, "AES - Invalid data input length" ); |
ansond | 0:137634ff4186 | 535 | #endif /* POLARSSL_AES_C */ |
ansond | 0:137634ff4186 | 536 | |
ansond | 0:137634ff4186 | 537 | #if defined(POLARSSL_ASN1_PARSE_C) |
ansond | 0:137634ff4186 | 538 | if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) |
ansond | 0:137634ff4186 | 539 | polarssl_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); |
ansond | 0:137634ff4186 | 540 | if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) |
ansond | 0:137634ff4186 | 541 | polarssl_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); |
ansond | 0:137634ff4186 | 542 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) |
ansond | 0:137634ff4186 | 543 | polarssl_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); |
ansond | 0:137634ff4186 | 544 | if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) |
ansond | 0:137634ff4186 | 545 | polarssl_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); |
ansond | 0:137634ff4186 | 546 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) |
ansond | 0:137634ff4186 | 547 | polarssl_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); |
ansond | 0:137634ff4186 | 548 | if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 549 | polarssl_snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); |
ansond | 0:137634ff4186 | 550 | if( use_ret == -(POLARSSL_ERR_ASN1_BUF_TOO_SMALL) ) |
ansond | 0:137634ff4186 | 551 | polarssl_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); |
ansond | 0:137634ff4186 | 552 | #endif /* POLARSSL_ASN1_PARSE_C */ |
ansond | 0:137634ff4186 | 553 | |
ansond | 0:137634ff4186 | 554 | #if defined(POLARSSL_BASE64_C) |
ansond | 0:137634ff4186 | 555 | if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) |
ansond | 0:137634ff4186 | 556 | polarssl_snprintf( buf, buflen, "BASE64 - Output buffer too small" ); |
ansond | 0:137634ff4186 | 557 | if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) |
ansond | 0:137634ff4186 | 558 | polarssl_snprintf( buf, buflen, "BASE64 - Invalid character in input" ); |
ansond | 0:137634ff4186 | 559 | #endif /* POLARSSL_BASE64_C */ |
ansond | 0:137634ff4186 | 560 | |
ansond | 0:137634ff4186 | 561 | #if defined(POLARSSL_BIGNUM_C) |
ansond | 0:137634ff4186 | 562 | if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 563 | polarssl_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); |
ansond | 0:137634ff4186 | 564 | if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 565 | polarssl_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 566 | if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) |
ansond | 0:137634ff4186 | 567 | polarssl_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); |
ansond | 0:137634ff4186 | 568 | if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) |
ansond | 0:137634ff4186 | 569 | polarssl_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); |
ansond | 0:137634ff4186 | 570 | if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) |
ansond | 0:137634ff4186 | 571 | polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); |
ansond | 0:137634ff4186 | 572 | if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) |
ansond | 0:137634ff4186 | 573 | polarssl_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); |
ansond | 0:137634ff4186 | 574 | if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) |
ansond | 0:137634ff4186 | 575 | polarssl_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); |
ansond | 0:137634ff4186 | 576 | if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) |
ansond | 0:137634ff4186 | 577 | polarssl_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); |
ansond | 0:137634ff4186 | 578 | #endif /* POLARSSL_BIGNUM_C */ |
ansond | 0:137634ff4186 | 579 | |
ansond | 0:137634ff4186 | 580 | #if defined(POLARSSL_BLOWFISH_C) |
ansond | 0:137634ff4186 | 581 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) |
ansond | 0:137634ff4186 | 582 | polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); |
ansond | 0:137634ff4186 | 583 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) |
ansond | 0:137634ff4186 | 584 | polarssl_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); |
ansond | 0:137634ff4186 | 585 | #endif /* POLARSSL_BLOWFISH_C */ |
ansond | 0:137634ff4186 | 586 | |
ansond | 0:137634ff4186 | 587 | #if defined(POLARSSL_CAMELLIA_C) |
ansond | 0:137634ff4186 | 588 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) |
ansond | 0:137634ff4186 | 589 | polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); |
ansond | 0:137634ff4186 | 590 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) |
ansond | 0:137634ff4186 | 591 | polarssl_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); |
ansond | 0:137634ff4186 | 592 | #endif /* POLARSSL_CAMELLIA_C */ |
ansond | 0:137634ff4186 | 593 | |
ansond | 0:137634ff4186 | 594 | #if defined(POLARSSL_CCM_C) |
ansond | 0:137634ff4186 | 595 | if( use_ret == -(POLARSSL_ERR_CCM_BAD_INPUT) ) |
ansond | 0:137634ff4186 | 596 | polarssl_snprintf( buf, buflen, "CCM - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 597 | if( use_ret == -(POLARSSL_ERR_CCM_AUTH_FAILED) ) |
ansond | 0:137634ff4186 | 598 | polarssl_snprintf( buf, buflen, "CCM - Authenticated decryption failed" ); |
ansond | 0:137634ff4186 | 599 | #endif /* POLARSSL_CCM_C */ |
ansond | 0:137634ff4186 | 600 | |
ansond | 0:137634ff4186 | 601 | #if defined(POLARSSL_CTR_DRBG_C) |
ansond | 0:137634ff4186 | 602 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) |
ansond | 0:137634ff4186 | 603 | polarssl_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); |
ansond | 0:137634ff4186 | 604 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) |
ansond | 0:137634ff4186 | 605 | polarssl_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); |
ansond | 0:137634ff4186 | 606 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) |
ansond | 0:137634ff4186 | 607 | polarssl_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); |
ansond | 0:137634ff4186 | 608 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 609 | polarssl_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); |
ansond | 0:137634ff4186 | 610 | #endif /* POLARSSL_CTR_DRBG_C */ |
ansond | 0:137634ff4186 | 611 | |
ansond | 0:137634ff4186 | 612 | #if defined(POLARSSL_DES_C) |
ansond | 0:137634ff4186 | 613 | if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) |
ansond | 0:137634ff4186 | 614 | polarssl_snprintf( buf, buflen, "DES - The data input has an invalid length" ); |
ansond | 0:137634ff4186 | 615 | #endif /* POLARSSL_DES_C */ |
ansond | 0:137634ff4186 | 616 | |
ansond | 0:137634ff4186 | 617 | #if defined(POLARSSL_ENTROPY_C) |
ansond | 0:137634ff4186 | 618 | if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) |
ansond | 0:137634ff4186 | 619 | polarssl_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); |
ansond | 0:137634ff4186 | 620 | if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) |
ansond | 0:137634ff4186 | 621 | polarssl_snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); |
ansond | 0:137634ff4186 | 622 | if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) |
ansond | 0:137634ff4186 | 623 | polarssl_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); |
ansond | 0:137634ff4186 | 624 | if( use_ret == -(POLARSSL_ERR_ENTROPY_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 625 | polarssl_snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); |
ansond | 0:137634ff4186 | 626 | #endif /* POLARSSL_ENTROPY_C */ |
ansond | 0:137634ff4186 | 627 | |
ansond | 0:137634ff4186 | 628 | #if defined(POLARSSL_GCM_C) |
ansond | 0:137634ff4186 | 629 | if( use_ret == -(POLARSSL_ERR_GCM_AUTH_FAILED) ) |
ansond | 0:137634ff4186 | 630 | polarssl_snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); |
ansond | 0:137634ff4186 | 631 | if( use_ret == -(POLARSSL_ERR_GCM_BAD_INPUT) ) |
ansond | 0:137634ff4186 | 632 | polarssl_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 633 | #endif /* POLARSSL_GCM_C */ |
ansond | 0:137634ff4186 | 634 | |
ansond | 0:137634ff4186 | 635 | #if defined(POLARSSL_HMAC_DRBG_C) |
ansond | 0:137634ff4186 | 636 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) |
ansond | 0:137634ff4186 | 637 | polarssl_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); |
ansond | 0:137634ff4186 | 638 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) |
ansond | 0:137634ff4186 | 639 | polarssl_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); |
ansond | 0:137634ff4186 | 640 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 641 | polarssl_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); |
ansond | 0:137634ff4186 | 642 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) |
ansond | 0:137634ff4186 | 643 | polarssl_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); |
ansond | 0:137634ff4186 | 644 | #endif /* POLARSSL_HMAC_DRBG_C */ |
ansond | 0:137634ff4186 | 645 | |
ansond | 0:137634ff4186 | 646 | #if defined(POLARSSL_MD2_C) |
ansond | 0:137634ff4186 | 647 | if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 648 | polarssl_snprintf( buf, buflen, "MD2 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 649 | #endif /* POLARSSL_MD2_C */ |
ansond | 0:137634ff4186 | 650 | |
ansond | 0:137634ff4186 | 651 | #if defined(POLARSSL_MD4_C) |
ansond | 0:137634ff4186 | 652 | if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 653 | polarssl_snprintf( buf, buflen, "MD4 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 654 | #endif /* POLARSSL_MD4_C */ |
ansond | 0:137634ff4186 | 655 | |
ansond | 0:137634ff4186 | 656 | #if defined(POLARSSL_MD5_C) |
ansond | 0:137634ff4186 | 657 | if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 658 | polarssl_snprintf( buf, buflen, "MD5 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 659 | #endif /* POLARSSL_MD5_C */ |
ansond | 0:137634ff4186 | 660 | |
ansond | 0:137634ff4186 | 661 | #if defined(POLARSSL_NET_C) |
ansond | 0:137634ff4186 | 662 | if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) |
ansond | 0:137634ff4186 | 663 | polarssl_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); |
ansond | 0:137634ff4186 | 664 | if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) |
ansond | 0:137634ff4186 | 665 | polarssl_snprintf( buf, buflen, "NET - Failed to open a socket" ); |
ansond | 0:137634ff4186 | 666 | if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) |
ansond | 0:137634ff4186 | 667 | polarssl_snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); |
ansond | 0:137634ff4186 | 668 | if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) |
ansond | 0:137634ff4186 | 669 | polarssl_snprintf( buf, buflen, "NET - Binding of the socket failed" ); |
ansond | 0:137634ff4186 | 670 | if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) |
ansond | 0:137634ff4186 | 671 | polarssl_snprintf( buf, buflen, "NET - Could not listen on the socket" ); |
ansond | 0:137634ff4186 | 672 | if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) |
ansond | 0:137634ff4186 | 673 | polarssl_snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); |
ansond | 0:137634ff4186 | 674 | if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) |
ansond | 0:137634ff4186 | 675 | polarssl_snprintf( buf, buflen, "NET - Reading information from the socket failed" ); |
ansond | 0:137634ff4186 | 676 | if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) |
ansond | 0:137634ff4186 | 677 | polarssl_snprintf( buf, buflen, "NET - Sending information through the socket failed" ); |
ansond | 0:137634ff4186 | 678 | if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) |
ansond | 0:137634ff4186 | 679 | polarssl_snprintf( buf, buflen, "NET - Connection was reset by peer" ); |
ansond | 0:137634ff4186 | 680 | if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) |
ansond | 0:137634ff4186 | 681 | polarssl_snprintf( buf, buflen, "NET - Connection requires a read call" ); |
ansond | 0:137634ff4186 | 682 | if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) |
ansond | 0:137634ff4186 | 683 | polarssl_snprintf( buf, buflen, "NET - Connection requires a write call" ); |
ansond | 0:137634ff4186 | 684 | #endif /* POLARSSL_NET_C */ |
ansond | 0:137634ff4186 | 685 | |
ansond | 0:137634ff4186 | 686 | #if defined(POLARSSL_OID_C) |
ansond | 0:137634ff4186 | 687 | if( use_ret == -(POLARSSL_ERR_OID_NOT_FOUND) ) |
ansond | 0:137634ff4186 | 688 | polarssl_snprintf( buf, buflen, "OID - OID is not found" ); |
ansond | 0:137634ff4186 | 689 | if( use_ret == -(POLARSSL_ERR_OID_BUF_TOO_SMALL) ) |
ansond | 0:137634ff4186 | 690 | polarssl_snprintf( buf, buflen, "OID - output buffer is too small" ); |
ansond | 0:137634ff4186 | 691 | #endif /* POLARSSL_OID_C */ |
ansond | 0:137634ff4186 | 692 | |
ansond | 0:137634ff4186 | 693 | #if defined(POLARSSL_PADLOCK_C) |
ansond | 0:137634ff4186 | 694 | if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) |
ansond | 0:137634ff4186 | 695 | polarssl_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); |
ansond | 0:137634ff4186 | 696 | #endif /* POLARSSL_PADLOCK_C */ |
ansond | 0:137634ff4186 | 697 | |
ansond | 0:137634ff4186 | 698 | #if defined(POLARSSL_PBKDF2_C) |
ansond | 0:137634ff4186 | 699 | if( use_ret == -(POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 700 | polarssl_snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 701 | #endif /* POLARSSL_PBKDF2_C */ |
ansond | 0:137634ff4186 | 702 | |
ansond | 0:137634ff4186 | 703 | #if defined(POLARSSL_RIPEMD160_C) |
ansond | 0:137634ff4186 | 704 | if( use_ret == -(POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 705 | polarssl_snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 706 | #endif /* POLARSSL_RIPEMD160_C */ |
ansond | 0:137634ff4186 | 707 | |
ansond | 0:137634ff4186 | 708 | #if defined(POLARSSL_SHA1_C) |
ansond | 0:137634ff4186 | 709 | if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 710 | polarssl_snprintf( buf, buflen, "SHA1 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 711 | #endif /* POLARSSL_SHA1_C */ |
ansond | 0:137634ff4186 | 712 | |
ansond | 0:137634ff4186 | 713 | #if defined(POLARSSL_SHA256_C) |
ansond | 0:137634ff4186 | 714 | if( use_ret == -(POLARSSL_ERR_SHA256_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 715 | polarssl_snprintf( buf, buflen, "SHA256 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 716 | #endif /* POLARSSL_SHA256_C */ |
ansond | 0:137634ff4186 | 717 | |
ansond | 0:137634ff4186 | 718 | #if defined(POLARSSL_SHA512_C) |
ansond | 0:137634ff4186 | 719 | if( use_ret == -(POLARSSL_ERR_SHA512_FILE_IO_ERROR) ) |
ansond | 0:137634ff4186 | 720 | polarssl_snprintf( buf, buflen, "SHA512 - Read/write error in file" ); |
ansond | 0:137634ff4186 | 721 | #endif /* POLARSSL_SHA512_C */ |
ansond | 0:137634ff4186 | 722 | |
ansond | 0:137634ff4186 | 723 | #if defined(POLARSSL_THREADING_C) |
ansond | 0:137634ff4186 | 724 | if( use_ret == -(POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE) ) |
ansond | 0:137634ff4186 | 725 | polarssl_snprintf( buf, buflen, "THREADING - The selected feature is not available" ); |
ansond | 0:137634ff4186 | 726 | if( use_ret == -(POLARSSL_ERR_THREADING_BAD_INPUT_DATA) ) |
ansond | 0:137634ff4186 | 727 | polarssl_snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); |
ansond | 0:137634ff4186 | 728 | if( use_ret == -(POLARSSL_ERR_THREADING_MUTEX_ERROR) ) |
ansond | 0:137634ff4186 | 729 | polarssl_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); |
ansond | 0:137634ff4186 | 730 | #endif /* POLARSSL_THREADING_C */ |
ansond | 0:137634ff4186 | 731 | |
ansond | 0:137634ff4186 | 732 | #if defined(POLARSSL_XTEA_C) |
ansond | 0:137634ff4186 | 733 | if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) |
ansond | 0:137634ff4186 | 734 | polarssl_snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); |
ansond | 0:137634ff4186 | 735 | #endif /* POLARSSL_XTEA_C */ |
ansond | 0:137634ff4186 | 736 | // END generated code |
ansond | 0:137634ff4186 | 737 | |
ansond | 0:137634ff4186 | 738 | if( strlen( buf ) != 0 ) |
ansond | 0:137634ff4186 | 739 | return; |
ansond | 0:137634ff4186 | 740 | |
ansond | 0:137634ff4186 | 741 | polarssl_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
ansond | 0:137634ff4186 | 742 | } |
ansond | 0:137634ff4186 | 743 | |
ansond | 0:137634ff4186 | 744 | #if defined(POLARSSL_ERROR_STRERROR_BC) |
ansond | 0:137634ff4186 | 745 | void error_strerror( int ret, char *buf, size_t buflen ) |
ansond | 0:137634ff4186 | 746 | { |
ansond | 0:137634ff4186 | 747 | polarssl_strerror( ret, buf, buflen ); |
ansond | 0:137634ff4186 | 748 | } |
ansond | 0:137634ff4186 | 749 | #endif /* POLARSSL_ERROR_STRERROR_BC */ |
ansond | 0:137634ff4186 | 750 | |
ansond | 0:137634ff4186 | 751 | #else /* POLARSSL_ERROR_C */ |
ansond | 0:137634ff4186 | 752 | |
ansond | 0:137634ff4186 | 753 | #if defined(POLARSSL_ERROR_STRERROR_DUMMY) |
ansond | 0:137634ff4186 | 754 | |
ansond | 0:137634ff4186 | 755 | /* |
ansond | 0:137634ff4186 | 756 | * Provide an non-function in case POLARSSL_ERROR_C is not defined |
ansond | 0:137634ff4186 | 757 | */ |
ansond | 0:137634ff4186 | 758 | void polarssl_strerror( int ret, char *buf, size_t buflen ) |
ansond | 0:137634ff4186 | 759 | { |
ansond | 0:137634ff4186 | 760 | ((void) ret); |
ansond | 0:137634ff4186 | 761 | |
ansond | 0:137634ff4186 | 762 | if( buflen > 0 ) |
ansond | 0:137634ff4186 | 763 | buf[0] = '\0'; |
ansond | 0:137634ff4186 | 764 | } |
ansond | 0:137634ff4186 | 765 | |
ansond | 0:137634ff4186 | 766 | #if defined(POLARSSL_ERROR_STRERROR_BC) |
ansond | 0:137634ff4186 | 767 | void error_strerror( int ret, char *buf, size_t buflen ) |
ansond | 0:137634ff4186 | 768 | { |
ansond | 0:137634ff4186 | 769 | polarssl_strerror( ret, buf, buflen ); |
ansond | 0:137634ff4186 | 770 | } |
ansond | 0:137634ff4186 | 771 | #endif /* POLARSSL_ERROR_STRERROR_BC */ |
ansond | 0:137634ff4186 | 772 | #endif /* POLARSSL_ERROR_STRERROR_DUMMY */ |
ansond | 0:137634ff4186 | 773 | |
ansond | 0:137634ff4186 | 774 | #endif /* POLARSSL_ERROR_C */ |
ansond | 0:137634ff4186 | 775 |