This is a port of cyaSSL 2.7.0.

Dependents:   CyaSSL_DTLS_Cellular CyaSSL_DTLS_Ethernet

Committer:
ashleymills
Date:
Thu Sep 05 15:55:50 2013 +0000
Revision:
1:c0ce1562443a
Parent:
0:714293de3836
Nothing;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:714293de3836 1 /* error.c
ashleymills 0:714293de3836 2 *
ashleymills 0:714293de3836 3 * Copyright (C) 2006-2013 wolfSSL Inc.
ashleymills 0:714293de3836 4 *
ashleymills 0:714293de3836 5 * This file is part of CyaSSL.
ashleymills 0:714293de3836 6 *
ashleymills 0:714293de3836 7 * CyaSSL is free software; you can redistribute it and/or modify
ashleymills 0:714293de3836 8 * it under the terms of the GNU General Public License as published by
ashleymills 0:714293de3836 9 * the Free Software Foundation; either version 2 of the License, or
ashleymills 0:714293de3836 10 * (at your option) any later version.
ashleymills 0:714293de3836 11 *
ashleymills 0:714293de3836 12 * CyaSSL is distributed in the hope that it will be useful,
ashleymills 0:714293de3836 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ashleymills 0:714293de3836 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ashleymills 0:714293de3836 15 * GNU General Public License for more details.
ashleymills 0:714293de3836 16 *
ashleymills 0:714293de3836 17 * You should have received a copy of the GNU General Public License
ashleymills 0:714293de3836 18 * along with this program; if not, write to the Free Software
ashleymills 0:714293de3836 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ashleymills 0:714293de3836 20 */
ashleymills 0:714293de3836 21
ashleymills 0:714293de3836 22 #ifdef HAVE_CONFIG_H
ashleymills 0:714293de3836 23 #include <config.h>
ashleymills 0:714293de3836 24 #endif
ashleymills 0:714293de3836 25
ashleymills 0:714293de3836 26 #include <cyassl/ctaocrypt/settings.h>
ashleymills 0:714293de3836 27
ashleymills 0:714293de3836 28 #include <cyassl/ctaocrypt/ctaoerror2.h>
ashleymills 0:714293de3836 29
ashleymills 0:714293de3836 30 #ifdef _MSC_VER
ashleymills 0:714293de3836 31 /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
ashleymills 0:714293de3836 32 #pragma warning(disable: 4996)
ashleymills 0:714293de3836 33 #endif
ashleymills 0:714293de3836 34
ashleymills 0:714293de3836 35
ashleymills 0:714293de3836 36 void CTaoCryptErrorString(int error, char* buffer)
ashleymills 0:714293de3836 37 {
ashleymills 0:714293de3836 38 const int max = MAX_ERROR_SZ; /* shorthand */
ashleymills 0:714293de3836 39
ashleymills 0:714293de3836 40 #ifdef NO_ERROR_STRINGS
ashleymills 0:714293de3836 41
ashleymills 0:714293de3836 42 (void)error;
ashleymills 0:714293de3836 43 XSTRNCPY(buffer, "no support for error strings built in", max);
ashleymills 0:714293de3836 44
ashleymills 0:714293de3836 45 #else
ashleymills 0:714293de3836 46
ashleymills 0:714293de3836 47 switch (error) {
ashleymills 0:714293de3836 48
ashleymills 0:714293de3836 49 case OPEN_RAN_E :
ashleymills 0:714293de3836 50 XSTRNCPY(buffer, "opening random device error", max);
ashleymills 0:714293de3836 51 break;
ashleymills 0:714293de3836 52
ashleymills 0:714293de3836 53 case READ_RAN_E :
ashleymills 0:714293de3836 54 XSTRNCPY(buffer, "reading random device error", max);
ashleymills 0:714293de3836 55 break;
ashleymills 0:714293de3836 56
ashleymills 0:714293de3836 57 case WINCRYPT_E :
ashleymills 0:714293de3836 58 XSTRNCPY(buffer, "windows crypt init error", max);
ashleymills 0:714293de3836 59 break;
ashleymills 0:714293de3836 60
ashleymills 0:714293de3836 61 case CRYPTGEN_E :
ashleymills 0:714293de3836 62 XSTRNCPY(buffer, "windows crypt generation error", max);
ashleymills 0:714293de3836 63 break;
ashleymills 0:714293de3836 64
ashleymills 0:714293de3836 65 case RAN_BLOCK_E :
ashleymills 0:714293de3836 66 XSTRNCPY(buffer, "random device read would block error", max);
ashleymills 0:714293de3836 67 break;
ashleymills 0:714293de3836 68
ashleymills 0:714293de3836 69 case MP_INIT_E :
ashleymills 0:714293de3836 70 XSTRNCPY(buffer, "mp_init error state", max);
ashleymills 0:714293de3836 71 break;
ashleymills 0:714293de3836 72
ashleymills 0:714293de3836 73 case MP_READ_E :
ashleymills 0:714293de3836 74 XSTRNCPY(buffer, "mp_read error state", max);
ashleymills 0:714293de3836 75 break;
ashleymills 0:714293de3836 76
ashleymills 0:714293de3836 77 case MP_EXPTMOD_E :
ashleymills 0:714293de3836 78 XSTRNCPY(buffer, "mp_exptmod error state", max);
ashleymills 0:714293de3836 79 break;
ashleymills 0:714293de3836 80
ashleymills 0:714293de3836 81 case MP_TO_E :
ashleymills 0:714293de3836 82 XSTRNCPY(buffer, "mp_to_xxx error state, can't convert", max);
ashleymills 0:714293de3836 83 break;
ashleymills 0:714293de3836 84
ashleymills 0:714293de3836 85 case MP_SUB_E :
ashleymills 0:714293de3836 86 XSTRNCPY(buffer, "mp_sub error state, can't subtract", max);
ashleymills 0:714293de3836 87 break;
ashleymills 0:714293de3836 88
ashleymills 0:714293de3836 89 case MP_ADD_E :
ashleymills 0:714293de3836 90 XSTRNCPY(buffer, "mp_add error state, can't add", max);
ashleymills 0:714293de3836 91 break;
ashleymills 0:714293de3836 92
ashleymills 0:714293de3836 93 case MP_MUL_E :
ashleymills 0:714293de3836 94 XSTRNCPY(buffer, "mp_mul error state, can't multiply", max);
ashleymills 0:714293de3836 95 break;
ashleymills 0:714293de3836 96
ashleymills 0:714293de3836 97 case MP_MULMOD_E :
ashleymills 0:714293de3836 98 XSTRNCPY(buffer, "mp_mulmod error state, can't multiply mod", max);
ashleymills 0:714293de3836 99 break;
ashleymills 0:714293de3836 100
ashleymills 0:714293de3836 101 case MP_MOD_E :
ashleymills 0:714293de3836 102 XSTRNCPY(buffer, "mp_mod error state, can't mod", max);
ashleymills 0:714293de3836 103 break;
ashleymills 0:714293de3836 104
ashleymills 0:714293de3836 105 case MP_INVMOD_E :
ashleymills 0:714293de3836 106 XSTRNCPY(buffer, "mp_invmod error state, can't inv mod", max);
ashleymills 0:714293de3836 107 break;
ashleymills 0:714293de3836 108
ashleymills 0:714293de3836 109 case MP_CMP_E :
ashleymills 0:714293de3836 110 XSTRNCPY(buffer, "mp_cmp error state", max);
ashleymills 0:714293de3836 111 break;
ashleymills 0:714293de3836 112
ashleymills 0:714293de3836 113 case MP_ZERO_E :
ashleymills 0:714293de3836 114 XSTRNCPY(buffer, "mp zero result, not expected", max);
ashleymills 0:714293de3836 115 break;
ashleymills 0:714293de3836 116
ashleymills 0:714293de3836 117 case MEMORY_E :
ashleymills 0:714293de3836 118 XSTRNCPY(buffer, "out of memory error", max);
ashleymills 0:714293de3836 119 break;
ashleymills 0:714293de3836 120
ashleymills 0:714293de3836 121 case RSA_WRONG_TYPE_E :
ashleymills 0:714293de3836 122 XSTRNCPY(buffer, "RSA wrong block type for RSA function", max);
ashleymills 0:714293de3836 123 break;
ashleymills 0:714293de3836 124
ashleymills 0:714293de3836 125 case RSA_BUFFER_E :
ashleymills 0:714293de3836 126 XSTRNCPY(buffer, "RSA buffer error, output too small or input too big",
ashleymills 0:714293de3836 127 max);
ashleymills 0:714293de3836 128 break;
ashleymills 0:714293de3836 129
ashleymills 0:714293de3836 130 case BUFFER_E :
ashleymills 0:714293de3836 131 XSTRNCPY(buffer, "Buffer error, output too small or input too big",max);
ashleymills 0:714293de3836 132 break;
ashleymills 0:714293de3836 133
ashleymills 0:714293de3836 134 case ALGO_ID_E :
ashleymills 0:714293de3836 135 XSTRNCPY(buffer, "Setting Cert AlogID error", max);
ashleymills 0:714293de3836 136 break;
ashleymills 0:714293de3836 137
ashleymills 0:714293de3836 138 case PUBLIC_KEY_E :
ashleymills 0:714293de3836 139 XSTRNCPY(buffer, "Setting Cert Public Key error", max);
ashleymills 0:714293de3836 140 break;
ashleymills 0:714293de3836 141
ashleymills 0:714293de3836 142 case DATE_E :
ashleymills 0:714293de3836 143 XSTRNCPY(buffer, "Setting Cert Date validity error", max);
ashleymills 0:714293de3836 144 break;
ashleymills 0:714293de3836 145
ashleymills 0:714293de3836 146 case SUBJECT_E :
ashleymills 0:714293de3836 147 XSTRNCPY(buffer, "Setting Cert Subject name error", max);
ashleymills 0:714293de3836 148 break;
ashleymills 0:714293de3836 149
ashleymills 0:714293de3836 150 case ISSUER_E :
ashleymills 0:714293de3836 151 XSTRNCPY(buffer, "Setting Cert Issuer name error", max);
ashleymills 0:714293de3836 152 break;
ashleymills 0:714293de3836 153
ashleymills 0:714293de3836 154 case CA_TRUE_E :
ashleymills 0:714293de3836 155 XSTRNCPY(buffer, "Setting basic constraint CA true error", max);
ashleymills 0:714293de3836 156 break;
ashleymills 0:714293de3836 157
ashleymills 0:714293de3836 158 case EXTENSIONS_E :
ashleymills 0:714293de3836 159 XSTRNCPY(buffer, "Setting extensions error", max);
ashleymills 0:714293de3836 160 break;
ashleymills 0:714293de3836 161
ashleymills 0:714293de3836 162 case ASN_PARSE_E :
ashleymills 0:714293de3836 163 XSTRNCPY(buffer, "ASN parsing error, invalid input", max);
ashleymills 0:714293de3836 164 break;
ashleymills 0:714293de3836 165
ashleymills 0:714293de3836 166 case ASN_VERSION_E :
ashleymills 0:714293de3836 167 XSTRNCPY(buffer, "ASN version error, invalid number", max);
ashleymills 0:714293de3836 168 break;
ashleymills 0:714293de3836 169
ashleymills 0:714293de3836 170 case ASN_GETINT_E :
ashleymills 0:714293de3836 171 XSTRNCPY(buffer, "ASN get big int error, invalid data", max);
ashleymills 0:714293de3836 172 break;
ashleymills 0:714293de3836 173
ashleymills 0:714293de3836 174 case ASN_RSA_KEY_E :
ashleymills 0:714293de3836 175 XSTRNCPY(buffer, "ASN key init error, invalid input", max);
ashleymills 0:714293de3836 176 break;
ashleymills 0:714293de3836 177
ashleymills 0:714293de3836 178 case ASN_OBJECT_ID_E :
ashleymills 0:714293de3836 179 XSTRNCPY(buffer, "ASN object id error, invalid id", max);
ashleymills 0:714293de3836 180 break;
ashleymills 0:714293de3836 181
ashleymills 0:714293de3836 182 case ASN_TAG_NULL_E :
ashleymills 0:714293de3836 183 XSTRNCPY(buffer, "ASN tag error, not null", max);
ashleymills 0:714293de3836 184 break;
ashleymills 0:714293de3836 185
ashleymills 0:714293de3836 186 case ASN_EXPECT_0_E :
ashleymills 0:714293de3836 187 XSTRNCPY(buffer, "ASN expect error, not zero", max);
ashleymills 0:714293de3836 188 break;
ashleymills 0:714293de3836 189
ashleymills 0:714293de3836 190 case ASN_BITSTR_E :
ashleymills 0:714293de3836 191 XSTRNCPY(buffer, "ASN bit string error, wrong id", max);
ashleymills 0:714293de3836 192 break;
ashleymills 0:714293de3836 193
ashleymills 0:714293de3836 194 case ASN_UNKNOWN_OID_E :
ashleymills 0:714293de3836 195 XSTRNCPY(buffer, "ASN oid error, unknown sum id", max);
ashleymills 0:714293de3836 196 break;
ashleymills 0:714293de3836 197
ashleymills 0:714293de3836 198 case ASN_DATE_SZ_E :
ashleymills 0:714293de3836 199 XSTRNCPY(buffer, "ASN date error, bad size", max);
ashleymills 0:714293de3836 200 break;
ashleymills 0:714293de3836 201
ashleymills 0:714293de3836 202 case ASN_BEFORE_DATE_E :
ashleymills 0:714293de3836 203 XSTRNCPY(buffer, "ASN date error, current date before", max);
ashleymills 0:714293de3836 204 break;
ashleymills 0:714293de3836 205
ashleymills 0:714293de3836 206 case ASN_AFTER_DATE_E :
ashleymills 0:714293de3836 207 XSTRNCPY(buffer, "ASN date error, current date after", max);
ashleymills 0:714293de3836 208 break;
ashleymills 0:714293de3836 209
ashleymills 0:714293de3836 210 case ASN_SIG_OID_E :
ashleymills 0:714293de3836 211 XSTRNCPY(buffer, "ASN signature error, mismatched oid", max);
ashleymills 0:714293de3836 212 break;
ashleymills 0:714293de3836 213
ashleymills 0:714293de3836 214 case ASN_TIME_E :
ashleymills 0:714293de3836 215 XSTRNCPY(buffer, "ASN time error, unkown time type", max);
ashleymills 0:714293de3836 216 break;
ashleymills 0:714293de3836 217
ashleymills 0:714293de3836 218 case ASN_INPUT_E :
ashleymills 0:714293de3836 219 XSTRNCPY(buffer, "ASN input error, not enough data", max);
ashleymills 0:714293de3836 220 break;
ashleymills 0:714293de3836 221
ashleymills 0:714293de3836 222 case ASN_SIG_CONFIRM_E :
ashleymills 0:714293de3836 223 XSTRNCPY(buffer, "ASN sig error, confirm failure", max);
ashleymills 0:714293de3836 224 break;
ashleymills 0:714293de3836 225
ashleymills 0:714293de3836 226 case ASN_SIG_HASH_E :
ashleymills 0:714293de3836 227 XSTRNCPY(buffer, "ASN sig error, unsupported hash type", max);
ashleymills 0:714293de3836 228 break;
ashleymills 0:714293de3836 229
ashleymills 0:714293de3836 230 case ASN_SIG_KEY_E :
ashleymills 0:714293de3836 231 XSTRNCPY(buffer, "ASN sig error, unsupported key type", max);
ashleymills 0:714293de3836 232 break;
ashleymills 0:714293de3836 233
ashleymills 0:714293de3836 234 case ASN_DH_KEY_E :
ashleymills 0:714293de3836 235 XSTRNCPY(buffer, "ASN key init error, invalid input", max);
ashleymills 0:714293de3836 236 break;
ashleymills 0:714293de3836 237
ashleymills 0:714293de3836 238 case ASN_NTRU_KEY_E :
ashleymills 0:714293de3836 239 XSTRNCPY(buffer, "ASN NTRU key decode error, invalid input", max);
ashleymills 0:714293de3836 240 break;
ashleymills 0:714293de3836 241
ashleymills 0:714293de3836 242 case ECC_BAD_ARG_E :
ashleymills 0:714293de3836 243 XSTRNCPY(buffer, "ECC input argument wrong type, invalid input", max);
ashleymills 0:714293de3836 244 break;
ashleymills 0:714293de3836 245
ashleymills 0:714293de3836 246 case ASN_ECC_KEY_E :
ashleymills 0:714293de3836 247 XSTRNCPY(buffer, "ECC ASN1 bad key data, invalid input", max);
ashleymills 0:714293de3836 248 break;
ashleymills 0:714293de3836 249
ashleymills 0:714293de3836 250 case ECC_CURVE_OID_E :
ashleymills 0:714293de3836 251 XSTRNCPY(buffer, "ECC curve sum OID unsupported, invalid input", max);
ashleymills 0:714293de3836 252 break;
ashleymills 0:714293de3836 253
ashleymills 0:714293de3836 254 case BAD_FUNC_ARG :
ashleymills 0:714293de3836 255 XSTRNCPY(buffer, "Bad function argument", max);
ashleymills 0:714293de3836 256 break;
ashleymills 0:714293de3836 257
ashleymills 0:714293de3836 258 case NOT_COMPILED_IN :
ashleymills 0:714293de3836 259 XSTRNCPY(buffer, "Feature not compiled in", max);
ashleymills 0:714293de3836 260 break;
ashleymills 0:714293de3836 261
ashleymills 0:714293de3836 262 case UNICODE_SIZE_E :
ashleymills 0:714293de3836 263 XSTRNCPY(buffer, "Unicode password too big", max);
ashleymills 0:714293de3836 264 break;
ashleymills 0:714293de3836 265
ashleymills 0:714293de3836 266 case NO_PASSWORD :
ashleymills 0:714293de3836 267 XSTRNCPY(buffer, "No password provided by user", max);
ashleymills 0:714293de3836 268 break;
ashleymills 0:714293de3836 269
ashleymills 0:714293de3836 270 case ALT_NAME_E :
ashleymills 0:714293de3836 271 XSTRNCPY(buffer, "Alt Name problem, too big", max);
ashleymills 0:714293de3836 272 break;
ashleymills 0:714293de3836 273
ashleymills 0:714293de3836 274 case AES_GCM_AUTH_E:
ashleymills 0:714293de3836 275 XSTRNCPY(buffer, "AES-GCM Authentication check fail", max);
ashleymills 0:714293de3836 276 break;
ashleymills 0:714293de3836 277
ashleymills 0:714293de3836 278 case AES_CCM_AUTH_E:
ashleymills 0:714293de3836 279 XSTRNCPY(buffer, "AES-CCM Authentication check fail", max);
ashleymills 0:714293de3836 280 break;
ashleymills 0:714293de3836 281
ashleymills 0:714293de3836 282 case CAVIUM_INIT_E:
ashleymills 0:714293de3836 283 XSTRNCPY(buffer, "Cavium Init type error", max);
ashleymills 0:714293de3836 284 break;
ashleymills 0:714293de3836 285
ashleymills 0:714293de3836 286 case COMPRESS_INIT_E:
ashleymills 0:714293de3836 287 XSTRNCPY(buffer, "Compress Init error", max);
ashleymills 0:714293de3836 288 break;
ashleymills 0:714293de3836 289
ashleymills 0:714293de3836 290 case COMPRESS_E:
ashleymills 0:714293de3836 291 XSTRNCPY(buffer, "Compress error", max);
ashleymills 0:714293de3836 292 break;
ashleymills 0:714293de3836 293
ashleymills 0:714293de3836 294 case DECOMPRESS_INIT_E:
ashleymills 0:714293de3836 295 XSTRNCPY(buffer, "DeCompress Init error", max);
ashleymills 0:714293de3836 296 break;
ashleymills 0:714293de3836 297
ashleymills 0:714293de3836 298 case DECOMPRESS_E:
ashleymills 0:714293de3836 299 XSTRNCPY(buffer, "DeCompress error", max);
ashleymills 0:714293de3836 300 break;
ashleymills 0:714293de3836 301
ashleymills 0:714293de3836 302 case BAD_ALIGN_E:
ashleymills 0:714293de3836 303 XSTRNCPY(buffer, "Bad alignment error, no alloc help", max);
ashleymills 0:714293de3836 304 break;
ashleymills 0:714293de3836 305
ashleymills 0:714293de3836 306 case ASN_NO_SIGNER_E :
ashleymills 0:714293de3836 307 XSTRNCPY(buffer, "ASN no signer error to confirm failure", max);
ashleymills 0:714293de3836 308 break;
ashleymills 0:714293de3836 309
ashleymills 0:714293de3836 310 case ASN_CRL_CONFIRM_E :
ashleymills 0:714293de3836 311 XSTRNCPY(buffer, "ASN CRL sig error, confirm failure", max);
ashleymills 0:714293de3836 312 break;
ashleymills 0:714293de3836 313
ashleymills 0:714293de3836 314 case ASN_CRL_NO_SIGNER_E :
ashleymills 0:714293de3836 315 XSTRNCPY(buffer, "ASN CRL no signer error to confirm failure", max);
ashleymills 0:714293de3836 316 break;
ashleymills 0:714293de3836 317
ashleymills 0:714293de3836 318 case ASN_OCSP_CONFIRM_E :
ashleymills 0:714293de3836 319 XSTRNCPY(buffer, "ASN OCSP sig error, confirm failure", max);
ashleymills 0:714293de3836 320 break;
ashleymills 0:714293de3836 321
ashleymills 0:714293de3836 322 default:
ashleymills 0:714293de3836 323 XSTRNCPY(buffer, "unknown error number", max);
ashleymills 0:714293de3836 324
ashleymills 0:714293de3836 325 }
ashleymills 0:714293de3836 326
ashleymills 0:714293de3836 327 #endif /* NO_ERROR_STRINGS */
ashleymills 0:714293de3836 328
ashleymills 0:714293de3836 329 }