Initial commit
[platform/upstream/ccid.git] / SCARDGETATTRIB.txt
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 SCARD_ATTR_CHANNEL_ID
70     DWORD in the form 0xDDDDCCCC with:
71     DDDD equal to 0x0020 for USB devices
72     CCCC equal to bus number in the high byte and device address in the
73     low byte
74
75 Sample code
76 ===========
77
78 #include <reader.h>
79
80 {
81     [...]
82
83     unsigned char pbAtr[MAX_ATR_SIZE];
84     DWORD dwAtrLen;
85
86     /* use a NULL buffer to just get the needed length */
87     rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &dwAtrLen);
88     if (rv == SCARD_S_SUCCESS)
89         printf("ATR length: %ld\n", dwAtrLen);
90
91     dwAtrLen = sizeof(pbAtr);
92     rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
93     if (rv == SCARD_S_SUCCESS)
94     {
95         for (i = 0; i < dwAtrLen; i++)
96             printf("%02X ", pbAtr[i]);
97         printf("\n");
98     }
99 }
100