0% found this document useful (0 votes)
216 views

Bit4Id PCSC Library For Bit4Id Minilector Devices: Pagina 1/23

This document describes a PCSC library provided by Bit4Id for its miniLector smart card reader devices on iOS and Android platforms. It implements a subset of the WinSCard API to allow legacy applications to interface with the miniLector devices. The document outlines the implemented API functions for connecting to readers, transmitting data, getting status information, and more. Screenshots of sample iOS and Android miniLector devices are also provided.

Uploaded by

Ronald Paico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
216 views

Bit4Id PCSC Library For Bit4Id Minilector Devices: Pagina 1/23

This document describes a PCSC library provided by Bit4Id for its miniLector smart card reader devices on iOS and Android platforms. It implements a subset of the WinSCard API to allow legacy applications to interface with the miniLector devices. The document outlines the implemented API functions for connecting to readers, transmitting data, getting status information, and more. Screenshots of sample iOS and Android miniLector devices are also provided.

Uploaded by

Ronald Paico
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

Bit4Id PCSC Library for Bit4ID miniLector devices

Pagina 1/23
Index
1Introduction........................................................................................................................................ 3
2APIs description................................................................................................................................. 4
2.1 iOS version................................................................................................................................. 4
2.1.1 ScardListReaders.................................................................................................................6
2.1.2 SCardConnect..................................................................................................................... 7
2.1.3 SCardDisconnect.................................................................................................................8
2.1.4 SCardReconnect..................................................................................................................9
2.1.5 SCardTransmit.................................................................................................................. 10
2.1.6 SCardGetAttrib................................................................................................................. 11
2.1.7 SCardGetStatusChange.....................................................................................................12
2.1.8 SCardStatus.......................................................................................................................13
2.2 Android version........................................................................................................................ 14
2.2.1 SCardListReaders..............................................................................................................16
2.2.2 SCardConnect................................................................................................................... 17
2.2.3 ScardDisconnect................................................................................................................18
2.2.4 SCardReconnect................................................................................................................19
2.2.5 SCardTransmit.................................................................................................................. 20
2.2.6 SCardGetAttrib................................................................................................................. 22
2.2.7 SCardGetStatusChange.....................................................................................................23
2.2.8 SCardStatus.......................................................................................................................24
3Appendix A – Error codes................................................................................................................26

1 Introduction
This document aims to describe the PCSC library provided by Bit4Id for Bit4Id miniLector devices.

Figure 1: miniLector Blue

Pagina 2/23
Figure 2: miniLector Pocket

Figure 3: miniLector EVO

The PCSC library was delivered for the Android and iOS mobile platforms in order to provide a
WinsSCard like standard interface for the device SDK and so encourage the use of these devices in
legacy applications. MiniLector EVO and MiniLector Pocket devices are usable only with Android
mobile platform because the USB is not available on iOS devices, of course.
The implementation of the WinSCard interface has to be considered incomplete. Only the APIs
which are needful in order to compile the Bit4Id middleware for the iOS and Android mobile
platforms have been implemented.
In the next paragraphs will be described the implementation of the WinSCard interface for the
Android and iOS devices.

2 APIs description
This paragraph describes PCSC library for Android and iOS mobile platform.

2.1 iOS version


The iOS version of the PCSC library is a module written in Objective C and it is compatible with iOS
8.0 and upper. The module is named pcsc and implements a set of WinSCard-like API and provides
a configuration view.
The set of implemented API consists of the following functions:

Pagina 3/23
1. SCardListReaders
2. SCardConnect
3. SCardDisconnect
4. SCardReconnect
5. SCardTransmit
6. SCardGetAttrib
7. SCardGetStatusChange
8. SCardStatus.
The configuration view is provided in order to allow the user applications to list the available
miniLector Blue devices and select the preferred one.
The below image shows the confguration view:

Figure 4: iOS configuration view

Client applications should call the library API LoadSetupView in order to show the configuration
view. The function LoadSetupView has no input parameters and returns an instance of the class
SetupViewController which is the class associated with the configuration view. In the below box is
listed a snippet of Swift code used for the configuration view presentation.

import pcsc
….
let configurationViewController = LoadSetupView()
self.presentViewController( configurationViewController, amimated: true,
completion: nil)

The package of the library consists of the following files:


1. modules.map: module description file, this file specifies the module name and the exported
symbols
2. SetupStoryboard.storyboard: storyboard containing the configuration view

Pagina 4/23
3. SetupViewController.h: header file containing the declaration of the class
SetupViewController associated with the configuration view
4. types.h: file with definitions of types and constants used by the module
5. winscard.h: header file containing the declaration of the WinSCard-like API functions.

2.1.1 ScardListReaders
The SCardListReaders function provides the list of readers eliminating duplicates. This function
only returns reader selected by the configuration view if it is currently attached to the system and
available for use. Reader groups are ignored and the method list all readers in the System,
regardless of what group or groups the readers are in.
Syntax:

LONG SCardListReaders(
SCARDCONTEXT hContext,
LPCTSTR mszGroups,
LPTSTR mszReaders,
LPDWORD pcchReaders)

Parameters:
hContext
Handle that identifies the resource manager context of the query. The parameter value is
ignored and the search for readers is not limited to any context.
mszGroups
Names of the reader groups defined to the system, as a multi-string. The parameter value is
ignored and all readers are listed regardless of what group or groups the readers are in.
mszReaders
Multi-string that lists the card readers. If this value is NULL, SCardListReaders ignores the
buffer length supplied in pcchReaders, writes the length of the buffer that would have been
returned if this parameter had not been NULL to pcchReaders, and returns a success code.
.pcchReaders
Length of the mszReaders buffer in characters. This parameter receives the actual length of
the multi-string structure, including all trailing null characters. SCARD_AUTOALLOCATE
value is not supported.
Returned value:
ScardListReaders function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.2 SCardConnect
The SCardConnect function establishes a connection (using a specific resource manager context)
between the calling application and a smart card contained by a specific reader. If no card exists in
the specified reader, an error is returned.

Pagina 5/23
Syntax:
LONG SCardConnect(
SCARDCONTEXT
LPCTSTR szReader,
hContext,
DWORD dwShareMode,
DWORD dwPreferredProtocols,
LPSCARDHANDLE phCard,
LPDWORD pdwActiveProtocol);

Parameters:
hContext
A handle that identifies the resource manager context. This parameter value is ignored.
szReader
The name of the reader that contains the target card.
dwShareMode
A flag that indicates whether other applications may form connections to the card. This
parameter value is ignored and the function acts as SCARD_SHARE_SHARED value is
selected.
dwPreferredProtocols
A bitmask of acceptable protocols for the connection. Possible values may be combined with
the OR operation:
• SCARD_PROTOCOL_T0: T=0 is an acceptable protocol
• SCARD_PROTOCOL_T1: T=1 is an acceptable protocol
phCard
A handle that identifies the connection to the smart card in the designated reader.
pdwActiveProtocol
A flag that indicates the established active protocol.
Returned value:
SCardConnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.3 SCardDisconnect
The SCardDisconnect function terminates a connection previously opened between the calling
application and a smart card in the target reader.
Syntax:

LONG SCardDisconnect(
SCARDHANDLE hCard,
DWORD dwDisposition);
Parameters:
hCard
Reference value obtained from a previous call to SCardConnect.
dwDisposition
Action to take on the card in the connected reader on close. The parameter value is ignored.

Pagina 6/23
Returned value:
SCardDisconnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.4 SCardReconnect
The SCardReconnect function reestablishes an existing connection between the calling application
and a smart card.
Syntax:

LONG SCardReconnect(
SCARDHANDLE hCard,
DWORD dwShareMode,
DWORD dwPreferredProtocols,
DWORD dwInitialization,
LPDWORD pdwActiveProtocol);

Parameters:
hCard
Reference value obtained from a previous call to SCardConnect.
dwShareMode
Flag that indicates whether other applications may form connections to this card. The
parameter value is ignored.
dwPreferredProtocols
Bitmask of acceptable protocols for this connection. Possible values may be combined with
the OR operation. The value of this parameter should include the current protocol.
dwInitiliazation
Type of initialization that should be performed on the card. The parameter value is ignored.
pdwActiveProtocol
Flag that indicates the established active protocol.
Returned value:
SCardReconnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.5 SCardTransmit
The SCardTransmit function sends a service request to the smart card and expects to receive data
back from the card.
Syntax:
LONG SCardTransmit(
SCARDHANDLE hCard,
LPCSCARD_IO_REQUEST pioSendPci,
LPCBYTE pbSendBuffer,
DWORD cbSendLength,
LPSCARD_IO_REQUEST pioRecvPci,
LPBYTE pbRecvBuffer,
LPDWORD pcbRecvLength);

Parameters:

Pagina 7/23
hCard
A reference value returned from the SCardConnect function.
pioSendPci
A pointer to the protocol header structure for the instruction. This buffer is in the format of an
SCARD_IO_REQUEST structure, followed by the specific protocol control information
(PCI). The parameter value is ignored.
sendBuffer
A pointer to the actual data to be written to the card.
cbSendLength
The length, in bytes, of the pbSendBuffer parameter.
pioRecvPci
Pointer to the protocol header structure for the instruction, followed by a buffer in which to
receive any returned protocol control information (PCI) specific to the protocol in use. This
parameter is ignored.
recvBuffer
Pointer to any data returned from the card.
cbRecvLength
Supplies the length, in bytes, of the pbRecvBuffer parameter and receives the actual number of
bytes received from the smart card.
ReturnedValue:
SCardTransmit function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.6 SCardGetAttrib
The SCardGetAttrib function retrieves the current reader attributes for the given handle. It does not
affect the state of the reader, driver, or card.
Syntax:
LONG SCardGetAttrib(
SCARDHANDLE hCard,
DWORD dwAttrId,
LPBYTE pbAttr,
LPDWORD pcbAttrLen);

Parameters:
hCard
Reference value returned from SCardConnect.
dwAttrId
Identifier for the attribute to get. Only SCARD_ATTR_ATR_STRING value is supported.
pbAttr
Pointer to a buffer that receives the attribute whose ID is supplied in dwAttrId.
pcbAttrLen
Length of the pbAttr buffer in bytes, and receives the actual length of the received attribute.

ReturnedValue:

Pagina 8/23
SCardGetAttrib function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.7 SCardGetStatusChange
The SCardGetStatusChange function blocks execution until the current availability of the cards in
a specific set of readers changes. The caller supplies a list of readers to be monitored by an
SCARD_READERSTATE array and the maximum amount of time (in milliseconds) that it is
willing to wait for an action to occur on one of the listed readers. Note that SCardGetStatusChange
uses the user-supplied value in the dwCurrentState members of the rgReaderStates
SCARD_READERSTATE array as the definition of the current state of the readers. The function
returns when there is a change in availability, having filled in the dwEventState members of
rgReaderStates appropriately.
Syntax:
LONG SCardGetStatusChange(
SCARDCONTEXT hContext,
DWORD dwTimeout,
LPSCARD_READERSTATE rgReaderStates,
DWORD cReaders);

Parameters:
hContext
A handle that identifies the resource manager context. This parameter value is ignored.
dwTimeout
The maximum amount of time, in milliseconds, to wait for an action. The parameter value is
ignored and the function acts as the value always is zero returning immediately.
rgReaderStates
An array of SCARD_READERSTATE structures that specify the readers to watch, and that
receives the result. Each member of each structure in this array must be initialized to zero and
then set to specific values as necessary. If this is not done, the function will fail in situations
that involve remote card readers.
cReaders
The number of elements in the rgReaderStates array.

Returned value:
SCardGetStatusChange function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.1.8 SCardStatus
The SCardStatus function provides the current status of a smart card in a reader. You can call it any
time after a successful call to SCardConnect and before a successful call to SCardDisconnect. It
does not affect the state of the reader or reader driver.
Syntax:

Pagina 9/23
SCardStatus(
SCARDHANDLE hCard,
LPTSTR szReaderName,
LPDWORD pcchReaderLen,
LPDWORD pdwState,
LPDWORD pdwProtocol,
LPBYTE pbAtr,
LPDWORD pcbAtrLen);
Parameters:
hCard
Reference value returned from SCardConnect.
szReaderName
List of display names (multiple string) by which the currently connected reader is known.
pcchReaderLen
Receives the actual length (in characters) of the reader name list, including the trailing NULL
character.
pdwState
Current state of the smart card in the reader. Upon success, it receives one of the following
state indicators.
Value Meaning
SCARD_STATE_ABSENT There is no card in the reader.
SCARD_STATE_PRESENT There is a card in the reader.
SCARD_STATE_UNKNOWN The card status is not detectable.

pdwProtocol
Current protocol

Pagina 10/23
pbAt
r Pointer to a 32-byte buffer that receives the ATR string from the currently inserted card, if
available.
pcbAtrLen
Receives the number of bytes in the ATR string (32 bytes maximum).

Returned value:
SCardStatus function returns different value depending on whether it succeds or fails (see Paragraph
17 for a complete list of the error codes).

2.2 Android version


The Android PCSC is a Java library named winscardlibrary which is delivered as an AAR file. A JNI
wrapper is also available in order to use the library by C/C++ code.
The library provides a class named Winscard with the following public methods:
1. SCardListReaders
2. SCardConnect
3. SCardDisconnect
4. SCardReconnect
5. SCardTransmit
6. SCardGetAttrib
7. SCardGetStatusChange

Pagina 11/23
Intent deviceManagerIntent = new
Intent( MainActivity.this,
DeviceManagerActivity.class);
startActivityForResult(deviceManagerIntent,
Constant.CONFIGURATION_REQUEST_CODE);
8. SCardStatus.
The winscardlibrary provides a configuration view in order to allow users to choose the device to
use. The below image shows the configuration view.

Figure 5: Android configuration view

The configuration view allows the user to choose the type of device: USB miniLector Pocket, USB
miniLector EVO or Bluetooth miniLector Blue devices are supported, choose the top option for
miniLector Blue or bottom option for USB miniLector EVO and Pocket. If Bluetooth technology is
selected the System shows another view which allows the user to look for available miniLector Blue
devices and select the preferred one.
To show the configuration view client applications should istantiate a new intent passing as activity
the class DeviceManagerActivity. In the below box is listed a snippet of Swift code used for the
configuration view presentation.

2.2.1 SCardListReaders
The SCardListReaders function provides the list of readers eliminating duplicates. This function
only returns reader selected by the configuration view if it is currently attached to the system and
available for use. Reader groups are ignored and the method list all readers in the System, regardless
of what group or groups the readers are in.
Syntax:
public long Parameters:
SCardListReaders( SCardListRe SCardListReadersParams.hContext
adersParams params
) Handle that identifies the resource manager
context of the query. The parameter value is
public class SCardListReadersParams { ignored and the search for readers is not
limited to any context.
private Object hContext;
private ArrayList<String> mszGroups; SCardListReadersParams.mszGroups
private ArrayList<String> mszReaders;
private long pcchReaders; Names of the reader groups defined to the
system, as a multi-string. The parameter value
… is ignored and all readers are listed regardless
of what group or groups the readers are in.
}
SCardListReadersParams.mszReaders
Multi-string that lists the card readers. If this value is NULL, SCardListReaders ignores the
buffer length supplied in pcchReaders, writes the length of the buffer that would have been
returned if this parameter had not been NULL to pcchReaders, and returns a success code.
SCardListReadersParams.pcchReaders
Length of the mszReaders buffer in characters. This parameter receives the actual length of
the multi-string structure, including all trailing null characters. SCARD_AUTOALLOCATE
value is not supported.
Returned value:
ScardListReaders function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.2 SCardConnect
The SCardConnect function establishes a connection (using a specific resource manager context)
between the calling application and a smart card contained by a specific reader. If no card exists in
the specified reader, an error is returned.
Syntax:
public long SCardConnect(SCardConnectParams params) Parameters:
SCardConnectParams.hContext
public class SCardConnectParams {
private Object hContext; A handle that identifies the
private String szReader; resource manager context. This
private long dwShareMode;
private long dwPreferredProtocols; parameter value is ignored.
private int phCard; SCardConnectParams.szReader
private long pdwActiveProtocol;
The name of the reader that
… contains the target card.

SCardConnectParams.dwShareMode
A flag that indicates whether other applications may form connections to the card. This
parameter value is ignored and the function acts as SCARD_SHARE_SHARED value is
selected.
SCardConnectParams.dwPreferredProtocols
A bitmask of acceptable protocols for the connection. Possible values may be combined with
the OR operation:
• SCARD_PROTOCOL_T0: T=0 is an acceptable protocol
• SCARD_PROTOCOL_T1: T=1 is an acceptable protocol
SCardConnectParams.phCard
A handle that identifies the connection to the smart card in the designated reader.
SCardConnectParams.pdwActiveProtocol
A flag that indicates the established active protocol.
Returned value:
SCardConnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.3 ScardDisconnect
The SCardDisconnect function terminates a connection previously opened between the calling
application and a smart card in the target reader.
Syntax:
public long SCardDisconnect(SCardDisconnectParams params) Parameters:
SCardDisconnect.hCard
public class SCardDisconnectParams {
private int hCard; Reference value obtained
private long dwDisposition; from a previous call to
SCardConnect.

}
SCardDisconnect.dwDisposition
Action to take on the card in the connected reader on close. The parameter value is ignored.
Returned value:
SCardDisconnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.4 SCardReconnect
The SCardReconnect function reestablishes an existing connection between the calling application
and a smart card.
Syntax:
public long
SCardReconnect( SCardReconn Parameters:
ectParams params
) SCardReconnectParams.hCard
public class SCardReconnectParams { Reference value obtained from a previous call
private int hCard; to SCardConnect.
private long dwShareMode; SCardReconnectParams.dwShareMode
private long dwPreferredProtocols;
private long dwInitialization; Flag that indicates whether other applications
private long pdwActiveProtocol; may form connections to this card. The
parameter value is ignored.

SCardReconnectParams.dwPreferredProtocols
Bitmask of acceptable protocols for this connection. Possible values may be combined with
the OR operation. The value of this parameter should include the current protocol.
SCardReconnectParams.dwInitiliazation
Type of initialization that should be performed on the card. The parameter value is ignored.
SCardReconnectParams.pdwActiveProtocol
Flag that indicates the established active protocol.
Returned value:
SCardReconnect function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.5 SCardTransmit
The SCardTransmit function sends a service request to the smart card and expects to receive data
back from the card.
Syntax:
public long SCardTransmit( Parameters:
SCardTransmitParams params) SCardTransmitParams.hCard
public class SCardTransmitParams { A reference value returned from the SCardConnect
function.
private int hCard;
private Object pioSendPci; SCardTransmitParams. pioSendPci
private byte[] sendBuffer; A pointer to the protocol header structure for the
private long cbSendLength;
private Object pioRecvPci; instruction. This buffer is in the format of an
public byte[] recvBuffer; SCARD_IO_REQUEST structure, followed by the
public long cbRecvLength; specific protocol control information (PCI). The
parameter value is ignored.

SCardTransmitParams.sendBuffer
} A pointer to the actual data to be written to the card.
SCardTransmitParams.cbSendLength
The length, in bytes, of the pbSendBuffer parameter.
SCardTransmitParams.pioRecvPci
Pointer to the protocol header structure for the instruction, followed by a buffer in which to
receive any returned protocol control information (PCI) specific to the protocol in use. This
parameter is ignored.
SCardTransmitParams.recvBuffer
Pointer to any data returned from the card.
SCardTransmitParams.cbRecvLength
Supplies the length, in bytes, of the pbRecvBuffer parameter and receives the actual number
of bytes received from the smart card.
ReturnedValue:
SCardTransmit function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.6 SCardGetAttrib
The SCardGetAttrib function retrieves the current reader attributes for the given handle. It does not
affect the state of the reader, driver, or card.
Syntax:
public long Parameters:
SCardGetAttrib( SCardGetAtt SCardGetAttribParams.hCard
ribParams params
) Reference value returned from SCardConnect.
SCardGetAttribParams.dwAttrId
public class SCardGetAttribParams { Identifier for the attribute to get. Only
private int hCard; SCARD_ATTR_ATR_STRING value is supported.
private long dwAttrId; SCardGetAttribParams.pbAttr
private byte[] pbAttr; Pointer to a buffer that receives the attribute whose ID
private long pcbAttrLen; is supplied in dwAttrId.
SCardGetAttribParams.pcbAttrLen

Length of the pbAttr buffer in bytes, and receives the
} actual length of the received attribute.

ReturnedValue:
SCardGetAttrib function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.7 SCardGetStatusChange
The SCardGetStatusChange function blocks execution until the current availability of the cards in
a specific set of readers changes. The caller supplies a list of readers to be monitored by an
SCARD_READERSTATE array and the maximum amount of time (in milliseconds) that it is
willing to wait for an action to occur on one of the listed readers. Note that SCardGetStatusChange
uses the user-supplied value in the dwCurrentState members of the rgReaderStates
SCARD_READERSTATE array as the definition of the current state of the readers. The function
returns when there is a change in availability, having filled in the dwEventState members of
rgReaderStates appropriately.
Syntax:
public long Parameters:
SCardGetStatusChange( SCardGetSta SCardGetStatusChange.hContext
tusChangeParams params
) A handle that identifies the resource
manager context. This parameter value
public class SCardGetStatusChangeParams { is ignored.
SCardGetStatusChange.dwTimeout
private Object The maximum amount of time, in
hContext; private long milliseconds, to wait for an action.
dwTimeout;
The parameter value is ignored and the
private SCardReaderState[]
rgReaderStates; private long cReaders; function acts as the value always is
zero returning immediately.

}
SCardGetStatusChange.rgReaderStates
An array of SCARD_READERSTATE structures that specify the readers to watch, and that
receives the result. Each member of each structure in this array must be initialized to zero and
then set to specific values as necessary. If this is not done, the function will fail in situations
that involve remote card readers.
SCardGetStatusChange.cReaders
The number of elements in the rgReaderStates array.

Returned value:
SCardGetStatusChange function returns different value depending on whether it succeds or fails (see
Paragraph 17 for a complete list of the error codes).

2.2.8 SCardStatus
The SCardStatus function provides the current status of a smart card in a reader. You can call it any
time after a successful call to SCardConnect and before a successful call to SCardDisconnect. It
does not affect the state of the reader or reader driver.
Syntax:
public long Parameters:
SCardStatus( SCardStatus SCardStatusParams.hCard
Params params
) Reference value returned from SCardConnect.
SCardStatusParams.szReaderName
public class SCardStatusParams { List of display names (multiple string) by which
private int hCard; the currently connected reader is known.
private String szReaderName; SCardStatusParams.pcchReaderLen
private long pcchReaderLen; Receives the actual length (in characters) of the
private long pdwState; reader name list, including the trailing NULL
private long pdwProtocol;
private byte[] pbAtr; character.
private long pcbAtrLen; SCardStatusParams.pdwState
Current state of the smart card in the reader. Upon
… success, it receives one of the following state
indicators.
}

Value Meaning
SCARD_STATE_ABSENT There is no card in the reader.
SCARD_STATE_PRESENT There is a card in the reader.
SCARD_STATE_UNKNOWN The card status is not detectable.

SCardStatusParams.pdwProtocol
Current protocol
SCardStatusParams.pbAtr
Pointer to a 32-byte buffer that receives the ATR string from the currently inserted card, if
available.
SCardStatusParams.pcbAtrLen
Receives the number of bytes in the ATR string (32 bytes maximum).

Returned value:
SCardStatus function returns different value depending on whether it succeds or fails (see Paragraph
17 for a complete list of the error codes).

3 Appendix A – Error codes

Value Description
The client attempted a smart card operation in a
ERROR_BROKEN_PIPE
remote session, such as a client session running on
a terminal server, and the operating system in use
0x00000109
does not support smart card redirection.

SCARD_E_BAD_SEEK
An error occurred in setting the smart card file
object pointer.
0x80100029

SCARD_E_CANCELLED
The action was canceled by an SCardCancel
request.
0x80100002

SCARD_E_CANT_DISPOSE
The system could not dispose of the media in the
requested manner.
0x8010000E

SCARD_E_CARD_UNSUPPORTED
The smart card does not meet minimal
requirements for support.
0x8010001C

SCARD_E_CERTIFICATE_UNAVAILABLE
The requested certificate could not be obtained.
0x8010002D

SCARD_E_COMM_DATA_LOST
A communications error with the smart card has
been detected.
0x8010002F
SCARD_E_DIR_NOT_FOUND
The specified directory does not exist in the smart
card.
0x80100023

SCARD_E_DUPLICATE_READER
The reader driver did not produce a unique reader
name.
0x8010001B

SCARD_E_FILE_NOT_FOUND
The specified file does not exist in the smart card.
0x80100024

SCARD_E_ICC_CREATEORDER
The requested order of object creation is not
supported.
0x80100021

SCARD_E_ICC_INSTALLATION
No primary provider can be found for the smart
card.
0x80100020

SCARD_E_INSUFFICIENT_BUFFER
The data buffer for returned data is too small for
the returned data.
0x80100008

SCARD_E_INVALID_ATR
An ATR string obtained from the registry is not a
valid ATR string.
0x80100015

SCARD_E_INVALID_CHV
The supplied PIN is incorrect.
0x8010002A

SCARD_E_INVALID_HANDLE
The supplied handle was not valid.
0x80100003

SCARD_E_INVALID_PARAMETER
One or more of the supplied parameters could not
be properly interpreted.
0x80100004

SCARD_E_INVALID_TARGET
Registry startup information is missing or not
valid.
0x80100005

SCARD_E_INVALID_VALUE
One or more of the supplied parameter values
could not be properly interpreted.
0x80100011
SCARD_E_NO_ACCESS
Access is denied to the file.
0x80100027

SCARD_E_NO_DIR
The supplied path does not represent a smart card
directory.
0x80100025

SCARD_E_NO_FILE
The supplied path does not represent a smart card
file.
0x80100026

SCARD_E_NO_KEY_CONTAINER
The requested key container does not exist on the
smart card.
0x80100030

SCARD_E_NO_MEMORY
Not enough memory available to complete this
command.
0x80100006

The smart card PIN cannot be cached.


SCARD_E_NO_PIN_CACHE
Windows Server 2008, Windows Vista,
0x80100033 Windows Server 2003 and Windows XP: This
error code is not available.

SCARD_E_NO_READERS_AVAILABLE
No smart card reader is available.
0x8010002E

SCARD_E_NO_SERVICE
The smart card resource manager is not running.
0x8010001D

SCARD_E_NO_SMARTCARD
The operation requires a smart card, but no smart
card is currently in the device.
0x8010000C

SCARD_E_NO_SUCH_CERTIFICATE
The requested certificate does not exist.
0x8010002C

SCARD_E_NOT_READY
The reader or card is not ready to accept
commands.
0x80100010

An attempt was made to end a nonexistent


SCARD_E_NOT_TRANSACTED
transaction.
0x80100016

SCARD_E_PCI_TOO_SMALL
The PCI receive buffer was too small.
0x80100019

The smart card PIN cache has expired.


SCARD_E_PIN_CACHE_EXPIRED
Windows Server 2008, Windows Vista,
0x80100032 Windows Server 2003 and Windows XP: This
error code is not available.

SCARD_E_PROTO_MISMATCH
The requested protocols are incompatible with the
protocol currently in use with the card.
0x8010000F

The smart card is read-only and cannot be written


to.
SCARD_E_READ_ONLY_CARD
Windows Server 2008, Windows Vista,
0x80100034
Windows Server 2003 and Windows XP: This
error code is not available.

SCARD_E_READER_UNAVAILABLE
The specified reader is not currently available for
use.
0x80100017

SCARD_E_READER_UNSUPPORTED
The reader driver does not meet minimal
requirements for support.
0x8010001A

SCARD_E_SERVER_TOO_BUSY
The smart card resource manager is too busy to
complete this operation.
0x80100031

SCARD_E_SERVICE_STOPPED
The smart card resource manager has shut down.
0x8010001E

SCARD_E_SHARING_VIOLATION
The smart card cannot be accessed because of
other outstanding connections.
0x8010000B

SCARD_E_SYSTEM_CANCELLED
The action was canceled by the system,
presumably to log off or shut down.
0x80100012

SCARD_E_TIMEOUT The user-specified time-out value has expired.


0x8010000A

SCARD_E_UNEXPECTED
An unexpected card error has occurred.
0x8010001F

SCARD_E_UNKNOWN_CARD
The specified smart card name is not recognized.
0x8010000D

SCARD_E_UNKNOWN_READER
The specified reader name is not recognized.
0x80100009

SCARD_E_UNKNOWN_RES_MNG
An unrecognized error code was returned.
0x8010002B

SCARD_E_UNSUPPORTED_FEATURE
This smart card does not support the requested
feature.
0x80100022

SCARD_E_WRITE_TOO_MANY
An attempt was made to write more data than
would fit in the target object.
0x80100028

SCARD_F_COMM_ERROR
An internal communications error has been
detected.
0x80100013

SCARD_F_INTERNAL_ERROR
An internal consistency check failed.
0x80100001

SCARD_F_UNKNOWN_ERROR
An internal error has been detected, but the source
is unknown.
0x80100014

SCARD_F_WAITED_TOO_LONG
An internal consistency timer has expired.
0x80100007

SCARD_P_SHUTDOWN
The operation has been aborted to allow the server
application to exit.
0x80100018

SCARD_S_SUCCESS No error was encountered.


SCARD_W_CANCELLED_BY_USER
The action was canceled by the user.
0x8010006E

SCARD_W_CACHE_ITEM_NOT_FOUND
The requested item could not be found in the
cache.
0x80100070

SCARD_W_CACHE_ITEM_STALE
The requested cache item is too old and was
deleted from the cache.
0x80100071

SCARD_W_CACHE_ITEM_TOO_BIG
The new cache item exceeds the maximum per-
item size defined for the cache.
0x80100072

SCARD_W_CARD_NOT_AUTHENTICATE
D
No PIN was presented to the smart card.
0x8010006F

SCARD_W_CHV_BLOCKED The card cannot be accessed because the


maximum number of PIN entry attempts has been
0x8010006C reached.

SCARD_W_EOF
The end of the smart card file has been reached.
0x8010006D

SCARD_W_REMOVED_CARD
The smart card has been removed, so further
communication is not possible.
0x80100069

SCARD_W_RESET_CARD
The smart card was reset.
0x80100068

SCARD_W_SECURITY_VIOLATION
Access was denied because of a security violation.
0x8010006A

SCARD_W_UNPOWERED_CARD
Power has been removed from the smart card, so
that further communication is not possible.
0x80100067

SCARD_W_UNRESPONSIVE_CARD
The smart card is not responding to a reset.
0x80100066
SCARD_W_UNSUPPORTED_CARD
The reader cannot communicate with the card, due
to ATR string configuration conflicts.
0x80100065

SCARD_W_WRONG_CHV
The card cannot be accessed because the wrong
PIN was presented.
0x8010006B

You might also like