1 |
List of SCardGetAttrib() commands supported by the CCID driver
|
2 |
==============================================================
|
3 |
|
4 |
PC/SC provides the SCardGetAttrib() function to request some attributes from
|
5 |
the driver.
|
6 |
|
7 |
|
8 |
PC/SC function prototype
|
9 |
"""""""""""""""""""""""""
|
10 |
|
11 |
LONG SCardGetAttrib(SCARDHANDLE hCard,
|
12 |
DWORD dwAttrId,
|
13 |
LPBYTE pbAttr,
|
14 |
LPDWORD pcbAttrLen);
|
15 |
|
16 |
Parameters:
|
17 |
|
18 |
hCard IN Connection made from SCardConnect
|
19 |
dwAttrId IN Identifier for the attribute to get
|
20 |
pbAttr OUT Pointer to a buffer that receives the attribute
|
21 |
pcbAttrLen IN/OUT Length of the pbAttr buffer in bytes
|
22 |
|
23 |
If the attribute is not supported the applications receive the error
|
24 |
SCARD_E_UNSUPPORTED_FEATURE (or SCARD_E_NOT_TRANSACTED for pcsc-lite
|
25 |
version < 1.3.3)
|
26 |
|
27 |
|
28 |
supported attributes
|
29 |
""""""""""""""""""""
|
30 |
|
31 |
SCARD_ATTR_ATR_STRING
|
32 |
ATR of the card
|
33 |
|
34 |
SCARD_ATTR_ICC_INTERFACE_STATUS
|
35 |
Single byte. Zero if smart card electrical contact is not active;
|
36 |
nonzero if contact is active.
|
37 |
|
38 |
SCARD_ATTR_ICC_PRESENCE
|
39 |
Single byte indicating smart card presence:
|
40 |
0 = not present
|
41 |
1 = card present but not swallowed (applies only if reader supports
|
42 |
smart card swallowing)
|
43 |
2 = card present (and swallowed if reader supports smart card swallowing)
|
44 |
4 = card confiscated.
|
45 |
|
46 |
SCARD_ATTR_VENDOR_IFD_VERSION
|
47 |
Vendor-supplied interface device version
|
48 |
DWORD in the form 0xMMmmbbbb where
|
49 |
MM = major version,
|
50 |
mm = minor version,
|
51 |
and bbbb = build number
|
52 |
It is the bcdDevice USB field.
|
53 |
|
54 |
SCARD_ATTR_VENDOR_NAME
|
55 |
name of the IFD (reader) vendor. It is the iManufacturer USB field
|
56 |
(if any).
|
57 |
|
58 |
SCARD_ATTR_MAXINPUT
|
59 |
maximum size of an APDU supported by the reader.
|
60 |
format is unsigned 32-bit unsing the byte order of the platform.
|
61 |
Correct readers should support up to 261 bytes (CLA + INS + P1 + P2 +
|
62 |
Lc + 255 bytes of data) but some readers support less (253 bytes only
|
63 |
for example). It is a problem for T=1 cards when the reader works in
|
64 |
APDU mode instead of TPDU and for T=0 cards.
|
65 |
|
66 |
SCARD_ATTR_VENDOR_IFD_SERIAL_NO
|
67 |
reader serial number (if available).
|
68 |
|
69 |
|
70 |
Sample code
|
71 |
===========
|
72 |
|
73 |
#include <reader.h>
|
74 |
|
75 |
{
|
76 |
[...]
|
77 |
|
78 |
unsigned char pbAtr[MAX_ATR_SIZE];
|
79 |
DWORD dwAtrLen;
|
80 |
|
81 |
/* use a NULL buffer to just get the needed length */
|
82 |
rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &dwAtrLen);
|
83 |
if (rv == SCARD_S_SUCCESS)
|
84 |
printf("ATR length: %ld\n", dwAtrLen);
|
85 |
|
86 |
dwAtrLen = sizeof(pbAtr);
|
87 |
rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
|
88 |
if (rv == SCARD_S_SUCCESS)
|
89 |
{
|
90 |
for (i = 0; i < dwAtrLen; i++)
|
91 |
printf("%02X ", pbAtr[i]);
|
92 |
printf("\n");
|
93 |
}
|
94 |
}
|
95 |
|