Active4 years, 7 months ago
This part of ISO/IEC 7816 is one of a series of standards defining the parameters for integrated circuit cards with contacts and the use of such cards for international interchange. These cards are identification cards intended for information exchange negotiated between the outside. ISO/IEC 7816 Part 4: Interindustry command for interchange 1. Normative references 3. Definitions 4. Abbreviations and notation 5. Basic organizations z5.1 Data structures 5.1.1 File organization 5.1.2 File referencing methods 5.1.3 Elementary file structures 5.1.4 Data referencing methods 5.1.4.1 Record referencing.
I'm trying to understand the communication for sending APDU command-response pair. Could anyone please explain, in a simple way, how T=0 works?
What are the differences between APDU and TPDU?
For example, the command header is CLA, INS, P1, P2 and P3=0x20 32 bytes data. how does a card know whether the 5th byte of a command is Lc or Le? How does the card know not to expect any command data, and how does it know if the reader is expecting data in the response?
Another thing, when does the procedure byte participate in the scenario? Is it procedure byte? or, procedure bytes? Is it mandatory for the card to send procedure byte?
Maarten Bodewes66.7k11 gold badges90 silver badges187 bronze badges
user3480055user3480055
2 Answers
An APDU is an Application Protocol Data Unit, a TPDU a Transport Protocol Data Unit. If an APDU command response pair has been defined for T=0 and it has both command data and response data (case 4S) then a separate TPDU will be generated to send and receive data (
GET RESPONSE
). See chapter 12.2.1 of ISO/IEC 7816-3 (2006).The card knows the meaning of P3 (byte 5) because it is the server. Each command should be implemented in such a way that P3 can only have a single meaning. ISO/IEC 7816 does not comply with the OSI stack in that regard - the layers are not strictly separated. This is one of the major issues with ISO 7816.
The procedure byte is part of the T=0 transmission protocol. It is not defined in the application protocol, although it may map to SW1, the first part of a status word. It is only send to indicate to the interface device (IFD) what to do. See chapter 10.3.3 of ISO/IEC 7816-3 (2006) for more information. Chapter 10 defines T=0, T=1 does not contain a procedure byte.
Maarten BodewesMaarten Bodewes66.7k11 gold badges90 silver badges187 bronze badges
APDU is for Application Layer, TPDU for Physical Layer.If you send '00 84 00 00 08' to card, card can response with 'xx xx xx xx xx xx xx xx 90 00'. Windows 10 32 bit driver. There is no data behind p3, so p3 stands le. Otherwise, p3 stands lc.However, I think there is no need to distinguish le and lc.
bitbeginbitbegin