/[pcsclite]/trunk/Drivers/ccid/src/ccid.c
ViewVC logotype

Contents of /trunk/Drivers/ccid/src/ccid.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 890 - (hide annotations) (download)
Mon May 24 09:58:43 2004 UTC (9 years ago) by rousseau
File MIME type: text/plain
File size: 4209 byte(s)
- add some missing error codes
- low error values indicate the byte in error in the CCID frame
1 rousseau 413 /*
2     ccid.c: CCID common code
3     Copyright (C) 2003 Ludovic Rousseau
4    
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9    
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18     */
19    
20     /*
21     * $Id$
22     */
23    
24 rousseau 879 #include <stdio.h>
25     #include <pcsclite.h>
26     #include <ifdhandler.h>
27    
28 rousseau 413 #include "config.h"
29     #include "debug.h"
30 rousseau 879 #include "ccid.h"
31 rousseau 611 #include "defs.h"
32 rousseau 879 #include "ccid_ifdhandler.h"
33 rousseau 413 #include "commands.h"
34    
35     /*****************************************************************************
36     *
37     * ccid_open_hack
38     *
39     ****************************************************************************/
40     int ccid_open_hack(int lun)
41     {
42     _ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
43    
44     switch (ccid_descriptor->readerID)
45     {
46     case CARDMAN3121+1:
47     /* Reader announces APDU but is in fact TPDU */
48     ccid_descriptor->dwFeatures &= ~CCID_CLASS_EXCHANGE_MASK;
49     ccid_descriptor->dwFeatures |= CCID_CLASS_TPDU;
50     break;
51    
52 rousseau 445 /*
53     * Do not switch to APDU mode since it also swicth in EMV mode and
54     * may not work with non EMV cards
55     */
56 rousseau 413 case GEMPCKEY:
57     case GEMPCTWIN:
58     /* Reader announces TPDU but can do APDU */
59 rousseau 879 if (DriverOptions & DRIVER_OPTION_GEMPC_TWIN_KEY_APDU)
60 rousseau 413 {
61 rousseau 879 unsigned char cmd[] = "\xA0\x02";
62     unsigned char res[10];
63 rousseau 890 int length_res = sizeof(res);
64 rousseau 879
65     if (CmdEscape(lun, cmd, sizeof(cmd)-1, res, &length_res) == IFD_SUCCESS)
66     {
67     ccid_descriptor->dwFeatures &= ~CCID_CLASS_EXCHANGE_MASK;
68     ccid_descriptor->dwFeatures |= CCID_CLASS_SHORT_APDU;
69     }
70 rousseau 413 }
71     break;
72     }
73    
74     return 0;
75     } /* ccid_open_hack */
76    
77     /*****************************************************************************
78     *
79     * ccid_error
80     *
81     ****************************************************************************/
82     void ccid_error(int error, char *file, int line)
83     {
84     char *text;
85    
86     switch (error)
87     {
88     case 0x00:
89     text = "Command not supported or not allowed";
90     break;
91    
92     case 0x01:
93     text = "Wrong command length";
94     break;
95    
96     case 0x05:
97 rousseau 890 text = "Invalid slot number";
98 rousseau 413 break;
99    
100     case 0xA2:
101     text = "Card short-circuiting. Card powered off";
102     break;
103    
104     case 0xA3:
105     text = "ATR too long (> 33)";
106     break;
107    
108 rousseau 890 case 0xAB:
109     text = "No data exchanged";
110     break;
111    
112 rousseau 413 case 0xB0:
113     text = "Reader in EMV mode and T=1 message too long";
114     break;
115    
116     case 0xBB:
117     text = "Protocol error in EMV mode";
118     break;
119    
120     case 0xBD:
121     text = "Card error during T=1 exchange";
122     break;
123    
124     case 0xBE:
125     text = "Wrong APDU command length";
126     break;
127    
128 rousseau 890 case 0xE0:
129     text = "Slot busy";
130     break;
131    
132     case 0xEF:
133     text = "PIN cancelled";
134     break;
135    
136     case 0xF0:
137     text = "PIN timeout";
138     break;
139    
140     case 0xF2:
141     text = "Busy with autosequence";
142     break;
143    
144     case 0xF3:
145     text = "Deactivated protocol";
146     break;
147    
148 rousseau 413 case 0xF4:
149     text = "Procedure byte conflict";
150     break;
151    
152 rousseau 890 case 0xF5:
153     text = "Class not supported";
154     break;
155    
156     case 0xF6:
157     text = "Protocol not supported";
158     break;
159    
160 rousseau 413 case 0xF7:
161     text = "Invalid ATR checksum byte (TCK)";
162     break;
163    
164     case 0xF8:
165     text = "Invalid ATR first byte";
166     break;
167    
168 rousseau 890 case 0xFB:
169     text = "Hardware error";
170     break;
171    
172     case 0xFC:
173     text = "Overrun error";
174     break;
175    
176 rousseau 413 case 0xFD:
177     text = "Parity error during exchange";
178     break;
179    
180     case 0xFE:
181     text = "Card absent or mute";
182     break;
183    
184 rousseau 890 case 0xFF:
185     text = "Activity aborted by Host";
186     break;
187    
188 rousseau 413 default:
189 rousseau 890 if ((error >= 1) && (error <= 127))
190     {
191     char var_text[20];
192    
193     sprintf(var_text, "error on byte %d", error);
194     text = var_text;
195     }
196     else
197     text = "Unknown CCID error";
198 rousseau 413 break;
199     }
200     debug_msg("%s:%d %s", file, line, text);
201    
202     } /* ccid_error */
203    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5