Skip to content

Latest commit

 

History

History
112 lines (78 loc) · 2.9 KB

SCARDGETATTRIB.md

File metadata and controls

112 lines (78 loc) · 2.9 KB

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

See also SCardGetAttrib() in the pcsclite API documentation.

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.

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 using 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).

  • SCARD_ATTR_CHANNEL_ID

    DWORD in the form 0xDDDDCCCC with:

    • DDDD equal to 0x0020 for USB devices
    • CCCC equal to bus number in the high byte and device address in the low byte

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