Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Error message information |
| 3 | * |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006-2012, 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 | |
| 26 | #include "polarssl/config.h" |
| 27 | |
| 28 | #if defined(POLARSSL_ERROR_C) |
| 29 | |
| 30 | #if defined(POLARSSL_AES_C) |
| 31 | #include "polarssl/aes.h" |
| 32 | #endif |
| 33 | |
| 34 | #if defined(POLARSSL_BASE64_C) |
| 35 | #include "polarssl/base64.h" |
| 36 | #endif |
| 37 | |
| 38 | #if defined(POLARSSL_BIGNUM_C) |
| 39 | #include "polarssl/bignum.h" |
| 40 | #endif |
| 41 | |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 42 | #if defined(POLARSSL_BLOWFISH_C) |
| 43 | #include "polarssl/blowfish.h" |
| 44 | #endif |
| 45 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 46 | #if defined(POLARSSL_CAMELLIA_C) |
| 47 | #include "polarssl/camellia.h" |
| 48 | #endif |
| 49 | |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 50 | #if defined(POLARSSL_CIPHER_C) |
| 51 | #include "polarssl/cipher.h" |
| 52 | #endif |
| 53 | |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 54 | #if defined(POLARSSL_CTR_DRBG_C) |
| 55 | #include "polarssl/ctr_drbg.h" |
| 56 | #endif |
| 57 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 58 | #if defined(POLARSSL_DES_C) |
| 59 | #include "polarssl/des.h" |
| 60 | #endif |
| 61 | |
| 62 | #if defined(POLARSSL_DHM_C) |
| 63 | #include "polarssl/dhm.h" |
| 64 | #endif |
| 65 | |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 66 | #if defined(POLARSSL_ENTROPY_C) |
| 67 | #include "polarssl/entropy.h" |
| 68 | #endif |
| 69 | |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 70 | #if defined(POLARSSL_GCM_C) |
| 71 | #include "polarssl/gcm.h" |
| 72 | #endif |
| 73 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 74 | #if defined(POLARSSL_MD_C) |
| 75 | #include "polarssl/md.h" |
| 76 | #endif |
| 77 | |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 78 | #if defined(POLARSSL_MD2_C) |
| 79 | #include "polarssl/md2.h" |
| 80 | #endif |
| 81 | |
| 82 | #if defined(POLARSSL_MD4_C) |
| 83 | #include "polarssl/md4.h" |
| 84 | #endif |
| 85 | |
| 86 | #if defined(POLARSSL_MD5_C) |
| 87 | #include "polarssl/md5.h" |
| 88 | #endif |
| 89 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 90 | #if defined(POLARSSL_NET_C) |
| 91 | #include "polarssl/net.h" |
| 92 | #endif |
| 93 | |
| 94 | #if defined(POLARSSL_PADLOCK_C) |
| 95 | #include "polarssl/padlock.h" |
| 96 | #endif |
| 97 | |
Paul Bakker | d14277d | 2012-09-26 15:19:05 +0000 | [diff] [blame] | 98 | #if defined(POLARSSL_PBKDF2_C) |
| 99 | #include "polarssl/pbkdf2.h" |
| 100 | #endif |
| 101 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 102 | #if defined(POLARSSL_PEM_C) |
| 103 | #include "polarssl/pem.h" |
| 104 | #endif |
| 105 | |
| 106 | #if defined(POLARSSL_RSA_C) |
| 107 | #include "polarssl/rsa.h" |
| 108 | #endif |
| 109 | |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 110 | #if defined(POLARSSL_SHA1_C) |
| 111 | #include "polarssl/sha1.h" |
| 112 | #endif |
| 113 | |
| 114 | #if defined(POLARSSL_SHA2_C) |
| 115 | #include "polarssl/sha2.h" |
| 116 | #endif |
| 117 | |
| 118 | #if defined(POLARSSL_SHA4_C) |
| 119 | #include "polarssl/sha4.h" |
| 120 | #endif |
| 121 | |
Paul Bakker | 831a755 | 2011-05-18 13:32:51 +0000 | [diff] [blame] | 122 | #if defined(POLARSSL_SSL_TLS_C) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 123 | #include "polarssl/ssl.h" |
| 124 | #endif |
| 125 | |
| 126 | #if defined(POLARSSL_X509_PARSE_C) |
| 127 | #include "polarssl/x509.h" |
| 128 | #endif |
| 129 | |
| 130 | #if defined(POLARSSL_XTEA_C) |
| 131 | #include "polarssl/xtea.h" |
| 132 | #endif |
| 133 | |
| 134 | |
| 135 | #include <string.h> |
| 136 | |
Paul Bakker | dceecd8 | 2011-11-15 16:38:34 +0000 | [diff] [blame] | 137 | #if defined _MSC_VER && !defined snprintf |
| 138 | #define snprintf _snprintf |
| 139 | #endif |
| 140 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 141 | void error_strerror( int ret, char *buf, size_t buflen ) |
| 142 | { |
| 143 | size_t len; |
| 144 | int use_ret; |
| 145 | |
| 146 | memset( buf, 0x00, buflen ); |
| 147 | |
| 148 | if( ret < 0 ) |
| 149 | ret = -ret; |
| 150 | |
| 151 | if( ret & 0xFF80 ) |
| 152 | { |
| 153 | use_ret = ret & 0xFF80; |
| 154 | |
| 155 | // High level error codes |
| 156 | // |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 157 | #if defined(POLARSSL_CIPHER_C) |
| 158 | if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) |
| 159 | snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); |
| 160 | if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) |
| 161 | snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); |
| 162 | if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) |
| 163 | snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); |
| 164 | if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) |
| 165 | snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); |
| 166 | if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) |
| 167 | snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); |
| 168 | #endif /* POLARSSL_CIPHER_C */ |
| 169 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 170 | #if defined(POLARSSL_DHM_C) |
| 171 | if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) |
| 172 | snprintf( buf, buflen, "DHM - Bad input parameters to function" ); |
| 173 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) |
| 174 | snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); |
| 175 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) |
| 176 | snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); |
| 177 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) |
| 178 | snprintf( buf, buflen, "DHM - Reading of the public values failed" ); |
| 179 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) |
Paul Bakker | 05ef835 | 2012-05-08 09:17:57 +0000 | [diff] [blame] | 180 | snprintf( buf, buflen, "DHM - Making of the public value failed" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 181 | if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) |
| 182 | snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); |
| 183 | #endif /* POLARSSL_DHM_C */ |
| 184 | |
| 185 | #if defined(POLARSSL_MD_C) |
| 186 | if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) |
| 187 | snprintf( buf, buflen, "MD - The selected feature is not available" ); |
Paul Bakker | 9c021ad | 2011-06-09 15:55:11 +0000 | [diff] [blame] | 188 | if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) |
| 189 | snprintf( buf, buflen, "MD - Bad input parameters to function" ); |
| 190 | if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) |
| 191 | snprintf( buf, buflen, "MD - Failed to allocate memory" ); |
Paul Bakker | 8913f82 | 2012-01-14 18:07:41 +0000 | [diff] [blame] | 192 | if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) |
| 193 | snprintf( buf, buflen, "MD - Opening or reading of file failed" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 194 | #endif /* POLARSSL_MD_C */ |
| 195 | |
| 196 | #if defined(POLARSSL_PEM_C) |
| 197 | if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_PRESENT) ) |
| 198 | snprintf( buf, buflen, "PEM - No PEM header found" ); |
| 199 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) |
| 200 | snprintf( buf, buflen, "PEM - PEM string is not as expected" ); |
| 201 | if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) |
| 202 | snprintf( buf, buflen, "PEM - Failed to allocate memory" ); |
| 203 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) |
| 204 | snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); |
| 205 | if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) |
| 206 | snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); |
| 207 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) |
| 208 | snprintf( buf, buflen, "PEM - Private key password can't be empty" ); |
| 209 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) |
| 210 | snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); |
| 211 | if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) |
| 212 | snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); |
| 213 | #endif /* POLARSSL_PEM_C */ |
| 214 | |
| 215 | #if defined(POLARSSL_RSA_C) |
| 216 | if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) |
| 217 | snprintf( buf, buflen, "RSA - Bad input parameters to function" ); |
| 218 | if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) |
| 219 | snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); |
| 220 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) |
| 221 | snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); |
| 222 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) |
| 223 | snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" ); |
| 224 | if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) |
| 225 | snprintf( buf, buflen, "RSA - The public key operation failed" ); |
| 226 | if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) |
| 227 | snprintf( buf, buflen, "RSA - The private key operation failed" ); |
| 228 | if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) |
| 229 | snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); |
| 230 | if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) |
| 231 | snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); |
| 232 | if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) |
| 233 | snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); |
| 234 | #endif /* POLARSSL_RSA_C */ |
| 235 | |
Paul Bakker | 831a755 | 2011-05-18 13:32:51 +0000 | [diff] [blame] | 236 | #if defined(POLARSSL_SSL_TLS_C) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 237 | if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) |
| 238 | snprintf( buf, buflen, "SSL - The requested feature is not available" ); |
| 239 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) |
| 240 | snprintf( buf, buflen, "SSL - Bad input parameters to function" ); |
| 241 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) |
| 242 | snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); |
| 243 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) |
| 244 | snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); |
Paul Bakker | 831a755 | 2011-05-18 13:32:51 +0000 | [diff] [blame] | 245 | if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) |
| 246 | snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 247 | if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) |
| 248 | snprintf( buf, buflen, "SSL - An unknown cipher was received" ); |
| 249 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) |
| 250 | snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); |
| 251 | if( use_ret == -(POLARSSL_ERR_SSL_NO_SESSION_FOUND) ) |
| 252 | snprintf( buf, buflen, "SSL - No session to recover was found" ); |
| 253 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) |
| 254 | snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); |
| 255 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) |
| 256 | snprintf( buf, buflen, "SSL - DESCRIPTION MISSING" ); |
| 257 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) |
| 258 | snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); |
| 259 | if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) |
| 260 | snprintf( buf, buflen, "SSL - The own private key is not set, but needed" ); |
| 261 | if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) |
| 262 | snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); |
| 263 | if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) |
| 264 | snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); |
| 265 | if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) |
Paul Bakker | 3aac1da | 2012-05-08 13:12:27 +0000 | [diff] [blame] | 266 | { |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 267 | 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] | 268 | return; |
| 269 | } |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 270 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) |
| 271 | snprintf( buf, buflen, "SSL - Verification of our peer failed" ); |
| 272 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) |
| 273 | snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); |
| 274 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) |
| 275 | snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); |
| 276 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) |
| 277 | snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); |
| 278 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) |
| 279 | snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); |
| 280 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) |
| 281 | snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); |
| 282 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) |
| 283 | snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); |
| 284 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) |
| 285 | snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); |
| 286 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) |
| 287 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); |
| 288 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_RP) ) |
| 289 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Read Public" ); |
| 290 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_DHM_CS) ) |
| 291 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM Calculate Secret" ); |
| 292 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) |
| 293 | snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); |
| 294 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) |
| 295 | snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); |
| 296 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) |
| 297 | snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 298 | if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) |
| 299 | snprintf( buf, buflen, "SSL - Memory allocation failed" ); |
Paul Bakker | 05ef835 | 2012-05-08 09:17:57 +0000 | [diff] [blame] | 300 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FAILED) ) |
| 301 | snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); |
| 302 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) |
| 303 | snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 304 | if( use_ret == -(POLARSSL_ERR_SSL_COMPRESSION_FAILED) ) |
| 305 | snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); |
Paul Bakker | 1d29fb5 | 2012-09-28 13:28:45 +0000 | [diff] [blame] | 306 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) |
| 307 | snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); |
Paul Bakker | 831a755 | 2011-05-18 13:32:51 +0000 | [diff] [blame] | 308 | #endif /* POLARSSL_SSL_TLS_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 309 | |
| 310 | #if defined(POLARSSL_X509_PARSE_C) |
| 311 | if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) |
| 312 | snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); |
| 313 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PEM) ) |
| 314 | snprintf( buf, buflen, "X509 - The PEM-encoded certificate contains invalid elements, e.g. invalid character" ); |
| 315 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_FORMAT) ) |
| 316 | snprintf( buf, buflen, "X509 - The certificate format is invalid, e.g. different type expected" ); |
| 317 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_VERSION) ) |
| 318 | snprintf( buf, buflen, "X509 - The certificate version element is invalid" ); |
| 319 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SERIAL) ) |
| 320 | snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); |
| 321 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_ALG) ) |
| 322 | snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); |
| 323 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_NAME) ) |
| 324 | snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); |
| 325 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_DATE) ) |
| 326 | snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); |
| 327 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_PUBKEY) ) |
| 328 | snprintf( buf, buflen, "X509 - The pubkey tag or value is invalid (only RSA is supported)" ); |
| 329 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE) ) |
| 330 | snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); |
| 331 | if( use_ret == -(POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS) ) |
| 332 | snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); |
| 333 | if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION) ) |
| 334 | snprintf( buf, buflen, "X509 - Certificate or CRL has an unsupported version number" ); |
| 335 | if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG) ) |
| 336 | snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); |
Paul Bakker | 9db7742 | 2011-07-13 11:47:32 +0000 | [diff] [blame] | 337 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_PK_ALG) ) |
| 338 | snprintf( buf, buflen, "X509 - Key algorithm is unsupported (only RSA is supported)" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 339 | if( use_ret == -(POLARSSL_ERR_X509_CERT_SIG_MISMATCH) ) |
| 340 | snprintf( buf, buflen, "X509 - Certificate signature algorithms do not match. (see \\c ::x509_cert sig_oid)" ); |
| 341 | if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) |
| 342 | snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); |
| 343 | if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_VERSION) ) |
| 344 | snprintf( buf, buflen, "X509 - Unsupported RSA key version" ); |
| 345 | if( use_ret == -(POLARSSL_ERR_X509_KEY_INVALID_FORMAT) ) |
| 346 | snprintf( buf, buflen, "X509 - Invalid RSA key tag or value" ); |
Paul Bakker | 6c0ceb3 | 2011-12-04 12:24:18 +0000 | [diff] [blame] | 347 | if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) |
| 348 | snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 349 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_INPUT) ) |
| 350 | snprintf( buf, buflen, "X509 - Input invalid" ); |
| 351 | if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) |
| 352 | snprintf( buf, buflen, "X509 - Allocation of memory failed" ); |
| 353 | if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) |
| 354 | snprintf( buf, buflen, "X509 - Read/write of file failed" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 355 | #endif /* POLARSSL_X509_PARSE_C */ |
| 356 | |
| 357 | if( strlen( buf ) == 0 ) |
| 358 | snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
| 359 | } |
| 360 | |
| 361 | use_ret = ret & ~0xFF80; |
| 362 | |
| 363 | if( use_ret == 0 ) |
| 364 | return; |
| 365 | |
| 366 | // If high level code is present, make a concatenation between both |
| 367 | // error strings. |
| 368 | // |
| 369 | len = strlen( buf ); |
| 370 | |
| 371 | if( len > 0 ) |
| 372 | { |
| 373 | if( buflen - len < 5 ) |
| 374 | return; |
| 375 | |
| 376 | snprintf( buf + len, buflen - len, " : " ); |
| 377 | |
| 378 | buf += len + 3; |
| 379 | buflen -= len + 3; |
| 380 | } |
| 381 | |
| 382 | // Low level error codes |
| 383 | // |
| 384 | #if defined(POLARSSL_AES_C) |
| 385 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) |
| 386 | snprintf( buf, buflen, "AES - Invalid key length" ); |
| 387 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) |
| 388 | snprintf( buf, buflen, "AES - Invalid data input length" ); |
| 389 | #endif /* POLARSSL_AES_C */ |
| 390 | |
Paul Bakker | dceecd8 | 2011-11-15 16:38:34 +0000 | [diff] [blame] | 391 | #if defined(POLARSSL_ASN1_PARSE_C) |
| 392 | if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) |
| 393 | snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); |
| 394 | if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) |
| 395 | snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); |
| 396 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) |
| 397 | snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); |
| 398 | if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) |
| 399 | snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); |
| 400 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) |
| 401 | snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 402 | if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) |
| 403 | snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 404 | if( use_ret == -(POLARSSL_ERR_ASN1_BUF_TOO_SMALL) ) |
| 405 | 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] | 406 | #endif /* POLARSSL_ASN1_PARSE_C */ |
| 407 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 408 | #if defined(POLARSSL_BASE64_C) |
| 409 | if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) |
| 410 | snprintf( buf, buflen, "BASE64 - Output buffer too small" ); |
| 411 | if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) |
| 412 | snprintf( buf, buflen, "BASE64 - Invalid character in input" ); |
| 413 | #endif /* POLARSSL_BASE64_C */ |
| 414 | |
| 415 | #if defined(POLARSSL_BIGNUM_C) |
| 416 | if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) |
| 417 | snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); |
| 418 | if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) |
| 419 | snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); |
| 420 | if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) |
| 421 | snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); |
| 422 | if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 423 | snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 424 | if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) |
| 425 | snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); |
| 426 | if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) |
| 427 | snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); |
| 428 | if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) |
| 429 | snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 430 | if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) |
| 431 | snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 432 | #endif /* POLARSSL_BIGNUM_C */ |
| 433 | |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 434 | #if defined(POLARSSL_BLOWFISH_C) |
| 435 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) |
| 436 | snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); |
| 437 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) |
| 438 | snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); |
| 439 | #endif /* POLARSSL_BLOWFISH_C */ |
| 440 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 441 | #if defined(POLARSSL_CAMELLIA_C) |
| 442 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) |
| 443 | snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); |
| 444 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) |
| 445 | snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); |
| 446 | #endif /* POLARSSL_CAMELLIA_C */ |
| 447 | |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 448 | #if defined(POLARSSL_CTR_DRBG_C) |
| 449 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) |
| 450 | snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); |
| 451 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) |
| 452 | snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); |
| 453 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) |
| 454 | snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 455 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) |
| 456 | snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 457 | #endif /* POLARSSL_CTR_DRBG_C */ |
| 458 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 459 | #if defined(POLARSSL_DES_C) |
| 460 | if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) |
| 461 | snprintf( buf, buflen, "DES - The data input has an invalid length" ); |
| 462 | #endif /* POLARSSL_DES_C */ |
| 463 | |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 464 | #if defined(POLARSSL_ENTROPY_C) |
| 465 | if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) |
| 466 | snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); |
| 467 | if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) |
| 468 | snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); |
Paul Bakker | 43655f4 | 2011-12-15 20:11:16 +0000 | [diff] [blame] | 469 | if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) |
| 470 | snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 471 | #endif /* POLARSSL_ENTROPY_C */ |
| 472 | |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 473 | #if defined(POLARSSL_GCM_C) |
| 474 | if( use_ret == -(POLARSSL_ERR_GCM_AUTH_FAILED) ) |
| 475 | snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); |
Paul Bakker | d8ef167 | 2012-04-18 14:17:32 +0000 | [diff] [blame] | 476 | if( use_ret == -(POLARSSL_ERR_GCM_BAD_INPUT) ) |
| 477 | snprintf( buf, buflen, "GCM - Bad input parameters to function" ); |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 478 | #endif /* POLARSSL_GCM_C */ |
| 479 | |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 480 | #if defined(POLARSSL_MD2_C) |
| 481 | if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) |
| 482 | snprintf( buf, buflen, "MD2 - Read/write error in file" ); |
| 483 | #endif /* POLARSSL_MD2_C */ |
| 484 | |
| 485 | #if defined(POLARSSL_MD4_C) |
| 486 | if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) |
| 487 | snprintf( buf, buflen, "MD4 - Read/write error in file" ); |
| 488 | #endif /* POLARSSL_MD4_C */ |
| 489 | |
| 490 | #if defined(POLARSSL_MD5_C) |
| 491 | if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) |
| 492 | snprintf( buf, buflen, "MD5 - Read/write error in file" ); |
| 493 | #endif /* POLARSSL_MD5_C */ |
| 494 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 495 | #if defined(POLARSSL_NET_C) |
| 496 | if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) |
| 497 | snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); |
| 498 | if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) |
| 499 | snprintf( buf, buflen, "NET - Failed to open a socket" ); |
| 500 | if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) |
| 501 | snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); |
| 502 | if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) |
| 503 | snprintf( buf, buflen, "NET - Binding of the socket failed" ); |
| 504 | if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) |
| 505 | snprintf( buf, buflen, "NET - Could not listen on the socket" ); |
| 506 | if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) |
| 507 | snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); |
| 508 | if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) |
| 509 | snprintf( buf, buflen, "NET - Reading information from the socket failed" ); |
| 510 | if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) |
| 511 | snprintf( buf, buflen, "NET - Sending information through the socket failed" ); |
| 512 | if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) |
| 513 | snprintf( buf, buflen, "NET - Connection was reset by peer" ); |
Paul Bakker | 831a755 | 2011-05-18 13:32:51 +0000 | [diff] [blame] | 514 | if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) |
| 515 | snprintf( buf, buflen, "NET - Connection requires a read call" ); |
| 516 | if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) |
| 517 | snprintf( buf, buflen, "NET - Connection requires a write call" ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 518 | #endif /* POLARSSL_NET_C */ |
| 519 | |
| 520 | #if defined(POLARSSL_PADLOCK_C) |
| 521 | if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) |
| 522 | snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); |
| 523 | #endif /* POLARSSL_PADLOCK_C */ |
| 524 | |
Paul Bakker | d14277d | 2012-09-26 15:19:05 +0000 | [diff] [blame] | 525 | #if defined(POLARSSL_PBKDF2_C) |
| 526 | if( use_ret == -(POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA) ) |
| 527 | snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" ); |
| 528 | #endif /* POLARSSL_PBKDF2_C */ |
| 529 | |
Paul Bakker | 69e095c | 2011-12-10 21:55:01 +0000 | [diff] [blame] | 530 | #if defined(POLARSSL_SHA1_C) |
| 531 | if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) |
| 532 | snprintf( buf, buflen, "SHA1 - Read/write error in file" ); |
| 533 | #endif /* POLARSSL_SHA1_C */ |
| 534 | |
| 535 | #if defined(POLARSSL_SHA2_C) |
| 536 | if( use_ret == -(POLARSSL_ERR_SHA2_FILE_IO_ERROR) ) |
| 537 | snprintf( buf, buflen, "SHA2 - Read/write error in file" ); |
| 538 | #endif /* POLARSSL_SHA2_C */ |
| 539 | |
| 540 | #if defined(POLARSSL_SHA4_C) |
| 541 | if( use_ret == -(POLARSSL_ERR_SHA4_FILE_IO_ERROR) ) |
| 542 | snprintf( buf, buflen, "SHA4 - Read/write error in file" ); |
| 543 | #endif /* POLARSSL_SHA4_C */ |
| 544 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 545 | #if defined(POLARSSL_XTEA_C) |
| 546 | if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) |
| 547 | snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); |
| 548 | #endif /* POLARSSL_XTEA_C */ |
| 549 | |
| 550 | if( strlen( buf ) != 0 ) |
| 551 | return; |
| 552 | |
| 553 | snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
| 554 | } |
| 555 | |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 556 | #else /* POLARSSL_ERROR_C */ |
| 557 | |
| 558 | #if defined(POLARSSL_ERROR_STRERROR_DUMMY) |
| 559 | |
| 560 | #include <string.h> |
| 561 | |
| 562 | /* |
| 563 | * Provide an non-function in case POLARSSL_ERROR_C is not defined |
| 564 | */ |
| 565 | void error_strerror( int ret, char *buf, size_t buflen ) |
| 566 | { |
| 567 | ((void) ret); |
| 568 | |
| 569 | if( buflen > 0 ) |
| 570 | buf[0] = '\0'; |
| 571 | } |
| 572 | |
| 573 | #endif /* POLARSSL_ERROR_STRERROR_DUMMY */ |
Paul Bakker | 9a73632 | 2012-11-14 12:39:52 +0000 | [diff] [blame] | 574 | #endif /* POLARSSL_ERROR_C */ |