| 1 |
rousseau |
413 |
/*
|
| 2 |
|
|
ccid.h: CCID structures
|
| 3 |
|
|
Copyright (C) 2003 Ludovic Rousseau
|
| 4 |
|
|
|
| 5 |
rousseau |
1399 |
This library is free software; you can redistribute it and/or
|
| 6 |
|
|
modify it under the terms of the GNU Lesser General Public
|
| 7 |
|
|
License as published by the Free Software Foundation; either
|
| 8 |
|
|
version 2.1 of the License, or (at your option) any later version.
|
| 9 |
rousseau |
413 |
|
| 10 |
rousseau |
1399 |
This library is distributed in the hope that it will be useful,
|
| 11 |
rousseau |
413 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
rousseau |
1399 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 |
|
|
Lesser General Public License for more details.
|
| 14 |
rousseau |
413 |
|
| 15 |
rousseau |
1399 |
You should have received a copy of the GNU Lesser General Public
|
| 16 |
|
|
License along with this library; if not, write to the Free Software
|
| 17 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 18 |
rousseau |
413 |
*/
|
| 19 |
|
|
|
| 20 |
|
|
/*
|
| 21 |
|
|
* $Id$
|
| 22 |
|
|
*/
|
| 23 |
|
|
|
| 24 |
|
|
typedef struct
|
| 25 |
|
|
{
|
| 26 |
|
|
/*
|
| 27 |
|
|
* CCID Sequence number
|
| 28 |
|
|
*/
|
| 29 |
rousseau |
1148 |
unsigned char *pbSeq;
|
| 30 |
|
|
unsigned char real_bSeq;
|
| 31 |
rousseau |
413 |
|
| 32 |
|
|
/*
|
| 33 |
|
|
* VendorID << 16 + ProductID
|
| 34 |
|
|
*/
|
| 35 |
|
|
int readerID;
|
| 36 |
|
|
|
| 37 |
|
|
/*
|
| 38 |
|
|
* Maximum message length
|
| 39 |
|
|
*/
|
| 40 |
rousseau |
1567 |
unsigned int dwMaxCCIDMessageLength;
|
| 41 |
rousseau |
413 |
|
| 42 |
|
|
/*
|
| 43 |
rousseau |
672 |
* Maximum IFSD
|
| 44 |
|
|
*/
|
| 45 |
|
|
int dwMaxIFSD;
|
| 46 |
|
|
|
| 47 |
|
|
/*
|
| 48 |
rousseau |
900 |
* Features supported by the reader (directly from Class Descriptor)
|
| 49 |
rousseau |
413 |
*/
|
| 50 |
|
|
int dwFeatures;
|
| 51 |
|
|
|
| 52 |
rousseau |
693 |
/*
|
| 53 |
rousseau |
900 |
* PIN support of the reader (directly from Class Descriptor)
|
| 54 |
|
|
*/
|
| 55 |
|
|
char bPINSupport;
|
| 56 |
|
|
|
| 57 |
|
|
/*
|
| 58 |
rousseau |
693 |
* Default Clock
|
| 59 |
|
|
*/
|
| 60 |
|
|
int dwDefaultClock;
|
| 61 |
|
|
|
| 62 |
|
|
/*
|
| 63 |
rousseau |
1484 |
* Max Data Rate
|
| 64 |
|
|
*/
|
| 65 |
|
|
int dwMaxDataRate;
|
| 66 |
|
|
|
| 67 |
|
|
/*
|
| 68 |
rousseau |
1088 |
* Number of available slots
|
| 69 |
|
|
*/
|
| 70 |
|
|
char bMaxSlotIndex;
|
| 71 |
|
|
|
| 72 |
|
|
/*
|
| 73 |
|
|
* Slot in use
|
| 74 |
|
|
*/
|
| 75 |
|
|
char bCurrentSlotIndex;
|
| 76 |
|
|
|
| 77 |
rousseau |
1445 |
/*
|
| 78 |
|
|
* The array of data rates supported by the reader
|
| 79 |
|
|
*/
|
| 80 |
|
|
unsigned int *arrayOfSupportedDataRates;
|
| 81 |
rousseau |
1449 |
|
| 82 |
|
|
/*
|
| 83 |
|
|
* Read communication port timeout
|
| 84 |
|
|
* value is seconds for serial, milliseconds for USB
|
| 85 |
|
|
* this value can evolve dynamically if card request it (time processing).
|
| 86 |
|
|
*/
|
| 87 |
|
|
unsigned int readTimeout;
|
| 88 |
rousseau |
1445 |
|
| 89 |
rousseau |
413 |
} _ccid_descriptor;
|
| 90 |
|
|
|
| 91 |
rousseau |
900 |
/* Features from dwFeatures */
|
| 92 |
rousseau |
685 |
#define CCID_CLASS_AUTO_CONF_ATR 0x00000002
|
| 93 |
rousseau |
413 |
#define CCID_CLASS_AUTO_VOLTAGE 0x00000008
|
| 94 |
rousseau |
691 |
#define CCID_CLASS_AUTO_BAUD 0x00000020
|
| 95 |
rousseau |
1353 |
#define CCID_CLASS_AUTO_PPS_PROP 0x00000040
|
| 96 |
rousseau |
672 |
#define CCID_CLASS_AUTO_PPS_CUR 0x00000080
|
| 97 |
rousseau |
691 |
#define CCID_CLASS_AUTO_IFSD 0x00000400
|
| 98 |
rousseau |
1260 |
#define CCID_CLASS_CHARACTER 0x00000000
|
| 99 |
rousseau |
413 |
#define CCID_CLASS_TPDU 0x00010000
|
| 100 |
|
|
#define CCID_CLASS_SHORT_APDU 0x00020000
|
| 101 |
|
|
#define CCID_CLASS_EXTENDED_APDU 0x00040000
|
| 102 |
rousseau |
672 |
#define CCID_CLASS_EXCHANGE_MASK 0x00070000
|
| 103 |
rousseau |
413 |
|
| 104 |
rousseau |
900 |
/* Features from bPINSupport */
|
| 105 |
|
|
#define CCID_CLASS_PIN_VERIFY 0x01
|
| 106 |
|
|
#define CCID_CLASS_PIN_MODIFY 0x02
|
| 107 |
|
|
|
| 108 |
rousseau |
413 |
/* See CCID specs ch. 4.2.1 */
|
| 109 |
rousseau |
1258 |
#define CCID_ICC_PRESENT_ACTIVE 0x00 /* 00 0000 00 */
|
| 110 |
|
|
#define CCID_ICC_PRESENT_INACTIVE 0x01 /* 00 0000 01 */
|
| 111 |
|
|
#define CCID_ICC_ABSENT 0x02 /* 00 0000 20 */
|
| 112 |
|
|
#define CCID_ICC_STATUS_MASK 0x03 /* 00 0000 11 */
|
| 113 |
|
|
|
| 114 |
rousseau |
413 |
#define CCID_COMMAND_FAILED 0x40 /* 01 0000 00 */
|
| 115 |
|
|
#define CCID_TIME_EXTENSION 0x80 /* 10 0000 00 */
|
| 116 |
|
|
|
| 117 |
|
|
/* Product identification for special treatments */
|
| 118 |
|
|
#define GEMPC433 0x08E64433
|
| 119 |
|
|
#define GEMPCKEY 0x08E63438
|
| 120 |
|
|
#define GEMPCTWIN 0x08E63437
|
| 121 |
|
|
#define CARDMAN3121 0x076B3021
|
| 122 |
rousseau |
693 |
#define LTC31 0x07830003
|
| 123 |
rousseau |
1089 |
#define SCR331DI 0x04E65111
|
| 124 |
rousseau |
1504 |
#define SCR331DINTTCOM 0x04E65120
|
| 125 |
rousseau |
1225 |
#define CHERRYXX33 0x046A0005
|
| 126 |
rousseau |
1259 |
#define OZ776 0x0B977762
|
| 127 |
rousseau |
1309 |
#define SPR532 0x04E6E003
|
| 128 |
rousseau |
413 |
|
| 129 |
|
|
/* Escape sequence codes */
|
| 130 |
|
|
#define ESC_GEMPC_SET_ISO_MODE 1
|
| 131 |
|
|
#define ESC_GEMPC_SET_APDU_MODE 2
|
| 132 |
|
|
|
| 133 |
|
|
|
| 134 |
rousseau |
1106 |
int ccid_open_hack(unsigned int reader_index);
|
| 135 |
rousseau |
1494 |
void ccid_error(int error, char *file, int line, const char *function);
|
| 136 |
rousseau |
1106 |
_ccid_descriptor *get_ccid_descriptor(unsigned int reader_index);
|
| 137 |
rousseau |
413 |
|
| 138 |
|
|
/* convert a 4 byte integer in USB format into an int */
|
| 139 |
|
|
#define dw2i(a, x) ((((((a[x+3] << 8) + a[x+2]) << 8) + a[x+1]) << 8) + a[x])
|
| 140 |
|
|
|