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