Host Interfaces Serial CCID (PCSC)
April 13, 2023 at 2:39 AMCCID (PC/SC) over Serial
Overview
SpringCard USB-enabled devices running in PC/SC Mode implement the USB CCID specification. For convenience and efficiency, most SpringCard non-USB couplers also implement the CCID protocol on top of whatever communication interface they feature. This is known as “PC/SC-like” operation.
This chapter details the implementation of CCID over the Serial interface of a SpringCore device.
CCID protocol over Serial
Every message starts with a constant START mark (CD byte), followed by the Endpoint number (copied from USB), then the CCID Header and Payload. A 1-byte LRC terminates the message.
| Byte | Name | Description |
|---|---|---|
| 0 | START mark | Constant value CD (in hex) |
| 1 | Endpoint | |
| 2-11 | CCID header | Always present |
| 12-N | CCID payload | Absent if not payload |
| N+1 | LRC | XOR of bytes 1-N (all the preceding bytes, expect the START byte) |
Values for the Endpoint byte
| Value | Endpoint | Purpose | Protocol |
|---|---|---|---|
00 |
ControlOut | Control endpoint, PC to RDR | See Non-USB Control |
80 |
ControlIn | Control endpoint, RDR to PC | See Non-USB Control |
02 |
BulkOut | PC to RDR commands | CCID_PC_To_RDR, see CCID protocol |
81 |
BulkIn | RDR to PC responses | CCID_RDR_To_PC, see CCID protocol |
83 |
InterruptIn | RDR to PC notification of card(s) insertion/removal | CCID_Interrupts, see CCID protocol |
Format of the CCID header
The format conforms to the CCID specification for BulkOut and BulkIn endpoints. For the other endpoints, the format is exactly the same (hence not conform).
| Byte | Name | Description |
|---|---|---|
| 2 | Message type | Command or response opcode. See tables in the CCID protocol chapter. |
| 3-6 | Length of payload | DWORD, LSB-first |
| 7-11 | Parameters | BulkOut/BulkIn endpoints: slot number and sequence number followed by 3 bytes of context-specific parameters or error/status Other endpoints: free |
Supported length
- The shortest messages are 13-byte long (length=0, no payload),
- BulkOut/BulkIn endpoints support 64kB of payload, i.e. messages up to 65549 bytes (max length is
0001000in hex), - Other endpoints are limited to 256B of payload, i.e. messages up to 269 bytes (max length is
00000100in hex).