File: SCARDGETATTRIB.txt

package info (click to toggle)
ccid 1.4.26-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 3,676 kB
  • sloc: ansic: 9,977; sh: 4,594; lex: 242; makefile: 144; perl: 97
file content (95 lines) | stat: -rw-r--r-- 2,691 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
List of SCardGetAttrib() commands supported by the CCID driver
==============================================================

PC/SC provides the SCardGetAttrib() function to request some attributes from
the driver.


PC/SC function prototype
"""""""""""""""""""""""""

LONG SCardGetAttrib(SCARDHANDLE hCard,
    DWORD dwAttrId,
    LPBYTE pbAttr,
    LPDWORD pcbAttrLen);

Parameters:

hCard       IN      Connection made from SCardConnect
dwAttrId    IN      Identifier for the attribute to get
pbAttr      OUT     Pointer to a buffer that receives the attribute
pcbAttrLen  IN/OUT  Length of the pbAttr buffer in bytes

If the attribute is not supported the applications receive the error
SCARD_E_UNSUPPORTED_FEATURE (or SCARD_E_NOT_TRANSACTED for pcsc-lite
version < 1.3.3)


supported attributes
""""""""""""""""""""

SCARD_ATTR_ATR_STRING
    ATR of the card

SCARD_ATTR_ICC_INTERFACE_STATUS
    Single byte. Zero if smart card electrical contact is not active;
    nonzero if contact is active.

SCARD_ATTR_ICC_PRESENCE
    Single byte indicating smart card presence:
    0 = not present
    1 = card present but not swallowed (applies only if reader supports
    smart card swallowing)
    2 = card present (and swallowed if reader supports smart card swallowing)
    4 = card confiscated.

SCARD_ATTR_VENDOR_IFD_VERSION
    Vendor-supplied interface device version
    DWORD in the form 0xMMmmbbbb where
    MM = major version,
    mm = minor version,
    and bbbb = build number
    It is the bcdDevice USB field.

SCARD_ATTR_VENDOR_NAME
   name of the IFD (reader) vendor. It is the iManufacturer USB field
   (if any).

SCARD_ATTR_MAXINPUT
   maximum size of an APDU supported by the reader.
   format is unsigned 32-bit unsing the byte order of the platform.
   Correct readers should support up to 261 bytes (CLA + INS + P1 + P2 +
   Lc + 255 bytes of data) but some readers support less (253 bytes only
   for example). It is a problem for T=1 cards when the reader works in
   APDU mode instead of TPDU and for T=0 cards.

SCARD_ATTR_VENDOR_IFD_SERIAL_NO
    reader serial number (if available).


Sample code
===========

#include <reader.h>

{
    [...]

    unsigned char pbAtr[MAX_ATR_SIZE];
    DWORD dwAtrLen;

    /* use a NULL buffer to just get the needed length */
    rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, NULL, &dwAtrLen);
    if (rv == SCARD_S_SUCCESS)
        printf("ATR length: %ld\n", dwAtrLen);

    dwAtrLen = sizeof(pbAtr);
    rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, pbAtr, &dwAtrLen);
    if (rv == SCARD_S_SUCCESS)
    {
        for (i = 0; i < dwAtrLen; i++)
            printf("%02X ", pbAtr[i]);
        printf("\n");
    }
}