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?
The block-oriented T=1 protocol is an asynchronous half- duplex protocol for data exchange between a smart card and a smart card terminal. Unlike the byte-oriented T=0 protocol, the block-oriented T=1 protocol separates data transmission via the answer to reset ( ATR) protocol and the application.
ISO 7816 Smart Card Standard ISO stands for International Standards Organization and the standard has been established to describe “Identification Cards – Integrated Circuit Cards with Contacts”.
VPP : Programing voltage input (optional use by the card). GND : Ground (reference voltage). CLK : Clocking or timing signal (optional use by the card). RST : Either used itself (reset signal supplied from the interface device) or in combination with an interal reset control circuit (optional use by the card).
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.
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". 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With