cyassl re-port with cellular comms, PSK test

Dependencies:   VodafoneUSBModem_bleedingedge2 mbed-rtos mbed-src

Committer:
ashleymills
Date:
Fri Apr 26 16:59:36 2013 +0000
Revision:
1:b211d97b0068
Parent:
0:e979170e02e7
nothing

Who changed what in which revision?

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