Skip to content

licpcsc pcscd communication

jsorg71 edited this page Aug 26, 2022 · 12 revisions

libpcsc pcscd communication

1.0 Connection sequence

When an application is started that uses the lipcsc library, the connection sequence is started to connect the application to pcscd. Here is the connection sequence.

libpcsc pcscd
CMD_VERSION with header >> CMD_VERSION with header
CMD_VERSION << CMD_VERSION

1.1 Message Header The header is attached before all messages going from libpcsc to pcscd. The header includes.

type description
UINT32 Size - Message bytes
UINT32 Command - Message command see 1.3

1.2 Environment variables

The environment variable PCSCLITE_CSOCK_NAME is used to tell the pcsc library what unix domain socket to connect to.

example export PCSCLITE_CSOCK_NAME=/tmp/pcsc_test pcsc_scan

The will cause pcsc_scan to try to connect to /tmp/pcsc_test through the libpcsclite library.

1.3 List of commands

command hex source
SCARD_ESTABLISH_CONTEXT 0x01 SCardEstablishContext()
SCARD_RELEASE_CONTEXT 0x02 SCardReleaseContext()
SCARD_LIST_READERS 0x03 SCardListReaders()
SCARD_CONNECT 0x04 SCardConnect()
SCARD_RECONNECT 0x05 SCardReconnect()
SCARD_DISCONNECT 0x06 SCardDisconnect()
SCARD_BEGIN_TRANSACTION 0x07 SCardBeginTransaction()
SCARD_END_TRANSACTION 0x08 SCardEndTransaction()
SCARD_TRANSMIT 0x09 SCardTransmit()
SCARD_CONTROL 0x0A SCardControl()
SCARD_STATUS 0x0B SCardStatus()
SCARD_GET_STATUS_CHANGE 0x0C Not used
SCARD_CANCEL 0x0D SCardCancel()
SCARD_CANCEL_TRANSACTION 0x0E Not used
SCARD_GET_ATTRIB 0x0F SCardGetAttrib()
SCARD_SET_ATTRIB 0x10
CMD_VERSION 0x11
CMD_GET_READERS_STATE 0x12
CMD_WAIT_READER_STATE_CHANGE 0x13
CMD_STOP_WAITING_READER_STATE_CHANGE 0x14

CMD_VERSION

name size
major UINT32
minor UINT32
Clone this wiki locally