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