xref: /freebsd-src/contrib/libfido2/src/err.c (revision 2ccfa855b2fc331819953e3de1b1c15ce5b95a7e)
10afa8e06SEd Maste /*
20afa8e06SEd Maste  * Copyright (c) 2018 Yubico AB. All rights reserved.
30afa8e06SEd Maste  * Use of this source code is governed by a BSD-style
40afa8e06SEd Maste  * license that can be found in the LICENSE file.
5*2ccfa855SEd Maste  * SPDX-License-Identifier: BSD-2-Clause
60afa8e06SEd Maste  */
70afa8e06SEd Maste 
80afa8e06SEd Maste #include "fido/err.h"
90afa8e06SEd Maste 
100afa8e06SEd Maste const char *
fido_strerr(int n)110afa8e06SEd Maste fido_strerr(int n)
120afa8e06SEd Maste {
130afa8e06SEd Maste 	switch (n) {
140afa8e06SEd Maste 	case FIDO_ERR_SUCCESS:
150afa8e06SEd Maste 		return "FIDO_ERR_SUCCESS";
160afa8e06SEd Maste 	case FIDO_ERR_INVALID_COMMAND:
170afa8e06SEd Maste 		return "FIDO_ERR_INVALID_COMMAND";
180afa8e06SEd Maste 	case FIDO_ERR_INVALID_PARAMETER:
190afa8e06SEd Maste 		return "FIDO_ERR_INVALID_PARAMETER";
200afa8e06SEd Maste 	case FIDO_ERR_INVALID_LENGTH:
210afa8e06SEd Maste 		return "FIDO_ERR_INVALID_LENGTH";
220afa8e06SEd Maste 	case FIDO_ERR_INVALID_SEQ:
230afa8e06SEd Maste 		return "FIDO_ERR_INVALID_SEQ";
240afa8e06SEd Maste 	case FIDO_ERR_TIMEOUT:
250afa8e06SEd Maste 		return "FIDO_ERR_TIMEOUT";
260afa8e06SEd Maste 	case FIDO_ERR_CHANNEL_BUSY:
270afa8e06SEd Maste 		return "FIDO_ERR_CHANNEL_BUSY";
280afa8e06SEd Maste 	case FIDO_ERR_LOCK_REQUIRED:
290afa8e06SEd Maste 		return "FIDO_ERR_LOCK_REQUIRED";
300afa8e06SEd Maste 	case FIDO_ERR_INVALID_CHANNEL:
310afa8e06SEd Maste 		return "FIDO_ERR_INVALID_CHANNEL";
320afa8e06SEd Maste 	case FIDO_ERR_CBOR_UNEXPECTED_TYPE:
330afa8e06SEd Maste 		return "FIDO_ERR_CBOR_UNEXPECTED_TYPE";
340afa8e06SEd Maste 	case FIDO_ERR_INVALID_CBOR:
350afa8e06SEd Maste 		return "FIDO_ERR_INVALID_CBOR";
360afa8e06SEd Maste 	case FIDO_ERR_MISSING_PARAMETER:
370afa8e06SEd Maste 		return "FIDO_ERR_MISSING_PARAMETER";
380afa8e06SEd Maste 	case FIDO_ERR_LIMIT_EXCEEDED:
390afa8e06SEd Maste 		return "FIDO_ERR_LIMIT_EXCEEDED";
400afa8e06SEd Maste 	case FIDO_ERR_UNSUPPORTED_EXTENSION:
410afa8e06SEd Maste 		return "FIDO_ERR_UNSUPPORTED_EXTENSION";
420afa8e06SEd Maste 	case FIDO_ERR_FP_DATABASE_FULL:
430afa8e06SEd Maste 		return "FIDO_ERR_FP_DATABASE_FULL";
440afa8e06SEd Maste 	case FIDO_ERR_LARGEBLOB_STORAGE_FULL:
450afa8e06SEd Maste 		return "FIDO_ERR_LARGEBLOB_STORAGE_FULL";
460afa8e06SEd Maste 	case FIDO_ERR_CREDENTIAL_EXCLUDED:
470afa8e06SEd Maste 		return "FIDO_ERR_CREDENTIAL_EXCLUDED";
480afa8e06SEd Maste 	case FIDO_ERR_PROCESSING:
490afa8e06SEd Maste 		return "FIDO_ERR_PROCESSING";
500afa8e06SEd Maste 	case FIDO_ERR_INVALID_CREDENTIAL:
510afa8e06SEd Maste 		return "FIDO_ERR_INVALID_CREDENTIAL";
520afa8e06SEd Maste 	case FIDO_ERR_USER_ACTION_PENDING:
530afa8e06SEd Maste 		return "FIDO_ERR_USER_ACTION_PENDING";
540afa8e06SEd Maste 	case FIDO_ERR_OPERATION_PENDING:
550afa8e06SEd Maste 		return "FIDO_ERR_OPERATION_PENDING";
560afa8e06SEd Maste 	case FIDO_ERR_NO_OPERATIONS:
570afa8e06SEd Maste 		return "FIDO_ERR_NO_OPERATIONS";
580afa8e06SEd Maste 	case FIDO_ERR_UNSUPPORTED_ALGORITHM:
590afa8e06SEd Maste 		return "FIDO_ERR_UNSUPPORTED_ALGORITHM";
600afa8e06SEd Maste 	case FIDO_ERR_OPERATION_DENIED:
610afa8e06SEd Maste 		return "FIDO_ERR_OPERATION_DENIED";
620afa8e06SEd Maste 	case FIDO_ERR_KEY_STORE_FULL:
630afa8e06SEd Maste 		return "FIDO_ERR_KEY_STORE_FULL";
640afa8e06SEd Maste 	case FIDO_ERR_NOT_BUSY:
650afa8e06SEd Maste 		return "FIDO_ERR_NOT_BUSY";
660afa8e06SEd Maste 	case FIDO_ERR_NO_OPERATION_PENDING:
670afa8e06SEd Maste 		return "FIDO_ERR_NO_OPERATION_PENDING";
680afa8e06SEd Maste 	case FIDO_ERR_UNSUPPORTED_OPTION:
690afa8e06SEd Maste 		return "FIDO_ERR_UNSUPPORTED_OPTION";
700afa8e06SEd Maste 	case FIDO_ERR_INVALID_OPTION:
710afa8e06SEd Maste 		return "FIDO_ERR_INVALID_OPTION";
720afa8e06SEd Maste 	case FIDO_ERR_KEEPALIVE_CANCEL:
730afa8e06SEd Maste 		return "FIDO_ERR_KEEPALIVE_CANCEL";
740afa8e06SEd Maste 	case FIDO_ERR_NO_CREDENTIALS:
750afa8e06SEd Maste 		return "FIDO_ERR_NO_CREDENTIALS";
760afa8e06SEd Maste 	case FIDO_ERR_USER_ACTION_TIMEOUT:
770afa8e06SEd Maste 		return "FIDO_ERR_USER_ACTION_TIMEOUT";
780afa8e06SEd Maste 	case FIDO_ERR_NOT_ALLOWED:
790afa8e06SEd Maste 		return "FIDO_ERR_NOT_ALLOWED";
800afa8e06SEd Maste 	case FIDO_ERR_PIN_INVALID:
810afa8e06SEd Maste 		return "FIDO_ERR_PIN_INVALID";
820afa8e06SEd Maste 	case FIDO_ERR_PIN_BLOCKED:
830afa8e06SEd Maste 		return "FIDO_ERR_PIN_BLOCKED";
840afa8e06SEd Maste 	case FIDO_ERR_PIN_AUTH_INVALID:
850afa8e06SEd Maste 		return "FIDO_ERR_PIN_AUTH_INVALID";
860afa8e06SEd Maste 	case FIDO_ERR_PIN_AUTH_BLOCKED:
870afa8e06SEd Maste 		return "FIDO_ERR_PIN_AUTH_BLOCKED";
880afa8e06SEd Maste 	case FIDO_ERR_PIN_NOT_SET:
890afa8e06SEd Maste 		return "FIDO_ERR_PIN_NOT_SET";
900afa8e06SEd Maste 	case FIDO_ERR_PIN_REQUIRED:
910afa8e06SEd Maste 		return "FIDO_ERR_PIN_REQUIRED";
920afa8e06SEd Maste 	case FIDO_ERR_PIN_POLICY_VIOLATION:
930afa8e06SEd Maste 		return "FIDO_ERR_PIN_POLICY_VIOLATION";
940afa8e06SEd Maste 	case FIDO_ERR_PIN_TOKEN_EXPIRED:
950afa8e06SEd Maste 		return "FIDO_ERR_PIN_TOKEN_EXPIRED";
960afa8e06SEd Maste 	case FIDO_ERR_REQUEST_TOO_LARGE:
970afa8e06SEd Maste 		return "FIDO_ERR_REQUEST_TOO_LARGE";
980afa8e06SEd Maste 	case FIDO_ERR_ACTION_TIMEOUT:
990afa8e06SEd Maste 		return "FIDO_ERR_ACTION_TIMEOUT";
1000afa8e06SEd Maste 	case FIDO_ERR_UP_REQUIRED:
1010afa8e06SEd Maste 		return "FIDO_ERR_UP_REQUIRED";
1020afa8e06SEd Maste 	case FIDO_ERR_UV_BLOCKED:
1030afa8e06SEd Maste 		return "FIDO_ERR_UV_BLOCKED";
1040afa8e06SEd Maste 	case FIDO_ERR_UV_INVALID:
1050afa8e06SEd Maste 		return "FIDO_ERR_UV_INVALID";
1060afa8e06SEd Maste 	case FIDO_ERR_UNAUTHORIZED_PERM:
1070afa8e06SEd Maste 		return "FIDO_ERR_UNAUTHORIZED_PERM";
1080afa8e06SEd Maste 	case FIDO_ERR_ERR_OTHER:
1090afa8e06SEd Maste 		return "FIDO_ERR_ERR_OTHER";
1100afa8e06SEd Maste 	case FIDO_ERR_SPEC_LAST:
1110afa8e06SEd Maste 		return "FIDO_ERR_SPEC_LAST";
1120afa8e06SEd Maste 	case FIDO_ERR_TX:
1130afa8e06SEd Maste 		return "FIDO_ERR_TX";
1140afa8e06SEd Maste 	case FIDO_ERR_RX:
1150afa8e06SEd Maste 		return "FIDO_ERR_RX";
1160afa8e06SEd Maste 	case FIDO_ERR_RX_NOT_CBOR:
1170afa8e06SEd Maste 		return "FIDO_ERR_RX_NOT_CBOR";
1180afa8e06SEd Maste 	case FIDO_ERR_RX_INVALID_CBOR:
1190afa8e06SEd Maste 		return "FIDO_ERR_RX_INVALID_CBOR";
1200afa8e06SEd Maste 	case FIDO_ERR_INVALID_PARAM:
1210afa8e06SEd Maste 		return "FIDO_ERR_INVALID_PARAM";
1220afa8e06SEd Maste 	case FIDO_ERR_INVALID_SIG:
1230afa8e06SEd Maste 		return "FIDO_ERR_INVALID_SIG";
1240afa8e06SEd Maste 	case FIDO_ERR_INVALID_ARGUMENT:
1250afa8e06SEd Maste 		return "FIDO_ERR_INVALID_ARGUMENT";
1260afa8e06SEd Maste 	case FIDO_ERR_USER_PRESENCE_REQUIRED:
1270afa8e06SEd Maste 		return "FIDO_ERR_USER_PRESENCE_REQUIRED";
1280afa8e06SEd Maste 	case FIDO_ERR_NOTFOUND:
1290afa8e06SEd Maste 		return "FIDO_ERR_NOTFOUND";
1300afa8e06SEd Maste 	case FIDO_ERR_COMPRESS:
1310afa8e06SEd Maste 		return "FIDO_ERR_COMPRESS";
1320afa8e06SEd Maste 	case FIDO_ERR_INTERNAL:
1330afa8e06SEd Maste 		return "FIDO_ERR_INTERNAL";
1340afa8e06SEd Maste 	default:
1350afa8e06SEd Maste 		return "FIDO_ERR_UNKNOWN";
1360afa8e06SEd Maste 	}
1370afa8e06SEd Maste }
138