/src/wolfssl/wolfcrypt/src/error.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* error.c |
2 | | * |
3 | | * Copyright (C) 2006-2025 wolfSSL Inc. |
4 | | * |
5 | | * This file is part of wolfSSL. |
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 3 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-1335, USA |
20 | | */ |
21 | | |
22 | | #include <wolfssl/wolfcrypt/libwolfssl_sources.h> |
23 | | |
24 | | #ifdef _MSC_VER |
25 | | /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ |
26 | | #pragma warning(disable: 4996) |
27 | | #endif |
28 | | |
29 | | #ifndef NO_ERROR_STRINGS |
30 | | |
31 | | #ifdef WOLFSSL_DEBUG_TRACE_ERROR_CODES_H |
32 | | #include <wolfssl/debug-untrace-error-codes.h> |
33 | | #endif |
34 | | |
35 | | WOLFSSL_ABI |
36 | | const char* wc_GetErrorString(int error) |
37 | 0 | { |
38 | 0 | switch ((enum wolfCrypt_ErrorCodes)error) { |
39 | | |
40 | 0 | case WC_FAILURE: |
41 | 0 | return "wolfCrypt generic failure"; |
42 | | |
43 | 0 | case MP_MEM : |
44 | 0 | return "MP integer dynamic memory allocation failed"; |
45 | | |
46 | 0 | case MP_VAL : |
47 | 0 | return "MP integer invalid argument"; |
48 | | |
49 | 0 | case MP_WOULDBLOCK : |
50 | 0 | return "MP integer non-blocking operation would block"; |
51 | | |
52 | 0 | case MP_NOT_INF: |
53 | 0 | return "MP point not at infinity"; |
54 | | |
55 | 0 | case OPEN_RAN_E : |
56 | 0 | return "opening random device error"; |
57 | | |
58 | 0 | case READ_RAN_E : |
59 | 0 | return "reading random device error"; |
60 | | |
61 | 0 | case WINCRYPT_E : |
62 | 0 | return "windows crypt init error"; |
63 | | |
64 | 0 | case CRYPTGEN_E : |
65 | 0 | return "windows crypt generation error"; |
66 | | |
67 | 0 | case RAN_BLOCK_E : |
68 | 0 | return "random device read would block error"; |
69 | | |
70 | 0 | case BAD_MUTEX_E : |
71 | 0 | return "Bad mutex, operation failed"; |
72 | | |
73 | 0 | case WC_TIMEOUT_E: |
74 | 0 | return "Timeout error"; |
75 | | |
76 | 0 | case WC_PENDING_E: |
77 | 0 | return "wolfCrypt Operation Pending (would block / eagain) error"; |
78 | | |
79 | 0 | case WC_NO_PENDING_E: |
80 | 0 | return "wolfCrypt operation not pending error"; |
81 | | |
82 | 0 | case MP_INIT_E : |
83 | 0 | return "mp_init error state"; |
84 | | |
85 | 0 | case MP_READ_E : |
86 | 0 | return "mp_read error state"; |
87 | | |
88 | 0 | case MP_EXPTMOD_E : |
89 | 0 | return "mp_exptmod error state"; |
90 | | |
91 | 0 | case MP_TO_E : |
92 | 0 | return "mp_to_xxx error state, can't convert"; |
93 | | |
94 | 0 | case MP_SUB_E : |
95 | 0 | return "mp_sub error state, can't subtract"; |
96 | | |
97 | 0 | case MP_ADD_E : |
98 | 0 | return "mp_add error state, can't add"; |
99 | | |
100 | 0 | case MP_MUL_E : |
101 | 0 | return "mp_mul error state, can't multiply"; |
102 | | |
103 | 0 | case MP_MULMOD_E : |
104 | 0 | return "mp_mulmod error state, can't multiply mod"; |
105 | | |
106 | 0 | case MP_MOD_E : |
107 | 0 | return "mp_mod error state, can't mod"; |
108 | | |
109 | 0 | case MP_INVMOD_E : |
110 | 0 | return "mp_invmod error state, can't inv mod"; |
111 | | |
112 | 0 | case MP_CMP_E : |
113 | 0 | return "mp_cmp error state"; |
114 | | |
115 | 0 | case MP_ZERO_E : |
116 | 0 | return "mp zero result, not expected"; |
117 | | |
118 | 0 | case MEMORY_E : |
119 | 0 | return "out of memory error"; |
120 | | |
121 | 0 | case VAR_STATE_CHANGE_E : |
122 | 0 | return "Variable state modified by different thread"; |
123 | | |
124 | 0 | case RSA_WRONG_TYPE_E : |
125 | 0 | return "RSA wrong block type for RSA function"; |
126 | | |
127 | 0 | case RSA_BUFFER_E : |
128 | 0 | return "RSA buffer error, output too small or input too big"; |
129 | | |
130 | 0 | case BUFFER_E : |
131 | 0 | return "Buffer error, output too small or input too big"; |
132 | | |
133 | 0 | case ALGO_ID_E : |
134 | 0 | return "Setting Cert AlgoID error"; |
135 | | |
136 | 0 | case PUBLIC_KEY_E : |
137 | 0 | return "Setting Cert Public Key error"; |
138 | | |
139 | 0 | case DATE_E : |
140 | 0 | return "Setting Cert Date validity error"; |
141 | | |
142 | 0 | case SUBJECT_E : |
143 | 0 | return "Setting Cert Subject name error"; |
144 | | |
145 | 0 | case ISSUER_E : |
146 | 0 | return "Setting Cert Issuer name error"; |
147 | | |
148 | 0 | case CA_TRUE_E : |
149 | 0 | return "Setting basic constraint CA true error"; |
150 | | |
151 | 0 | case EXTENSIONS_E : |
152 | 0 | return "Setting extensions error"; |
153 | | |
154 | 0 | case ASN_PARSE_E : |
155 | 0 | return "ASN parsing error, invalid input"; |
156 | | |
157 | 0 | case ASN_VERSION_E : |
158 | 0 | return "ASN version error, invalid number"; |
159 | | |
160 | 0 | case ASN_GETINT_E : |
161 | 0 | return "ASN get big int error, invalid data"; |
162 | | |
163 | 0 | case ASN_RSA_KEY_E : |
164 | 0 | return "ASN key init error, invalid input"; |
165 | | |
166 | 0 | case ASN_OBJECT_ID_E : |
167 | 0 | return "ASN object id error, invalid id"; |
168 | | |
169 | 0 | case ASN_TAG_NULL_E : |
170 | 0 | return "ASN tag error, not null"; |
171 | | |
172 | 0 | case ASN_EXPECT_0_E : |
173 | 0 | return "ASN expect error, not zero"; |
174 | | |
175 | 0 | case ASN_BITSTR_E : |
176 | 0 | return "ASN bit string error, wrong id"; |
177 | | |
178 | 0 | case ASN_UNKNOWN_OID_E : |
179 | 0 | return "ASN oid error, unknown sum id"; |
180 | | |
181 | 0 | case ASN_DATE_SZ_E : |
182 | 0 | return "ASN date error, bad size"; |
183 | | |
184 | 0 | case ASN_BEFORE_DATE_E : |
185 | 0 | return "ASN date error, current date is before start of validity"; |
186 | | |
187 | 0 | case ASN_AFTER_DATE_E : |
188 | 0 | return "ASN date error, current date is after expiration"; |
189 | | |
190 | 0 | case ASN_SIG_OID_E : |
191 | 0 | return "ASN signature error, mismatched oid"; |
192 | | |
193 | 0 | case ASN_TIME_E : |
194 | 0 | return "ASN time error, unknown time type"; |
195 | | |
196 | 0 | case ASN_INPUT_E : |
197 | 0 | return "ASN input error, not enough data"; |
198 | | |
199 | 0 | case ASN_SIG_CONFIRM_E : |
200 | 0 | return "ASN sig error, confirm failure"; |
201 | | |
202 | 0 | case ASN_SIG_HASH_E : |
203 | 0 | return "ASN sig error, unsupported hash type"; |
204 | | |
205 | 0 | case ASN_SIG_KEY_E : |
206 | 0 | return "ASN sig error, unsupported key type"; |
207 | | |
208 | 0 | case ASN_DH_KEY_E : |
209 | 0 | return "ASN key init error, invalid input"; |
210 | | |
211 | 0 | case ASN_CRIT_EXT_E: |
212 | 0 | return "X.509 Critical extension ignored or invalid"; |
213 | | |
214 | 0 | case ASN_ALT_NAME_E: |
215 | 0 | return "ASN alternate name error"; |
216 | | |
217 | 0 | case ECC_BAD_ARG_E : |
218 | 0 | return "ECC input argument wrong type, invalid input"; |
219 | | |
220 | 0 | case ASN_ECC_KEY_E : |
221 | 0 | return "ECC ASN1 bad key data, invalid input"; |
222 | | |
223 | 0 | case ECC_CURVE_OID_E : |
224 | 0 | return "ECC curve sum OID unsupported, invalid input"; |
225 | | |
226 | 0 | case BAD_FUNC_ARG : |
227 | 0 | return "Bad function argument"; |
228 | | |
229 | 0 | case NOT_COMPILED_IN : |
230 | 0 | return "Feature not compiled in"; |
231 | | |
232 | 0 | case UNICODE_SIZE_E : |
233 | 0 | return "Unicode password too big"; |
234 | | |
235 | 0 | case NO_PASSWORD : |
236 | 0 | return "No password provided by user"; |
237 | | |
238 | 0 | case ALT_NAME_E : |
239 | 0 | return "Alt Name problem, too big"; |
240 | | |
241 | 0 | case AES_GCM_AUTH_E: |
242 | 0 | return "AES-GCM Authentication check fail"; |
243 | | |
244 | 0 | case AES_CCM_AUTH_E: |
245 | 0 | return "AES-CCM Authentication check fail"; |
246 | | |
247 | 0 | case AES_SIV_AUTH_E: |
248 | 0 | return "AES-SIV authentication failure"; |
249 | | |
250 | 0 | case ASYNC_INIT_E: |
251 | 0 | return "Async Init error"; |
252 | | |
253 | 0 | case COMPRESS_INIT_E: |
254 | 0 | return "Compress Init error"; |
255 | | |
256 | 0 | case COMPRESS_E: |
257 | 0 | return "Compress error"; |
258 | | |
259 | 0 | case DECOMPRESS_INIT_E: |
260 | 0 | return "DeCompress Init error"; |
261 | | |
262 | 0 | case DECOMPRESS_E: |
263 | 0 | return "DeCompress error"; |
264 | | |
265 | 0 | case BAD_ALIGN_E: |
266 | 0 | return "Bad alignment error, no alloc help"; |
267 | | |
268 | 0 | case ASN_NO_SIGNER_E : |
269 | 0 | #ifndef OPENSSL_EXTRA |
270 | 0 | return "ASN no signer error to confirm failure"; |
271 | | #else |
272 | | return "certificate verify failed"; |
273 | | #endif |
274 | | |
275 | 0 | case ASN_CRL_CONFIRM_E : |
276 | 0 | return "ASN CRL sig error, confirm failure"; |
277 | | |
278 | 0 | case ASN_CRL_NO_SIGNER_E : |
279 | 0 | return "ASN CRL no signer error to confirm failure"; |
280 | | |
281 | 0 | case CRL_CERT_DATE_ERR: |
282 | 0 | return "CRL date error"; |
283 | | |
284 | 0 | case ASN_OCSP_CONFIRM_E : |
285 | 0 | return "ASN OCSP sig error, confirm failure"; |
286 | | |
287 | 0 | case ASN_NO_PEM_HEADER: |
288 | 0 | return "ASN no PEM Header Error"; |
289 | | |
290 | 0 | case BAD_STATE_E: |
291 | 0 | return "Bad state operation"; |
292 | | |
293 | 0 | case BAD_PADDING_E: |
294 | 0 | return "Bad padding, message wrong length"; |
295 | | |
296 | 0 | case REQ_ATTRIBUTE_E: |
297 | 0 | return "Setting cert request attributes error"; |
298 | | |
299 | 0 | case PKCS7_OID_E: |
300 | 0 | return "PKCS#7 error: mismatched OID value"; |
301 | | |
302 | 0 | case PKCS7_RECIP_E: |
303 | 0 | return "PKCS#7 error: no matching recipient found"; |
304 | | |
305 | 0 | case WC_PKCS7_WANT_READ_E: |
306 | 0 | return "PKCS#7 operations wants more input, call again"; |
307 | | |
308 | 0 | case FIPS_NOT_ALLOWED_E: |
309 | 0 | return "FIPS mode not allowed error"; |
310 | | |
311 | 0 | case ASN_NAME_INVALID_E: |
312 | 0 | return "Name Constraint error"; |
313 | | |
314 | 0 | case RNG_FAILURE_E: |
315 | 0 | return "Random Number Generator failed"; |
316 | | |
317 | 0 | case HMAC_MIN_KEYLEN_E: |
318 | 0 | return "FIPS Mode HMAC Minimum Key Length error"; |
319 | | |
320 | 0 | case RSA_PAD_E: |
321 | 0 | return "Rsa Padding error"; |
322 | | |
323 | 0 | case LENGTH_ONLY_E: |
324 | 0 | return "Output length only set, not for other use error"; |
325 | | |
326 | 0 | case IN_CORE_FIPS_E: |
327 | 0 | return "In Core Integrity check FIPS error"; |
328 | | |
329 | 0 | case AES_KAT_FIPS_E: |
330 | 0 | return "AES Known Answer Test check FIPS error"; |
331 | | |
332 | 0 | case DES3_KAT_FIPS_E: |
333 | 0 | return "DES3 Known Answer Test check FIPS error"; |
334 | | |
335 | 0 | case HMAC_KAT_FIPS_E: |
336 | 0 | return "HMAC Known Answer Test check FIPS error"; |
337 | | |
338 | 0 | case RSA_KAT_FIPS_E: |
339 | 0 | return "RSA Known Answer Test check FIPS error"; |
340 | | |
341 | 0 | case DRBG_KAT_FIPS_E: |
342 | 0 | return "DRBG Known Answer Test check FIPS error"; |
343 | | |
344 | 0 | case DRBG_CONT_FIPS_E: |
345 | 0 | return "DRBG Continuous Test FIPS error"; |
346 | | |
347 | 0 | case AESGCM_KAT_FIPS_E: |
348 | 0 | return "AESGCM Known Answer Test check FIPS error"; |
349 | | |
350 | 0 | case THREAD_STORE_KEY_E: |
351 | 0 | return "Thread Storage Key Create error"; |
352 | | |
353 | 0 | case THREAD_STORE_SET_E: |
354 | 0 | return "Thread Storage Set error"; |
355 | | |
356 | 0 | case MAC_CMP_FAILED_E: |
357 | 0 | return "MAC comparison failed"; |
358 | | |
359 | 0 | case IS_POINT_E: |
360 | 0 | return "ECC is point on curve failed"; |
361 | | |
362 | 0 | case ECC_INF_E: |
363 | 0 | return "ECC point at infinity error"; |
364 | | |
365 | 0 | case ECC_OUT_OF_RANGE_E: |
366 | 0 | return "ECC Qx or Qy out of range error"; |
367 | | |
368 | 0 | case ECC_PRIV_KEY_E: |
369 | 0 | return "ECC private key is not valid error"; |
370 | | |
371 | 0 | case SRP_CALL_ORDER_E: |
372 | 0 | return "SRP function called in the wrong order error"; |
373 | | |
374 | 0 | case SRP_VERIFY_E: |
375 | 0 | return "SRP proof verification error"; |
376 | | |
377 | 0 | case SRP_BAD_KEY_E: |
378 | 0 | return "SRP bad key values error"; |
379 | | |
380 | 0 | case ASN_NO_SKID: |
381 | 0 | return "ASN no Subject Key Identifier found error"; |
382 | | |
383 | 0 | case ASN_NO_AKID: |
384 | 0 | return "ASN no Authority Key Identifier found error"; |
385 | | |
386 | 0 | case ASN_NO_KEYUSAGE: |
387 | 0 | return "ASN no Key Usage found error"; |
388 | | |
389 | 0 | case SKID_E: |
390 | 0 | return "Setting Subject Key Identifier error"; |
391 | | |
392 | 0 | case AKID_E: |
393 | 0 | return "Setting Authority Key Identifier error"; |
394 | | |
395 | 0 | case KEYUSAGE_E: |
396 | 0 | return "Key Usage value error"; |
397 | | |
398 | 0 | case EXTKEYUSAGE_E: |
399 | 0 | return "Extended Key Usage value error"; |
400 | | |
401 | 0 | case CERTPOLICIES_E: |
402 | 0 | return "Setting Certificate Policies error"; |
403 | | |
404 | 0 | case WC_INIT_E: |
405 | 0 | return "wolfCrypt Initialize Failure error"; |
406 | | |
407 | 0 | case SIG_VERIFY_E: |
408 | 0 | return "Signature verify error"; |
409 | | |
410 | 0 | case BAD_COND_E: |
411 | 0 | return "Bad condition variable operation error"; |
412 | | |
413 | 0 | case SIG_TYPE_E: |
414 | 0 | return "Signature type not enabled/available"; |
415 | | |
416 | 0 | case HASH_TYPE_E: |
417 | 0 | return "Hash type not enabled/available"; |
418 | | |
419 | 0 | case WC_KEY_SIZE_E: |
420 | 0 | return "Key size error, either too small or large"; |
421 | | |
422 | 0 | case ASN_COUNTRY_SIZE_E: |
423 | 0 | return "Country code size error, either too small or large"; |
424 | | |
425 | 0 | case MISSING_RNG_E: |
426 | 0 | return "RNG required but not provided"; |
427 | | |
428 | 0 | case ASN_PATHLEN_SIZE_E: |
429 | 0 | return "ASN CA path length value too large error"; |
430 | | |
431 | 0 | case ASN_PATHLEN_INV_E: |
432 | 0 | return "ASN CA path length larger than signer error"; |
433 | | |
434 | 0 | case BAD_KEYWRAP_ALG_E: |
435 | 0 | return "Unsupported key wrap algorithm error"; |
436 | | |
437 | 0 | case BAD_KEYWRAP_IV_E: |
438 | 0 | return "Decrypted AES key wrap IV does not match expected"; |
439 | | |
440 | 0 | case WC_CLEANUP_E: |
441 | 0 | return "wolfcrypt cleanup failed"; |
442 | | |
443 | 0 | case ECC_CDH_KAT_FIPS_E: |
444 | 0 | return "wolfcrypt FIPS ECC CDH Known Answer Test Failure"; |
445 | | |
446 | 0 | case DH_CHECK_PUB_E: |
447 | 0 | return "DH Check Public Key failure"; |
448 | | |
449 | 0 | case BAD_PATH_ERROR: |
450 | 0 | return "Bad path for opendir error"; |
451 | | |
452 | 0 | case ASYNC_OP_E: |
453 | 0 | return "Async operation error"; |
454 | | |
455 | 0 | case BAD_OCSP_RESPONDER: |
456 | 0 | return "Invalid OCSP Responder, missing specific key usage extensions"; |
457 | | |
458 | 0 | case ECC_PRIVATEONLY_E: |
459 | 0 | return "Invalid use of private only ECC key"; |
460 | | |
461 | 0 | case WC_HW_E: |
462 | 0 | return "Error with hardware crypto use"; |
463 | | |
464 | 0 | case WC_HW_WAIT_E: |
465 | 0 | return "Hardware waiting on resource"; |
466 | | |
467 | 0 | case PSS_SALTLEN_E: |
468 | 0 | return "PSS - Length of salt is too big for hash algorithm"; |
469 | | |
470 | 0 | case PRIME_GEN_E: |
471 | 0 | return "Unable to find a prime for RSA key"; |
472 | | |
473 | 0 | case BER_INDEF_E: |
474 | 0 | return "Unable to decode an indefinite length encoded message"; |
475 | | |
476 | 0 | case RSA_OUT_OF_RANGE_E: |
477 | 0 | return "Ciphertext to decrypt is out of range"; |
478 | | |
479 | 0 | case RSAPSS_PAT_FIPS_E: |
480 | 0 | return "wolfcrypt FIPS RSA-PSS Pairwise Agreement Test Failure"; |
481 | | |
482 | 0 | case ECDSA_PAT_FIPS_E: |
483 | 0 | return "wolfcrypt FIPS ECDSA Pairwise Agreement Test Failure"; |
484 | | |
485 | 0 | case DH_KAT_FIPS_E: |
486 | 0 | return "wolfcrypt FIPS DH Known Answer Test Failure"; |
487 | | |
488 | 0 | case AESCCM_KAT_FIPS_E: |
489 | 0 | return "AESCCM Known Answer Test check FIPS error"; |
490 | | |
491 | 0 | case SHA3_KAT_FIPS_E: |
492 | 0 | return "SHA-3 Known Answer Test check FIPS error"; |
493 | | |
494 | 0 | case ECDHE_KAT_FIPS_E: |
495 | 0 | return "wolfcrypt FIPS ECDHE Known Answer Test Failure"; |
496 | | |
497 | 0 | case AES_GCM_OVERFLOW_E: |
498 | 0 | return "AES-GCM invocation counter overflow"; |
499 | | |
500 | 0 | case AES_CCM_OVERFLOW_E: |
501 | 0 | return "AES-CCM invocation counter overflow"; |
502 | | |
503 | 0 | case RSA_KEY_PAIR_E: |
504 | 0 | return "RSA Key Pair-Wise Consistency check fail"; |
505 | | |
506 | 0 | case DH_CHECK_PRIV_E: |
507 | 0 | return "DH Check Private Key failure"; |
508 | | |
509 | 0 | case WC_AFALG_SOCK_E: |
510 | 0 | return "AF_ALG socket error"; |
511 | | |
512 | 0 | case WC_DEVCRYPTO_E: |
513 | 0 | return "Error with /dev/crypto"; |
514 | | |
515 | 0 | case ZLIB_INIT_ERROR: |
516 | 0 | return "zlib init error"; |
517 | | |
518 | 0 | case ZLIB_COMPRESS_ERROR: |
519 | 0 | return "zlib compress error"; |
520 | | |
521 | 0 | case ZLIB_DECOMPRESS_ERROR: |
522 | 0 | return "zlib decompress error"; |
523 | | |
524 | 0 | case PKCS7_NO_SIGNER_E: |
525 | 0 | return "No signer in PKCS#7 signed data"; |
526 | | |
527 | 0 | case CRYPTOCB_UNAVAILABLE: |
528 | 0 | return "Crypto callback unavailable"; |
529 | | |
530 | 0 | case PKCS7_SIGNEEDS_CHECK: |
531 | 0 | return "Signature found but no certificate to verify"; |
532 | | |
533 | 0 | case PSS_SALTLEN_RECOVER_E: |
534 | 0 | return "PSS - Salt length unable to be recovered"; |
535 | | |
536 | 0 | case CHACHA_POLY_OVERFLOW: |
537 | 0 | return "wolfcrypt - ChaCha20_Poly1305 limit overflow 4GB"; |
538 | | |
539 | 0 | case ASN_SELF_SIGNED_E: |
540 | 0 | return "ASN self-signed certificate error"; |
541 | | |
542 | 0 | case SAKKE_VERIFY_FAIL_E: |
543 | 0 | return "SAKKE derivation verification error"; |
544 | | |
545 | 0 | case MISSING_IV: |
546 | 0 | return "Required IV not set"; |
547 | | |
548 | 0 | case MISSING_KEY: |
549 | 0 | return "Required key not set"; |
550 | | |
551 | 0 | case BAD_LENGTH_E: |
552 | 0 | return "Value of length parameter is invalid."; |
553 | | |
554 | 0 | case ECDSA_KAT_FIPS_E: |
555 | 0 | return "wolfcrypt FIPS ECDSA Known Answer Test Failure"; |
556 | | |
557 | 0 | case RSA_PAT_FIPS_E: |
558 | 0 | return "wolfcrypt FIPS RSA Pairwise Agreement Test Failure"; |
559 | | |
560 | 0 | case KDF_TLS12_KAT_FIPS_E: |
561 | 0 | return "wolfcrypt FIPS TLSv1.2 KDF Known Answer Test Failure"; |
562 | | |
563 | 0 | case KDF_TLS13_KAT_FIPS_E: |
564 | 0 | return "wolfcrypt FIPS TLSv1.3 KDF Known Answer Test Failure"; |
565 | | |
566 | 0 | case KDF_SSH_KAT_FIPS_E: |
567 | 0 | return "wolfcrypt FIPS SSH KDF Known Answer Test Failure"; |
568 | | |
569 | 0 | case DHE_PCT_E: |
570 | 0 | return "wolfcrypt DHE Pairwise Consistency Test Failure"; |
571 | | |
572 | 0 | case ECC_PCT_E: |
573 | 0 | return "wolfcrypt ECDHE Pairwise Consistency Test Failure"; |
574 | | |
575 | 0 | case FIPS_PRIVATE_KEY_LOCKED_E: |
576 | 0 | return "Cannot export private key, locked"; |
577 | | |
578 | 0 | case PROTOCOLCB_UNAVAILABLE: |
579 | 0 | return "Protocol callback unavailable"; |
580 | | |
581 | 0 | case NO_VALID_DEVID: |
582 | 0 | return "No valid device ID set"; |
583 | | |
584 | 0 | case IO_FAILED_E: |
585 | 0 | return "Input/output failure"; |
586 | | |
587 | 0 | case SYSLIB_FAILED_E: |
588 | 0 | return "System/library call failed"; |
589 | | |
590 | 0 | case USE_HW_PSK: |
591 | 0 | return "Callback indicates that HW has PSK"; |
592 | | |
593 | 0 | case ENTROPY_RT_E: |
594 | 0 | return "Entropy Repetition Test failed"; |
595 | | |
596 | 0 | case ENTROPY_APT_E: |
597 | 0 | return "Entropy Adaptive Proportion Test failed"; |
598 | | |
599 | 0 | case ASN_DEPTH_E: |
600 | 0 | return "Invalid ASN.1 - depth check"; |
601 | | |
602 | 0 | case ASN_LEN_E: |
603 | 0 | return "ASN.1 length invalid"; |
604 | | |
605 | 0 | case SM4_GCM_AUTH_E: |
606 | 0 | return "SM4-GCM Authentication check fail"; |
607 | | |
608 | 0 | case SM4_CCM_AUTH_E: |
609 | 0 | return "SM4-CCM Authentication check fail"; |
610 | | |
611 | 0 | case FIPS_DEGRADED_E: |
612 | 0 | return "FIPS module in DEGRADED mode"; |
613 | | |
614 | 0 | case AES_EAX_AUTH_E: |
615 | 0 | return "AES-EAX Authentication check fail"; |
616 | | |
617 | 0 | case KEY_EXHAUSTED_E: |
618 | 0 | return "Key no longer usable for operation"; |
619 | | |
620 | 0 | case FIPS_INVALID_VER_E: |
621 | 0 | return "Invalid FIPS version defined, check length"; |
622 | | |
623 | 0 | case FIPS_DATA_SZ_E: |
624 | 0 | return "FIPS Module Data too large adjust MAX_FIPS_DATA_SZ"; |
625 | | |
626 | 0 | case FIPS_CODE_SZ_E: |
627 | 0 | return "FIPS Module Code too large adjust MAX_FIPS_CODE_SZ"; |
628 | | |
629 | 0 | case KDF_SRTP_KAT_FIPS_E: |
630 | 0 | return "wolfCrypt FIPS SRTP-KDF Known Answer Test Failure"; |
631 | | |
632 | 0 | case ED25519_KAT_FIPS_E: |
633 | 0 | return "wolfCrypt FIPS Ed25519 Known Answer Test Failure"; |
634 | | |
635 | 0 | case ED448_KAT_FIPS_E: |
636 | 0 | return "wolfCrypt FIPS Ed448 Known Answer Test Failure"; |
637 | | |
638 | 0 | case PBKDF2_KAT_FIPS_E: |
639 | 0 | return "wolfCrypt FIPS PBKDF2 Known Answer Test Failure"; |
640 | | |
641 | 0 | case WC_KEY_MISMATCH_E: |
642 | 0 | return "key values mismatch"; |
643 | | |
644 | 0 | case DEADLOCK_AVERTED_E: |
645 | 0 | return "Deadlock averted -- retry the call"; |
646 | | |
647 | 0 | case ASCON_AUTH_E: |
648 | 0 | return "ASCON Authentication check fail"; |
649 | | |
650 | 0 | case WC_ACCEL_INHIBIT_E: |
651 | 0 | return "Crypto acceleration is currently inhibited"; |
652 | | |
653 | 0 | case BAD_INDEX_E: |
654 | 0 | return "Bad index"; |
655 | | |
656 | 0 | case INTERRUPTED_E: |
657 | 0 | return "Process interrupted"; |
658 | | |
659 | 0 | case MAX_CODE_E: |
660 | 0 | case WC_SPAN1_MIN_CODE_E: |
661 | 0 | case MIN_CODE_E: |
662 | 0 | default: |
663 | 0 | return "unknown error number"; |
664 | 0 | } |
665 | 0 | } |
666 | | |
667 | | #ifdef WOLFSSL_DEBUG_TRACE_ERROR_CODES |
668 | | #include <wolfssl/debug-trace-error-codes.h> |
669 | | #endif |
670 | | |
671 | | void wc_ErrorString(int error, char* buffer) |
672 | 0 | { |
673 | 0 | XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ); |
674 | 0 | buffer[WOLFSSL_MAX_ERROR_SZ-1] = 0; |
675 | 0 | } |
676 | | #endif /* !NO_ERROR_STRINGS */ |