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