USB 智能卡 class 规范中的字符级交换
character level exchang in USB smart card class specification
USB:智能卡class标准有3级交换,包括1:APDU2级:TPDU 3级:字符级。这些级别之间有什么区别?另外,character level
是什么意思?
抱歉我的英文写得不好。
规范中定义的正式控制较少,因为从 TPDU 到 APDU 的级别上升到 3 级字符级别交换。
根据规范,3.2.3:
Character level of exchanges is selected when none of the TPDU, Short APDU or Short and extended APDU is selected.
The CCID sends the characters in the command (maybe none) then waits for the number of characters (if not null) indicated in the command.
For character level exchange between the host and the CCID, the CCID supports asynchronous characters communication with the ICC as per ISO 7816-3 § 6.3 including
Page 14 of 123 CCID Rev 1.1
DWG Smart-Card Integrated Circuit(s) Card Interface Devices
timings defined in ISO/IEC 7816-3 § 8.2 for T = 0 and in ISO 7816-3 § 9.3 for T = 1. To respect timing the CCID shall use the defined parameters.
The CCID implements the character frame and character repetition procedure when T = 0 is selected.
这是定义交换性质的全部内容:
3.2 Protocolandparametersselection
A CCID announces in dwFeatures Table 5.1-1 one level of exchanges with the host, TPDU, APDU (Short and Extended), or Character.
TPDU 是第一个指定的交换,APDU 是第二个。
3.2.1 TPDU level of exchange
For TPDU level exchanges, the CCID provides the transportation of host’s TPDU to the ICC’s TPDU. The TPDU format changes according to the protocol or for PPS exchange.
TPDU for PPS exchange has the following format:
Command TPDU:
FF PPS0 PPS1 PPS2 PPS3 PCK, with PPS1, PPS2, PPS3 optional [ISO/IEC7816-3 §7].
Response TPDU:
FF PPS0_R PPS1_R PPS2_R PPS3_R PCK_R, with PPS1_R, PPS2_R, PPS3_R optional [ISO/IEC7816-3 §7.4).
The CCID implements and verifies timings and protocol according to its parameters settings to assume ISO/IEC 7816-3 §7.1, §7.2. No check on frame format is mandatory on request, and on response the only recommended analysis is the most significant nibble of PPS0_R to compute the number of bytes left to receive.
A CCID that implements automatic PPS should not accept TPDU for PPS exchange and must check for PPS response validity.
T = 0 TPDU can have three formats [ISO/IEC 7816-3, § 8.3.2]:
- Form 1, no data to exchange with ICC, only header:
Command TPDU = CLA INS P1 P2, the CCID is responsible to add P3=00h. Response TPDU = SW1 SW2
- Form 2, data expected from ICC:
Command TPDU = CLA INS P1 P2 Le, Le=P3 from 00h to FFh (00h means 100h)
Response TPDU = Data(Le) SW1 SW2, Data(Le) is for the Le data received from the ICC or empty if ICC rejects the command.
- Form 3, data are to be sent to the ICC:
Command TPDU = CLA INS P1 P2 Lc Data(Lc), Lc=P3 from 01h to FFh and Data(Lc) for the Lc data to send to the ICC.
Response TPDU = SW1 SW2
The CCID, for T=0 TPDU, is in charge of managing procedure bytes (ISO 7816-3 § 8.3.3) and character level [ISO]IEC 7816-3 § 8.2].
The procedure bytes are not mapped into the response TPDU except for the SW1 SW2 bytes. The CCID implements and verifies timings according to its
CCID Rev 1.1 Page 13 of 123
DWG Smart-Card Integrated Circuit(s) Card Interface Devices
parameters settings to assume ISO/IEC 7816-3 § 8.2 (work waiting time, extra guard time, ...). If ICC uses NULL procedure byte (60h) the CCID informs the host of this request for time extension.
T = 1 TPDU command and response use the frame format [ISO/IEC 7816-3 § 9.4]. The CCID expects the respect of the character frame [ISO/IEC 7816-3 § 9.4.1]. But no check on frame format is mandatory on sending, and on receiving. The only recommended checks are:
- Expecting LEN byte as third byte
- Wait for LEN bytes as INF field.
- Wait for an EDC field which length complies with parameter bmTCCKST1 (see § 6.1.7).
The CCID implements and verifies timing according to its parameters settings to assume ISO/IEC 7816-3 § 9.5.3 (CWT, BWT, BGT, ...).
The detection of parity error on character received is optional. The interpretation of first bytes received as NAD and PCB to manage VPP is optional and depends on CCID capabilities.
3.2.2 APDU level of exchange
For APDU level exchanges, the CCID provides the transportation of host’s APDU to ICC’s TPDU.
APDU commands and responses are defined in ISO 7816-4.
Two APDU levels are defined, short APDU and extended APDU. Short APDU and extended APDU are defined in ISO/IEC 7816-4 § 5.3.2.
A CCID that indicates a short APDU exchange only accepts short APDU. A CCID that indicates an extended APDU exchange accepts both short APDU and extended APDU.
If the ICC requests time extension, by using a NULL procedure byte (60h) in T=0 protocol or S(WTX) in T=1 protocol, the CCID informs the host of this request.
A CCID supporting APDU level of exchanges implements a high level of automatism in ICC communications. It shall also provide a high level of automatism in ATR treatment and implement one of the following automatisms: automatic parameters negotiation (proprietary algorithm), or automatic PPS according to the current parameters. At least two standards of transportation for APDU are defined, ISO/IEC 7816-4 and EMV 3.1.1, which standard to implement is out of the scope of this specification.
USB:智能卡class标准有3级交换,包括1:APDU2级:TPDU 3级:字符级。这些级别之间有什么区别?另外,character level
是什么意思?
抱歉我的英文写得不好。
规范中定义的正式控制较少,因为从 TPDU 到 APDU 的级别上升到 3 级字符级别交换。
根据规范,3.2.3:
Character level of exchanges is selected when none of the TPDU, Short APDU or Short and extended APDU is selected. The CCID sends the characters in the command (maybe none) then waits for the number of characters (if not null) indicated in the command. For character level exchange between the host and the CCID, the CCID supports asynchronous characters communication with the ICC as per ISO 7816-3 § 6.3 including Page 14 of 123 CCID Rev 1.1 DWG Smart-Card Integrated Circuit(s) Card Interface Devices timings defined in ISO/IEC 7816-3 § 8.2 for T = 0 and in ISO 7816-3 § 9.3 for T = 1. To respect timing the CCID shall use the defined parameters. The CCID implements the character frame and character repetition procedure when T = 0 is selected.
这是定义交换性质的全部内容:
3.2 Protocolandparametersselection A CCID announces in dwFeatures Table 5.1-1 one level of exchanges with the host, TPDU, APDU (Short and Extended), or Character.
TPDU 是第一个指定的交换,APDU 是第二个。
3.2.1 TPDU level of exchange For TPDU level exchanges, the CCID provides the transportation of host’s TPDU to the ICC’s TPDU. The TPDU format changes according to the protocol or for PPS exchange. TPDU for PPS exchange has the following format: Command TPDU: FF PPS0 PPS1 PPS2 PPS3 PCK, with PPS1, PPS2, PPS3 optional [ISO/IEC7816-3 §7]. Response TPDU: FF PPS0_R PPS1_R PPS2_R PPS3_R PCK_R, with PPS1_R, PPS2_R, PPS3_R optional [ISO/IEC7816-3 §7.4). The CCID implements and verifies timings and protocol according to its parameters settings to assume ISO/IEC 7816-3 §7.1, §7.2. No check on frame format is mandatory on request, and on response the only recommended analysis is the most significant nibble of PPS0_R to compute the number of bytes left to receive. A CCID that implements automatic PPS should not accept TPDU for PPS exchange and must check for PPS response validity. T = 0 TPDU can have three formats [ISO/IEC 7816-3, § 8.3.2]: - Form 1, no data to exchange with ICC, only header: Command TPDU = CLA INS P1 P2, the CCID is responsible to add P3=00h. Response TPDU = SW1 SW2 - Form 2, data expected from ICC: Command TPDU = CLA INS P1 P2 Le, Le=P3 from 00h to FFh (00h means 100h) Response TPDU = Data(Le) SW1 SW2, Data(Le) is for the Le data received from the ICC or empty if ICC rejects the command. - Form 3, data are to be sent to the ICC: Command TPDU = CLA INS P1 P2 Lc Data(Lc), Lc=P3 from 01h to FFh and Data(Lc) for the Lc data to send to the ICC. Response TPDU = SW1 SW2 The CCID, for T=0 TPDU, is in charge of managing procedure bytes (ISO 7816-3 § 8.3.3) and character level [ISO]IEC 7816-3 § 8.2]. The procedure bytes are not mapped into the response TPDU except for the SW1 SW2 bytes. The CCID implements and verifies timings according to its CCID Rev 1.1 Page 13 of 123 DWG Smart-Card Integrated Circuit(s) Card Interface Devices parameters settings to assume ISO/IEC 7816-3 § 8.2 (work waiting time, extra guard time, ...). If ICC uses NULL procedure byte (60h) the CCID informs the host of this request for time extension. T = 1 TPDU command and response use the frame format [ISO/IEC 7816-3 § 9.4]. The CCID expects the respect of the character frame [ISO/IEC 7816-3 § 9.4.1]. But no check on frame format is mandatory on sending, and on receiving. The only recommended checks are: - Expecting LEN byte as third byte - Wait for LEN bytes as INF field. - Wait for an EDC field which length complies with parameter bmTCCKST1 (see § 6.1.7). The CCID implements and verifies timing according to its parameters settings to assume ISO/IEC 7816-3 § 9.5.3 (CWT, BWT, BGT, ...). The detection of parity error on character received is optional. The interpretation of first bytes received as NAD and PCB to manage VPP is optional and depends on CCID capabilities.
3.2.2 APDU level of exchange For APDU level exchanges, the CCID provides the transportation of host’s APDU to ICC’s TPDU. APDU commands and responses are defined in ISO 7816-4. Two APDU levels are defined, short APDU and extended APDU. Short APDU and extended APDU are defined in ISO/IEC 7816-4 § 5.3.2. A CCID that indicates a short APDU exchange only accepts short APDU. A CCID that indicates an extended APDU exchange accepts both short APDU and extended APDU. If the ICC requests time extension, by using a NULL procedure byte (60h) in T=0 protocol or S(WTX) in T=1 protocol, the CCID informs the host of this request. A CCID supporting APDU level of exchanges implements a high level of automatism in ICC communications. It shall also provide a high level of automatism in ATR treatment and implement one of the following automatisms: automatic parameters negotiation (proprietary algorithm), or automatic PPS according to the current parameters. At least two standards of transportation for APDU are defined, ISO/IEC 7816-4 and EMV 3.1.1, which standard to implement is out of the scope of this specification.