CCID接口规范

控制通道(Control pipe)
GET_DESCRIPTOR 和 SET_CONFIGURATION 等标准请求 通过此通道发送。

命令在默认通道上发动,报告信息也在默认通道上返还给主机。
———————–
中断通道处理异步事件
NotifySlotChange (卡插入,移除)
HardwareError (硬件错误)
————————
Bulk-in, Bulk-out通道

CCID命令在BULK_OUT端点 发送
每个命令都会有一个响应。有些响应可以立即得到。
有些响应 需要通过 BULK-IN 端口返回。

发送给指定卡槽的所有命令,都必须是同步发送的。
一个卡槽同一时刻,只能接受一个命令。
如果一个卡槽准备接受一个命令,那么就应该认为它是空闲的。

如果每条命令 都是给不同的空闲卡槽的,那么主机最多可以同时发送 bMaxCCIDBusySlots 条命令给 CCID
主机需要记住哪些slot是繁忙的。
当激活的卡槽数量达到 bMaxCCIDBusySlots时, CCID只能在 控制通道,接受 通用请求 或者 特定类的请求,去 ABORT一个slot

当CCID成功接收到一条给 繁忙卡槽的命令时,它应该报一个 CMD_SLOT_BUSY 错误

为了实现对每条命令的跟踪,主机对 发出的命令,设置一个 唯一的 bSeq 命令标识符。
CCID发回响应时,也要带上同样的 bSeq 标识符,表明 这条命令已经处理完毕。
驱动程序不会发送新的命令给 slot, 直到前面发送命令的 ending response响应被收到。
如果命令有错误或者超时, 那么 会发送 abandon/abort 类特定的命令 给 控制端点。

对于一个 BULK-OUT 命令 消息,可能会产生多个 BULK-IN 响应消息。
For example, the CCID can send a BULK-IN message with a Time Extension status to notify
the host that the ICC has requested more time to process the ICC command and, after a
delay, follow this with a second BULK-IN message with the ICC’s response to the
command. When this happens, both BULK-IN messages have the same bSeq value.

如果Bulk-In 消息的大小 是 MaxPacketSize 的倍数,那么应该在它后面还发一个 Zero Length Packet (ZLP)
ZLP包可以让 CCID设备驱动更有效率, 是一种最佳实践。

———————————————
CCID 发送 RDR_to_PC_NotifySlotChange 到主机, 通知驱动程序, 新插入了卡
收到驱动来的 PC_to_RDR_IccPowerOn 消息, CCID重新激活 IC卡

PC_to_RDR_IccPowerOn         RDR_to_PC_DataBlock
PC_to_RDR_IccPowerOff        RDR_to_PC_SlotStatus
PC_to_RDR_GetSlotStatus      RDR_to_PC_SlotStatus
PC_to_RDR_XfrBlock           RDR_to_PC_DataBlock
PC_to_RDR_GetParameters      RDR_to_PC_Parameters
PC_to_RDR_ResetParameters    RDR_to_PC_Parameters
PC_to_RDR_SetParameters      RDR_to_PC_Parameters
PC_to_RDR_Escape             RDR_to_PC_Escape
PC_to_RDR_IccClock           RDR_to_PC_SlotStatus
PC_to_RDR_T0APDU             RDR_to_PC_SlotStatus
PC_to_RDR_Secure             RDR_to_PC_DataBlock
PC_to_RDR_Mechanical         RDR_to_PC_SlotStatus
PC_to_RDR_Abort              RDR_to_PC_SlotStatus
PC_to_RDR_SetDataRateAndClockFrequency              RDR_to_PC_DataRateAndClockFrequency

CCID_PC_To_RDR Commands

CodeCommandDescriptionEquivalent PC/SC function
62PC_To_RDR_IccPowerOnPower up the card in the slot, and return its ATRSCardConnect
63PC_To_RDR_IccPowerOffPower down the card in the slotSCardDisconnect
65PC_To_RDR_GetSlotStatusRetrieve the slot’s current status and protocol dataSCardStatus
6BPC_To_RDR_EscapeSend a direct command to the deviceSCardControl
6FPC_To_RDR_XfrBlockSend a C-APDU to the card (and return its R-APDU)SCardTransmit

CCID_RDR_To_PC Responses

CodeCommandDescriptionIn response to
80RDR_To_PC_DataBlockR-APDU returned by the card
ATR of the card
PC_To_RDR_XfrBlock (success)
PC_To_RDR_IccPowerOn (success)
81RDR_To_PC_SlotStatusStatus of the slotPC_To_RDR_GetSlotStatus
PC_To_RDR_IccPowerOff
PC_To_RDR_XfrBlock (failure)
PC_To_RDR_IccPowerOn (failure)
83RDR_To_PC_EscapeSend a direct command to the devicePC_To_RDR_Escape

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注