Wiki     Blog     Roadmap     Timeline     New Ticket     View Tickets     Project Search

source: releases/Apple/OSX-10.8.0/SmartCardServices-55105/src/PCSC/reader.h @ 160

Revision 155, 13.0 KB checked in by geddis@…, 22 months ago (diff)

Importing SmartCardServices?-55105 from Apple Release OS X Mountain Lion v10.8.0

Line 
1/*
2 * MUSCLE SmartCard Development ( http://www.linuxnet.com )
3 *
4 * Copyright (C) 1999-2005
5 *  David Corcoran <corcoran@linuxnet.com>
6 * Copyright (C) 2005-2009
7 *  Ludovic Rousseau <ludovic.rousseau@free.fr>
8 *
9 * $Id: reader.h 123 2010-03-27 10:50:42Z ludovic.rousseau@gmail.com $
10 */
11
12/**
13 * @file
14 * @brief This keeps a list of defines shared between the driver and the application
15 */
16
17#ifndef __reader_h__
18#define __reader_h__
19
20/*
21 * Tags for requesting card and reader attributes
22 */
23
24#define SCARD_ATTR_VALUE(Class, Tag) ((((ULONG)(Class)) << 16) | ((ULONG)(Tag)))
25
26#define SCARD_CLASS_VENDOR_INFO     1   /**< Vendor information definitions */
27#define SCARD_CLASS_COMMUNICATIONS  2   /**< Communication definitions */
28#define SCARD_CLASS_PROTOCOL        3   /**< Protocol definitions */
29#define SCARD_CLASS_POWER_MGMT      4   /**< Power Management definitions */
30#define SCARD_CLASS_SECURITY        5   /**< Security Assurance definitions */
31#define SCARD_CLASS_MECHANICAL      6   /**< Mechanical characteristic definitions */
32#define SCARD_CLASS_VENDOR_DEFINED  7   /**< Vendor specific definitions */
33#define SCARD_CLASS_IFD_PROTOCOL    8   /**< Interface Device Protocol options */
34#define SCARD_CLASS_ICC_STATE       9   /**< ICC State specific definitions */
35#define SCARD_CLASS_SYSTEM     0x7fff   /**< System-specific definitions */
36
37#define SCARD_ATTR_VENDOR_NAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0100) /**< Vendor name. */
38#define SCARD_ATTR_VENDOR_IFD_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0101) /**< Vendor-supplied interface device type (model designation of reader). */
39#define SCARD_ATTR_VENDOR_IFD_VERSION SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0102) /**< Vendor-supplied interface device version (DWORD in the form 0xMMmmbbbb where MM = major version, mm = minor version, and bbbb = build number). */
40#define SCARD_ATTR_VENDOR_IFD_SERIAL_NO SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0103) /**< Vendor-supplied interface device serial number. */
41#define SCARD_ATTR_CHANNEL_ID SCARD_ATTR_VALUE(SCARD_CLASS_COMMUNICATIONS, 0x0110) /**< DWORD encoded as 0xDDDDCCCC, where DDDD = data channel type and CCCC = channel number */
42#define SCARD_ATTR_ASYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0120) /**< FIXME */
43#define SCARD_ATTR_DEFAULT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0121) /**< Default clock rate, in kHz. */
44#define SCARD_ATTR_MAX_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0122) /**< Maximum clock rate, in kHz. */
45#define SCARD_ATTR_DEFAULT_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0123) /**< Default data rate, in bps. */
46#define SCARD_ATTR_MAX_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0124) /**< Maximum data rate, in bps. */
47#define SCARD_ATTR_MAX_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0125) /**< Maximum bytes for information file size device. */
48#define SCARD_ATTR_SYNC_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0126) /**< FIXME */
49#define SCARD_ATTR_POWER_MGMT_SUPPORT SCARD_ATTR_VALUE(SCARD_CLASS_POWER_MGMT, 0x0131) /**< Zero if device does not support power down while smart card is inserted. Nonzero otherwise. */
50#define SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0140) /**< FIXME */
51#define SCARD_ATTR_USER_AUTH_INPUT_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0142) /**< FIXME */
52#define SCARD_ATTR_CHARACTERISTICS SCARD_ATTR_VALUE(SCARD_CLASS_MECHANICAL, 0x0150) /**< DWORD indicating which mechanical characteristics are supported. If zero, no special characteristics are supported. Note that multiple bits can be set */
53
54#define SCARD_ATTR_CURRENT_PROTOCOL_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0201) /**< FIXME */
55#define SCARD_ATTR_CURRENT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0202) /**< Current clock rate, in kHz. */
56#define SCARD_ATTR_CURRENT_F SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0203) /**< Clock conversion factor. */
57#define SCARD_ATTR_CURRENT_D SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0204) /**< Bit rate conversion factor. */
58#define SCARD_ATTR_CURRENT_N SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0205) /**< Current guard time. */
59#define SCARD_ATTR_CURRENT_W SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0206) /**< Current work waiting time. */
60#define SCARD_ATTR_CURRENT_IFSC SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0207) /**< Current byte size for information field size card. */
61#define SCARD_ATTR_CURRENT_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0208) /**< Current byte size for information field size device. */
62#define SCARD_ATTR_CURRENT_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0209) /**< Current block waiting time. */
63#define SCARD_ATTR_CURRENT_CWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020a) /**< Current character waiting time. */
64#define SCARD_ATTR_CURRENT_EBC_ENCODING SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020b) /**< Current error block control encoding. */
65#define SCARD_ATTR_EXTENDED_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020c) /**< FIXME */
66
67#define SCARD_ATTR_ICC_PRESENCE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0300) /**< Single byte indicating smart card presence */
68#define SCARD_ATTR_ICC_INTERFACE_STATUS SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0301) /**< Single byte. Zero if smart card electrical contact is not active; nonzero if contact is active. */
69#define SCARD_ATTR_CURRENT_IO_STATE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0302) /**< FIXME */
70#define SCARD_ATTR_ATR_STRING SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0303) /**< Answer to reset (ATR) string. */
71#define SCARD_ATTR_ICC_TYPE_PER_ATR SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0304) /**< Single byte indicating smart card type */
72
73#define SCARD_ATTR_ESC_RESET SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA000) /**< FIXME */
74#define SCARD_ATTR_ESC_CANCEL SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA003) /**< FIXME */
75#define SCARD_ATTR_ESC_AUTHREQUEST SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA005) /**< FIXME */
76#define SCARD_ATTR_MAXINPUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA007) /**< FIXME */
77
78#define SCARD_ATTR_DEVICE_UNIT SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0001) /**< Instance of this vendor's reader attached to the computer. The first instance will be device unit 0, the next will be unit 1 (if it is the same brand of reader) and so on. Two different brands of readers will both have zero for this value. */
79#define SCARD_ATTR_DEVICE_IN_USE SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0002) /**< Reserved for future use. */
80#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003)
81#define SCARD_ATTR_DEVICE_SYSTEM_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0004)
82#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0005)
83#define SCARD_ATTR_DEVICE_SYSTEM_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0006)
84#define SCARD_ATTR_SUPRESS_T1_IFS_REQUEST SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0007) /**< FIXME */
85
86#ifdef UNICODE
87#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_W /**< Reader's display name. */
88#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_W /**< Reader's system name. */
89#else
90#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A /**< Reader's display name. */
91#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_A /**< Reader's system name. */
92#endif
93
94/**
95 * Provide source compatibility on different platforms
96 */
97#define SCARD_CTL_CODE(code) (0x42000000 + (code))
98
99/**
100 * PC/SC part 10 v2.02.07 March 2010 reader tags
101 */
102#define CM_IOCTL_GET_FEATURE_REQUEST SCARD_CTL_CODE(3400)
103
104#define FEATURE_VERIFY_PIN_START         0x01
105#define FEATURE_VERIFY_PIN_FINISH        0x02
106#define FEATURE_MODIFY_PIN_START         0x03
107#define FEATURE_MODIFY_PIN_FINISH        0x04
108#define FEATURE_GET_KEY_PRESSED          0x05
109#define FEATURE_VERIFY_PIN_DIRECT        0x06 /**< Verify PIN */
110#define FEATURE_MODIFY_PIN_DIRECT        0x07 /**< Modify PIN */
111#define FEATURE_MCT_READERDIRECT         0x08 /**< deprecated */
112#define FEATURE_MCT_READER_DIRECT        0x08
113#define FEATURE_MCT_UNIVERSAL            0x09
114#define FEATURE_IFD_PIN_PROPERTIES       0x0A /**< retrieve properties of the IFD regarding PIN handling */
115#define FEATURE_ABORT                    0x0B
116#define FEATURE_SET_SPE_MESSAGE          0x0C
117#define FEATURE_VERIFY_PIN_DIRECT_APP_ID 0x0D
118#define FEATURE_MODIFY_PIN_DIRECT_APP_ID 0x0E
119#define FEATURE_WRITE_DISPLAY            0x0F
120#define FEATURE_GET_KEY                  0x10
121#define FEATURE_IFD_DISPLAY_PROPERTIES   0x11
122#define FEATURE_GET_TLV_PROPERTIES       0x12
123#define FEATURE_CCID_ESC_COMMAND         0x13
124
125/* structures used (but not defined) in PC/SC Part 10:
126 * "IFDs with Secure Pin Entry Capabilities" */
127
128#include <inttypes.h>
129
130/* Set structure elements aligment on bytes
131 * http://gcc.gnu.org/onlinedocs/gcc/Structure_002dPacking-Pragmas.html */
132#if defined(__APPLE__) | defined(sun)
133#pragma pack(1)
134#else
135#pragma pack(push, 1)
136#endif
137
138/** the structure must be 6-bytes long */
139typedef struct
140{
141        uint8_t tag;
142        uint8_t length;
143        uint32_t value; /**< This value is always in BIG ENDIAN format as documented in PCSC v2 part 10 ch 2.2 page 2. You can use ntohl() for example */
144} PCSC_TLV_STRUCTURE;
145
146/** the wLangId and wPINMaxExtraDigit are 16-bits long so are subject to byte
147 * ordering */
148#ifdef __BIG_ENDIAN__
149#define HOST_TO_CCID_16(x) ((((x) >> 8) & 0xFF) + ((x & 0xFF) << 8))
150#define HOST_TO_CCID_32(x) ((((x) >> 24) & 0xFF) + (((x) >> 8) & 0xFF00) + ((x & 0xFF00) << 8) + (((x) & 0xFF) << 24))
151#else
152#define HOST_TO_CCID_16(x) (x)
153#define HOST_TO_CCID_32(x) (x)
154#endif
155
156/** structure used with \ref FEATURE_VERIFY_PIN_DIRECT */
157typedef struct
158{
159        uint8_t bTimerOut;      /**< timeout is seconds (00 means use default timeout) */
160        uint8_t bTimerOut2; /**< timeout in seconds after first key stroke */
161        uint8_t bmFormatString; /**< formatting options */
162        uint8_t bmPINBlockString; /**< bits 7-4 bit size of PIN length in APDU,
163                                * bits 3-0 PIN block size in bytes after
164                                * justification and formatting */
165        uint8_t bmPINLengthFormat; /**< bits 7-5 RFU,
166                                 * bit 4 set if system units are bytes, clear if
167                                 * system units are bits,
168                                 * bits 3-0 PIN length position in system units */
169        uint16_t wPINMaxExtraDigit; /**< 0xXXYY where XX is minimum PIN size in digits,
170                                    and YY is maximum PIN size in digits */
171        uint8_t bEntryValidationCondition; /**< Conditions under which PIN entry should
172                                         * be considered complete */
173        uint8_t bNumberMessage; /**< Number of messages to display for PIN verification */
174        uint16_t wLangId; /**< Language for messages */
175        uint8_t bMsgIndex; /**< Message index (should be 00) */
176        uint8_t bTeoPrologue[3]; /**< T=1 block prologue field to use (fill with 00) */
177        uint32_t ulDataLength; /**< length of Data to be sent to the ICC */
178        uint8_t abData[1]; /**< Data to send to the ICC */
179} PIN_VERIFY_STRUCTURE;
180
181/** structure used with \ref FEATURE_MODIFY_PIN_DIRECT */
182typedef struct
183{
184        uint8_t bTimerOut;      /**< timeout is seconds (00 means use default timeout) */
185        uint8_t bTimerOut2; /**< timeout in seconds after first key stroke */
186        uint8_t bmFormatString; /**< formatting options */
187        uint8_t bmPINBlockString; /**< bits 7-4 bit size of PIN length in APDU,
188                                * bits 3-0 PIN block size in bytes after
189                                * justification and formatting */
190        uint8_t bmPINLengthFormat; /**< bits 7-5 RFU,
191                                 * bit 4 set if system units are bytes, clear if
192                                 * system units are bits,
193                                 * bits 3-0 PIN length position in system units */
194        uint8_t bInsertionOffsetOld; /**< Insertion position offset in bytes for
195                                     the current PIN */
196        uint8_t bInsertionOffsetNew; /**< Insertion position offset in bytes for
197                                     the new PIN */
198        uint16_t wPINMaxExtraDigit;
199                                 /**< 0xXXYY where XX is minimum PIN size in digits,
200                                    and YY is maximum PIN size in digits */
201        uint8_t bConfirmPIN; /**< Flags governing need for confirmation of new PIN */
202        uint8_t bEntryValidationCondition; /**< Conditions under which PIN entry should
203                                         * be considered complete */
204        uint8_t bNumberMessage; /**< Number of messages to display for PIN verification*/
205        uint16_t wLangId; /**< Language for messages */
206        uint8_t bMsgIndex1; /**< index of 1st prompting message */
207        uint8_t bMsgIndex2; /**< index of 2d prompting message */
208        uint8_t bMsgIndex3; /**< index of 3d prompting message */
209        uint8_t bTeoPrologue[3]; /**< T=1 block prologue field to use (fill with 00) */
210        uint32_t ulDataLength; /**< length of Data to be sent to the ICC */
211        uint8_t abData[1]; /**< Data to send to the ICC */
212} PIN_MODIFY_STRUCTURE;
213
214/** structure used with \ref FEATURE_IFD_PIN_PROPERTIES */
215typedef struct {
216        uint16_t wLcdLayout; /**< display characteristics */
217        uint8_t bEntryValidationCondition;
218        uint8_t bTimeOut2;
219} PIN_PROPERTIES_STRUCTURE;
220
221/* restore default structure elements alignment */
222#if defined(__APPLE__) | defined(sun)
223#pragma pack()
224#else
225#pragma pack(pop)
226#endif
227
228#endif
229
Note: See TracBrowser for help on using the repository browser.