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