APDU message command-response pair
There are two categories of APDUs: command APDUs and response APDUs. A command APDU is sent by the reader to the card – it contains a mandatory 4-byte header (CLA, INS, P1, P2) and from 0 to 255 bytes of data. A response APDU is sent by the card to the reader – it contains a mandatory 2-byte status word and from 0 to 256 bytes of data.
| Command APDU | ||
|---|---|---|
| Field name | Length (bytes) | Description |
| CLA | 1 | Instruction class - indicates the type of command, e.g. interindustry or proprietary |
| INS | 1 | Instruction code - indicates the specific command, e.g. "write data" |
| P1-P2 | 2 | Instruction parameters for the command, e.g. offset into file at which to write the data |
| Lc | 0, 1 or 3 | Encodes the number (Nc) of bytes of command data to follow |
| Command data | Nc | Nc bytes of data |
| Le | 0, 1, 2 or 3 | Encodes the maximum number (Ne) of response bytes expected |
| Response APDU | ||
| Response data | Nr (at most Ne) | Response data |
| SW1-SW2 (Response trailer) | 2 | Command processing status, e.g. 90 00 (hexadecimal) indicates success |
Abbreviations and Notation
For the purposes of this part of the ISO/IEC 7816, the following abbreviations apply :
| APDU | Application protocol data unit |
| ATR | Answer to reset |
| BER | Basic encoding rules of ASN.1 (see annex D) |
| CLA | Class byte |
| DIR | Directory |
| DF | Dedicated file |
| EF | Elementary file |
| FCI | File control information |
| FCP | File control parameter |
| FMD | File management data |
| INS | Instruction byte |
| MF | Instruction byte |
| P1-P2 | Parameter bytes |
| PTS | Protocol type selection |
| RFU | Reserved for future use |
| SM | Secure messaging |
| SW1-SW2 | Status bytes |
| TLV | Tag length value |
| TPDU | Transmission protocol data unit |
For the purposes of this part of ISO/IEC 7816, the following notation applies :
< TR>
| '0'-'9' and 'A'-'F' | The sixteen hexadecimal digits |
| (B1) | Value of byte B1 |
| B1||B2 | Concatenation of bytes B1 (the most significant byte) and B2 (the least significant byte) |
| # | Number |