source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfcrypt/src/error.c@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 years ago

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 8.7 KB
Line 
1/* error.c
2 *
3 * Copyright (C) 2006-2015 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL. (formerly known as CyaSSL)
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifdef HAVE_CONFIG_H
23 #include <config.h>
24#endif
25
26#include <wolfssl/wolfcrypt/settings.h>
27
28#include <wolfssl/wolfcrypt/error-crypt.h>
29
30#ifdef _MSC_VER
31 /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
32 #pragma warning(disable: 4996)
33#endif
34
35const char* wc_GetErrorString(int error)
36{
37#ifdef NO_ERROR_STRINGS
38
39 (void)error;
40 return "no support for error strings built in";
41
42#else
43
44 switch (error) {
45
46 case OPEN_RAN_E :
47 return "opening random device error";
48
49 case READ_RAN_E :
50 return "reading random device error";
51
52 case WINCRYPT_E :
53 return "windows crypt init error";
54
55 case CRYPTGEN_E :
56 return "windows crypt generation error";
57
58 case RAN_BLOCK_E :
59 return "random device read would block error";
60
61 case BAD_MUTEX_E :
62 return "Bad mutex, operation failed";
63
64 case MP_INIT_E :
65 return "mp_init error state";
66
67 case MP_READ_E :
68 return "mp_read error state";
69
70 case MP_EXPTMOD_E :
71 return "mp_exptmod error state";
72
73 case MP_TO_E :
74 return "mp_to_xxx error state, can't convert";
75
76 case MP_SUB_E :
77 return "mp_sub error state, can't subtract";
78
79 case MP_ADD_E :
80 return "mp_add error state, can't add";
81
82 case MP_MUL_E :
83 return "mp_mul error state, can't multiply";
84
85 case MP_MULMOD_E :
86 return "mp_mulmod error state, can't multiply mod";
87
88 case MP_MOD_E :
89 return "mp_mod error state, can't mod";
90
91 case MP_INVMOD_E :
92 return "mp_invmod error state, can't inv mod";
93
94 case MP_CMP_E :
95 return "mp_cmp error state";
96
97 case MP_ZERO_E :
98 return "mp zero result, not expected";
99
100 case MEMORY_E :
101 return "out of memory error";
102
103 case RSA_WRONG_TYPE_E :
104 return "RSA wrong block type for RSA function";
105
106 case RSA_BUFFER_E :
107 return "RSA buffer error, output too small or input too big";
108
109 case BUFFER_E :
110 return "Buffer error, output too small or input too big";
111
112 case ALGO_ID_E :
113 return "Setting Cert AlogID error";
114
115 case PUBLIC_KEY_E :
116 return "Setting Cert Public Key error";
117
118 case DATE_E :
119 return "Setting Cert Date validity error";
120
121 case SUBJECT_E :
122 return "Setting Cert Subject name error";
123
124 case ISSUER_E :
125 return "Setting Cert Issuer name error";
126
127 case CA_TRUE_E :
128 return "Setting basic constraint CA true error";
129
130 case EXTENSIONS_E :
131 return "Setting extensions error";
132
133 case ASN_PARSE_E :
134 return "ASN parsing error, invalid input";
135
136 case ASN_VERSION_E :
137 return "ASN version error, invalid number";
138
139 case ASN_GETINT_E :
140 return "ASN get big int error, invalid data";
141
142 case ASN_RSA_KEY_E :
143 return "ASN key init error, invalid input";
144
145 case ASN_OBJECT_ID_E :
146 return "ASN object id error, invalid id";
147
148 case ASN_TAG_NULL_E :
149 return "ASN tag error, not null";
150
151 case ASN_EXPECT_0_E :
152 return "ASN expect error, not zero";
153
154 case ASN_BITSTR_E :
155 return "ASN bit string error, wrong id";
156
157 case ASN_UNKNOWN_OID_E :
158 return "ASN oid error, unknown sum id";
159
160 case ASN_DATE_SZ_E :
161 return "ASN date error, bad size";
162
163 case ASN_BEFORE_DATE_E :
164 return "ASN date error, current date before";
165
166 case ASN_AFTER_DATE_E :
167 return "ASN date error, current date after";
168
169 case ASN_SIG_OID_E :
170 return "ASN signature error, mismatched oid";
171
172 case ASN_TIME_E :
173 return "ASN time error, unkown time type";
174
175 case ASN_INPUT_E :
176 return "ASN input error, not enough data";
177
178 case ASN_SIG_CONFIRM_E :
179 return "ASN sig error, confirm failure";
180
181 case ASN_SIG_HASH_E :
182 return "ASN sig error, unsupported hash type";
183
184 case ASN_SIG_KEY_E :
185 return "ASN sig error, unsupported key type";
186
187 case ASN_DH_KEY_E :
188 return "ASN key init error, invalid input";
189
190 case ASN_NTRU_KEY_E :
191 return "ASN NTRU key decode error, invalid input";
192
193 case ASN_CRIT_EXT_E:
194 return "X.509 Critical extension ignored";
195
196 case ECC_BAD_ARG_E :
197 return "ECC input argument wrong type, invalid input";
198
199 case ASN_ECC_KEY_E :
200 return "ECC ASN1 bad key data, invalid input";
201
202 case ECC_CURVE_OID_E :
203 return "ECC curve sum OID unsupported, invalid input";
204
205 case BAD_FUNC_ARG :
206 return "Bad function argument";
207
208 case NOT_COMPILED_IN :
209 return "Feature not compiled in";
210
211 case UNICODE_SIZE_E :
212 return "Unicode password too big";
213
214 case NO_PASSWORD :
215 return "No password provided by user";
216
217 case ALT_NAME_E :
218 return "Alt Name problem, too big";
219
220 case AES_GCM_AUTH_E:
221 return "AES-GCM Authentication check fail";
222
223 case AES_CCM_AUTH_E:
224 return "AES-CCM Authentication check fail";
225
226 case CAVIUM_INIT_E:
227 return "Cavium Init type error";
228
229 case COMPRESS_INIT_E:
230 return "Compress Init error";
231
232 case COMPRESS_E:
233 return "Compress error";
234
235 case DECOMPRESS_INIT_E:
236 return "DeCompress Init error";
237
238 case DECOMPRESS_E:
239 return "DeCompress error";
240
241 case BAD_ALIGN_E:
242 return "Bad alignment error, no alloc help";
243
244 case ASN_NO_SIGNER_E :
245 return "ASN no signer error to confirm failure";
246
247 case ASN_CRL_CONFIRM_E :
248 return "ASN CRL sig error, confirm failure";
249
250 case ASN_CRL_NO_SIGNER_E :
251 return "ASN CRL no signer error to confirm failure";
252
253 case ASN_OCSP_CONFIRM_E :
254 return "ASN OCSP sig error, confirm failure";
255
256 case BAD_ENC_STATE_E:
257 return "Bad ecc encrypt state operation";
258
259 case BAD_PADDING_E:
260 return "Bad padding, message wrong length";
261
262 case REQ_ATTRIBUTE_E:
263 return "Setting cert request attributes error";
264
265 case PKCS7_OID_E:
266 return "PKCS#7 error: mismatched OID value";
267
268 case PKCS7_RECIP_E:
269 return "PKCS#7 error: no matching recipient found";
270
271 case FIPS_NOT_ALLOWED_E:
272 return "FIPS mode not allowed error";
273
274 case ASN_NAME_INVALID_E:
275 return "Name Constraint error";
276
277 case RNG_FAILURE_E:
278 return "Random Number Generator failed";
279
280 case HMAC_MIN_KEYLEN_E:
281 return "FIPS Mode HMAC Minimum Key Length error";
282
283 case RSA_PAD_E:
284 return "Rsa Padding error";
285
286 case LENGTH_ONLY_E:
287 return "Output length only set, not for other use error";
288
289 case IN_CORE_FIPS_E:
290 return "In Core Integrity check FIPS error";
291
292 case AES_KAT_FIPS_E:
293 return "AES Known Answer Test check FIPS error";
294
295 case DES3_KAT_FIPS_E:
296 return "DES3 Known Answer Test check FIPS error";
297
298 case HMAC_KAT_FIPS_E:
299 return "HMAC Known Answer Test check FIPS error";
300
301 case RSA_KAT_FIPS_E:
302 return "RSA Known Answer Test check FIPS error";
303
304 case DRBG_KAT_FIPS_E:
305 return "DRBG Known Answer Test check FIPS error";
306
307 case DRBG_CONT_FIPS_E:
308 return "DRBG Continuous Test FIPS error";
309
310 case AESGCM_KAT_FIPS_E:
311 return "AESGCM Known Answer Test check FIPS error";
312
313 case THREAD_STORE_KEY_E:
314 return "Thread Storage Key Create error";
315
316 case THREAD_STORE_SET_E:
317 return "Thread Storage Set error";
318
319 case MAC_CMP_FAILED_E:
320 return "MAC comparison failed";
321
322 case IS_POINT_E:
323 return "ECC is point on curve failed";
324
325 case ECC_INF_E:
326 return " ECC point at infinity error";
327
328 case ECC_PRIV_KEY_E:
329 return " ECC private key is not valid error";
330
331 case SRP_CALL_ORDER_E:
332 return "SRP function called in the wrong order error";
333
334 case SRP_VERIFY_E:
335 return "SRP proof verification error";
336
337 case SRP_BAD_KEY_E:
338 return "SRP bad key values error";
339
340 default:
341 return "unknown error number";
342
343 }
344
345#endif /* NO_ERROR_STRINGS */
346
347}
348
349void wc_ErrorString(int error, char* buffer)
350{
351 XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ);
352}
Note: See TracBrowser for help on using the repository browser.