File: SCARDGETATTRIB.txt

package info (click to toggle)
ccid 1.3.11-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,716 kB
  • ctags: 897
  • sloc: sh: 10,390; ansic: 6,869; makefile: 318; lex: 160; perl: 113
file content (78 lines) | stat: -rw-r--r-- 2,101 bytes parent folder | download | duplicates (2)
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
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_VENDOR_IFD_VERSION
    Vendor-supplied interface device version
    DWORD in the form 0xMMmmbbbb where
    MM = major version,
    mm = minor version,
    and bbbb = build number

SCARD_ATTR_VENDOR_NAME
   name of the IFD (driver) vendor

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.


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");
    }
}