Host Protocols CCID Protocol (PCSC) Non-USB Control
April 13, 2023 at 2:39 AMNon-USB Control
Since Serial and Network (TCP) interfaces don’t intrinsicly provide an equivalent of the USB Control endpoint (that is required to detect, recognize and activate the device), the non-USB variants of the CCID protocol must emulate this missing feature.
This is done using pseudo-endpoints ControlOut (00) for PC to RDR commands, and ControlIn (80) for RDR to PC responses. The command/responses described in this paragraph are proprietary, yet inspired for the largest part by the USB core specifications.
List of opcodes
The same opcode is used for a command and the corresponding response.
| Opcode | Name | Role |
|---|---|---|
00 |
GET STATUS | Check that the device is up and running, report an error |
06 |
GET DESCRIPTOR | Identify the device and its features |
09 |
SET CONFIGURATION | Start (or stop) the CCID engine in the device |
GET STATUS
Command
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 00 |
ControlOut |
| 1 | Message type | 00 |
GET STATUS |
| 2-5 | Length of payload | 00000000 |
No payload |
| 6-10 | 0000000000 |
Not used |
Response
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 80 |
ControlIn |
| 1 | Message type | 00 |
GET STATUS |
| 2-5 | Length of payload | 00000000 |
No payload |
| 6-9 | 00000000 |
Not used | |
| 10 | xx |
STATUS byte |
Value of the STATUS byte in GET STATUS response
| Value | Description | Possible cause |
|---|---|---|
00 |
OK | |
01 |
Control error | Unsupported command on ControlOut endpoint |
FC |
Overrun | The host sends a BulkOut command while another BulkOut command is already pending |
FD |
Denied | Device must be activated before sending a BulkOut command (see SET CONFIGURATION below) |
FE |
Overflow | The BulkOut message is too big for the device’s buffer |
FF |
Protocol error | Invalid endpoint or invalid frame format |
GET DESCRIPTOR
Command
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 00 |
ControlOut |
| 1 | Message type | 06 |
GET DESCRIPTOR |
| 2-5 | Length of payload | 00000000 |
No payload |
| 6 | Descriptor type | xx |
Same as ‘Value_L’ in USB spec. |
| 7 | Descriptor index | xx |
Same as ‘Value_H’ in USB spec. |
| 8-10 | 000000 |
Not used |
Response
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 80 |
ControlIn |
| 1 | Message type | 06 |
GET DESCRIPTOR |
| 2-5 | Length of payload | xxxxxxxx |
|
| 6 | Descriptor type | xx |
Echo of the value received in the command |
| 7 | Descriptor index | xx |
Echo of the value received in the command |
| 8-10 | 000000 |
Not used | |
| 11-N | Descriptor value | xx...xx |
Raw structure or UTF16 string depending on the descriptor |
List of available descriptors
| Type / Value_L | Index / Value_H | Response’s payload | Remark |
|---|---|---|---|
01 |
00 |
Device descriptor | Same as USB Device descriptor. See below for details. |
02 |
00 |
Configuration descriptor | Same as USB Configuration descriptor. See below for details. |
03 |
01 |
Vendor Name | UTF16 string, namely SpringCard |
03 |
02 |
Product Name | UTF16 string |
03 |
03 |
Serial Number | UTF16 string, length is either 8 or 12 characters (4 or 6 bytes expressed in hex) depending on manufacturing options |
03 |
04 |
Configuration Name | UTF16 string, namely CCID |
Device descriptor
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Size | 12 |
Length of device descriptor is 18 bytes |
| 1 | Type | 01 |
This is a device descriptor |
| 2-3 | USB version | 0200 |
Don’t care |
| 4 | Class | 00 |
Class is specified in the interface descriptor |
| 5 | SubClass | 00 |
No subclass specified |
| 6 | Protocol | 00 |
No protocol specified |
| 7 | MaxPacketSize0 | xx |
Don’t care |
| 8-9 | Vendor Id | 1C34 |
Identifier of the manufacturer (SPRINGCARD, formerly PRO ACTIVE) |
| 10-11 | Product Id | xxxx |
Identifier of the device |
| 12-13 | Version | xxxx |
Firmware version |
| 14 | Index of Vendor Name | 01 |
Index of the Vendor Name string descriptor |
| 15 | Index of Product Name | 02 |
Index of the Product Name string descriptor |
| 16 | Index of Serial Number | 03 |
Index of the Serial Number string descriptor |
| 17 | Configurations | 01 |
Only one configuration supported |
Configuration descriptor
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Size | 09 |
Length of configuration descriptor is 9 bytes |
| 1 | Type | 02 |
This is a configuration descriptor |
| 2-4 | Total size | 005D |
Total length of all the descriptors is 93 bytes |
| 4 | Interfaces | 01 |
Only one interface |
| 5 | Configuration | 01 |
This is the first (and single) configuration |
| 6 | Index of Configuration Name | 04 |
Index of the Configuration Name string descriptor |
| 7 | Attributes | xx |
Don’t care |
| 8 | Max Power | xx |
Don’t care |
| 9 | Size | 09 |
Length of interface descriptor is 9 bytes |
| 10 | Type | 04 |
This is an interface descriptor |
| 11 | Interface | 00 |
Interface number = 0 |
| 12 | Alternate settings | 00 |
Don’t care |
| 13 | Endpoints | 03 |
3 endpoints |
| 14 | Class | 0B |
CCID class |
| 15 | SubClass | 00 |
No subclass specified |
| 16 | Protocol | 00 |
No protocol specified |
| 17 | Index of Interface Name | 00 |
No string provided |
| 18 | Size | 36 |
Length of CCID descriptor |
| 19 | Type | 21 |
Specific to CCID |
| 20-21 | Version | 0110 |
Only version of CCID specification is 1.10 |
| 22 | MaxSlotIndex | xx |
The number of CCID slots, minus 1 (03 means 4 slots!) |
| 23 | VoltageSupport | 07 |
5V, 3V and 1.8V (makes no sense for a contactless coupler) |
| 24-27 | Protocols | 00000003 |
Support T=0 and T=1 |
| 28-31 | DefaultClock | 00000FA0 |
Default clock is 4MHz (makes no sense for a contactless coupler) |
| 32-35 | MaximumClock | 00000FA0 |
Maximum clock is 4MHz (makes no sense for a contactless coupler) |
| 36 | NumClockSupported | 00 |
Clock frequency is managed by the device |
| 37-40 | DataRate | 00002A00 |
Default bitrate is 10752bps (makes no sense for a contactless coupler) |
| 41-44 | MaxDataRate | 00030D90 |
Max bitrate is 250kbps (makes no sense for a contactless coupler) |
| 45 | NumDataRateSupported | 00 |
Bitrate is managed by the device |
| 46-49 | MaxIFSD | 000000FE |
T=1 max block size is 254 |
| 50-53 | SynchProtocols | 00000000 |
Synchronous cards are not supported |
| 54-57 | Mechanical | 00000000 |
No motor/no special hardware |
| 58-61 | Features | 0004047E |
- short and extended APDU exchange - automatic IFSD exchange - automatic bitrate change (self determined) - automatic clock frequency change (self determined) - automatic PPS (proprietary algorithm) - automatic voltage selection - automatic activation on insertion - automatic parameter configuration based on ATR |
| 62-65 | MaxMessageLength | 00010012 |
65554 bytes (64kB for payload + 10B for data + endpoint) |
| 66 | ClassGetResponse | FF |
GET RESPONSE uses the same CLAss as preceding APDU |
| 67 | ClassEnvelope | FF |
|
| 68-69 | LCDLayout | 0000 |
No LCD |
| 70 | PinSupport | 00 |
No pinpad |
| 71 | MaxBusySlot | 01 |
Device can only process one command at a time |
| 72 | Size | 07 |
Length of endpoint descriptor is 7 bytes |
| 73 | Type | 05 |
This is an endpoint descriptor |
| 74 | Address | 81 |
1st endpoint is RDR to PC (BulkIn) at index 1 |
| 75 | Attributes | 02 |
Bulk |
| 76-77 | MaxPacketSize | xxxx |
Don’t care (value for USB only; Serial and TCP have a direct access to the 64kB buffer) |
| 78 | Interval | 00 |
Don’t care |
| 79 | Size | 07 |
Length of endpoint descriptor is 7 bytes |
| 80 | Type | 05 |
This is an endpoint descriptor |
| 81 | Address | 02 |
2nd endpoint is PC to RDR (BulkOut) at index 2 |
| 82 | Attributes | 02 |
Bulk |
| 83-84 | MaxPacketSize | xxxx |
Don’t care (value for USB only; Serial and TCP have a direct access to the 64kB buffer) |
| 85 | Interval | 00 |
Don’t care |
| 86 | Size | 07 |
Length of endpoint descriptor is 7 bytes |
| 87 | Type | 05 |
This is an endpoint descriptor |
| 88-89 | Address | 83 |
3rd endpoint is RDR to PC (InterruptIn) at index 3 |
| 90 | Attributes | 03 |
Interrupt |
| 91 | MaxPacketSize | 0010 |
Device will never send more than 16 bytes on InterruptIn |
| 92 | Interval | 00 |
Don’t care |
NB: the MaxSlotIndex field (in bold) must be read and handled by the host application.
SET CONFIGURATION
Command
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 00 |
ControlOut |
| 1 | Message type | 09 |
SET CONFIGURATION |
| 2-5 | Length of payload | 00000000 |
No payload |
| 6 | 00 |
Not used | |
| 7 | Start / stop CCID | 0001 |
Stop the coupler Start the coupler |
| 8-9 | 0000 |
Not used | |
| 10 | Option | xx |
See below |
Value for the Option byte
The Option byte is an array of flags:
| Bit | Description | Remark |
|---|---|---|
| 7 | RFU | Must be 0 |
| 6 | RFU | Must be 0 |
| 5 | RFU | Must be 0 |
| 4 | Power saving | 0: no power saving1: use LPCD (low power card detect) or alike power saving method to limit device’s power requirement |
| 3 | RFU | Must be 0 |
| 2 | RFU | Must be 0 |
| 1 | Use /WAKEUP | 0: do not use /WAKEUP1: use /WAKEUP (the device asserts this output line when a card is inserted or removed; therefore the host does not have to poll PC_To_RDR_GetSlotStatus too often) |
| 0 | Use InterruptIn endpoint | 0: do not use InterruptIn endpoint (host SHALL poll using PC_To_RDR_GetSlotStatus to know when a card is inserted or removed)1: use InterruptIn endpoint (a [RDR_to_PC_Notification](Non-USB Notifications) is sent when a card is inserted or removed) |
Note: the InterruptIn endpoint SHALL NOT be activated on a RS-485 medium because the [RDR_to_PC_Notification](Non-USB Notifications) may collide with a PC_to_RDR command.
Values of Option byte - Network (TCP) interface
Response
| Byte | Field | Value | Description / Remark |
|---|---|---|---|
| 0 | Endpoint | 80 |
ControlIn |
| 1 | Message type | 09 |
SET CONFIGURATION |
| 2-5 | Length of payload | xxxxxxxx |
|
| 6 | 00 |
Not used | |
| 7 | CCID running? | xx |
Echo of the value received in the command |
| 8-9 | 0000 |
Not used | |
| 10 | CCID option | Echo of the value received in the command |