1 /*
2  * errors.h: OpenSC error codes
3  *
4  * Copyright (C) 2001, 2002  Juha Yrjölä <juha.yrjola@iki.fi>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307	 USA
19  */
20 
21 #ifndef _OPENSC_ERRORS_H
22 #define _OPENSC_ERRORS_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define SC_SUCCESS				0
29 
30 /* Errors related to reader operation */
31 #define SC_ERROR_READER				-1100
32 #define SC_ERROR_NO_READERS_FOUND		-1101
33 /* Unused: -1102 */
34 /* Unused: -1103 */
35 #define SC_ERROR_CARD_NOT_PRESENT		-1104
36 #define SC_ERROR_CARD_REMOVED			-1105
37 #define SC_ERROR_CARD_RESET			-1106
38 #define SC_ERROR_TRANSMIT_FAILED		-1107
39 #define SC_ERROR_KEYPAD_TIMEOUT			-1108
40 #define SC_ERROR_KEYPAD_CANCELLED		-1109
41 #define SC_ERROR_KEYPAD_PIN_MISMATCH		-1110
42 #define SC_ERROR_KEYPAD_MSG_TOO_LONG		-1111
43 #define SC_ERROR_EVENT_TIMEOUT			-1112
44 #define SC_ERROR_CARD_UNRESPONSIVE		-1113
45 #define SC_ERROR_READER_DETACHED		-1114
46 #define SC_ERROR_READER_REATTACHED		-1115
47 #define SC_ERROR_READER_LOCKED			-1116
48 
49 /* Resulting from a card command or related to the card*/
50 #define SC_ERROR_CARD_CMD_FAILED		-1200
51 #define SC_ERROR_FILE_NOT_FOUND			-1201
52 #define SC_ERROR_RECORD_NOT_FOUND		-1202
53 #define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
54 #define SC_ERROR_INS_NOT_SUPPORTED		-1204
55 #define SC_ERROR_INCORRECT_PARAMETERS		-1205
56 #define SC_ERROR_WRONG_LENGTH			-1206
57 #define SC_ERROR_MEMORY_FAILURE			-1207
58 #define SC_ERROR_NO_CARD_SUPPORT		-1208
59 #define SC_ERROR_NOT_ALLOWED			-1209
60 #define SC_ERROR_INVALID_CARD			-1210
61 #define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
62 #define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
63 #define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
64 #define SC_ERROR_PIN_CODE_INCORRECT		-1214
65 #define SC_ERROR_FILE_ALREADY_EXISTS		-1215
66 #define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
67 #define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
68 #define SC_ERROR_CORRUPTED_DATA			-1218
69 #define SC_ERROR_FILE_END_REACHED		-1219
70 #define SC_ERROR_REF_DATA_NOT_USABLE	-1220
71 
72 /* Returned by OpenSC library when called with invalid arguments */
73 #define SC_ERROR_INVALID_ARGUMENTS		-1300
74 /* Unused: -1301 */
75 /* Unused: -1302 */
76 #define SC_ERROR_BUFFER_TOO_SMALL		-1303
77 #define SC_ERROR_INVALID_PIN_LENGTH		-1304
78 #define SC_ERROR_INVALID_DATA			-1305
79 
80 /* Resulting from OpenSC internal operation */
81 #define SC_ERROR_INTERNAL			-1400
82 #define SC_ERROR_INVALID_ASN1_OBJECT		-1401
83 #define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
84 #define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
85 #define SC_ERROR_OUT_OF_MEMORY			-1404
86 #define SC_ERROR_TOO_MANY_OBJECTS		-1405
87 #define SC_ERROR_OBJECT_NOT_VALID		-1406
88 #define SC_ERROR_OBJECT_NOT_FOUND		-1407
89 #define SC_ERROR_NOT_SUPPORTED			-1408
90 #define SC_ERROR_PASSPHRASE_REQUIRED		-1409
91 #define SC_ERROR_INCONSISTENT_CONFIGURATION	-1410
92 #define SC_ERROR_DECRYPT_FAILED			-1411
93 #define SC_ERROR_WRONG_PADDING			-1412
94 #define SC_ERROR_WRONG_CARD			-1413
95 #define SC_ERROR_CANNOT_LOAD_MODULE		-1414
96 #define SC_ERROR_OFFSET_TOO_LARGE		-1415
97 #define SC_ERROR_NOT_IMPLEMENTED		-1416
98 #define SC_ERROR_INVALID_TLV_OBJECT		-1417
99 #define SC_ERROR_TLV_END_OF_CONTENTS	-1418
100 
101 /* Relating to PKCS #15 init stuff */
102 #define SC_ERROR_PKCS15INIT			-1500
103 #define SC_ERROR_SYNTAX_ERROR			-1501
104 #define SC_ERROR_INCONSISTENT_PROFILE		-1502
105 #define SC_ERROR_INCOMPATIBLE_KEY		-1503
106 #define SC_ERROR_NO_DEFAULT_KEY			-1504
107 #define SC_ERROR_NON_UNIQUE_ID			-1505
108 #define SC_ERROR_CANNOT_LOAD_KEY		-1506
109 /* Unused: -1007 */
110 #define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
111 #define SC_ERROR_INVALID_PIN_REFERENCE		-1509
112 #define SC_ERROR_FILE_TOO_SMALL			-1510
113 
114 /* Related to secure messaging */
115 #define SC_ERROR_SM				-1600
116 #define SC_ERROR_SM_ENCRYPT_FAILED		-1601
117 #define SC_ERROR_SM_INVALID_LEVEL		-1602
118 #define SC_ERROR_SM_NO_SESSION_KEYS		-1603
119 #define SC_ERROR_SM_INVALID_SESSION_KEY		-1604
120 #define SC_ERROR_SM_NOT_INITIALIZED		-1605
121 #define SC_ERROR_SM_AUTHENTICATION_FAILED	-1606
122 #define SC_ERROR_SM_RAND_FAILED			-1607
123 #define SC_ERROR_SM_KEYSET_NOT_FOUND		-1608
124 #define SC_ERROR_SM_IFD_DATA_MISSING		-1609
125 #define SC_ERROR_SM_NOT_APPLIED			-1610
126 #define SC_ERROR_SM_SESSION_ALREADY_ACTIVE	-1611
127 #define SC_ERROR_SM_INVALID_CHECKSUM		-1612
128 
129 /* Errors that do not fit the categories above */
130 #define SC_ERROR_UNKNOWN			-1900
131 #define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
132 
133 const char *sc_strerror(int sc_errno);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif
140