PCSC Operation APDU Interpreter Standard instructions READ BINARY
April 13, 2023 at 2:39 AMREAD BINARY instruction
The READ BINARY instruction retrieves data from a memory card (wired-logic PICC or VICC).
For any PICC/VICC but Mifare Classic, this instruction is executed without any prerequisite.For Mifare Classic, to be able to read the sector’s data, the application must be authenticated onthe card’s sector. The application must therefore invoke GENERAL AUTHENTICATE instruction (with a valid key A or key B for the sector) before invoking the READ BINARY instruction. Using the MIFARE CLASSIC READ instruction instead can be easier and may shorten thetransaction time.
Command format
Field | Value | Remark |
---|---|---|
CLA | FF |
|
INS | B0 |
|
P1 | AddressMSB | See below |
P2 | AddressLSB | See below |
Lc | absent | |
DataIn | absent | |
Le | XX |
P1 and P2 form the address that will be sent to the PICC/VICC in its specific read command. Most PICC/VICC are divided into small blocks (sometimes called pages). The address is a block number,and not to an absolute byte offset in memory.Both the allowed range for the address and the value for Le depend on the capabilities of thePICC/VICC. Please always refer to its datasheet for details. Note that Le = 00
should always work,provided that the address is valid.
For Mifare Classic, P1,P2 is the address of the block (
0000
to00FF
), but remember that theauthentication is made on a per-sector basis. A new authentication must be performed every timeyou have to access another sector.For a NFC Type 2 Tag, P2 is the block number, and P1 the sector number if the PICC supports thisfeature. Set P1 to00
if it is not the case.
Response
Field | Value | Remark |
---|---|---|
DataOut | The expected data | |
SW | 9000 on success |
Other values are documented in Status Words |