Smart Reader Operation NFC Templates ISO Data
September 3, 2024 at 2:25 AMISO Data Template
Description
ISO/IEC 7816-4 is the standard for smart card commands. Most contactless smartcards use the ISO/IEC 7816-4 on top of a ISO/IEC 14443-4 ‘T=CL’ or “ISO-DEP” communication channel.
According to this standard, the card is structured as a (lightweight) file-system, providing Directory Files and Elementary Files.
The standard-defined Instruction-set allows to navigate in the smartcard’s directories and file tree, and to read the data from its files.
Every Instruction call is named an “APDU”.
The card’s Response to every Instruction is always terminated by a 2-B Status Word which denotes the success (values 9xxx
, typically 9000
) or the failure (values 6xxx
).
Using this ISO/IEC 7816-4 Template, the Reader is able to send 1, 2 or 3 APDUs and to extract the data from the card’s last Response.
Remark
This Template is suitable to read data on virtually any contactless smartcard, provided that said data is accessible in the plain and without prior authentication.
Reading data from a secure smartcard (such as Desfire) or an NFC applications (such as Apple VAS and Google SmartTap) is possible only using a dedicated Template that implements both the application-specific security and Instruction-set at once.
Lookup List
This Template supports 4 protocol selectors:
LKL Value | Selected protocol(s) |
---|---|
13 |
ISO-DEP on NFC-A and NFC-B - ISO/IEC 14443-4 ‘T=CL’ types A and B |
11 |
ISO-DEP on NFC-A - ISO/IEC 14443-4 ‘T=CL’ type A |
12 |
ISO-DEP on NFC-B - ISO/IEC 14443-4 ‘T=CL’ type B |
72 |
Innovatron Radio Protocol (legacy Calypso cards) |
Registers
This Template uses 8 configuration registers:
Alias | Offset | Name | Description |
---|---|---|---|
LKL | 0 |
Lookup List | See the Lookup List table above |
APDU1 | 5 |
1st APDU | This is typically a SELECT APPLICATION or a SELECT DIRECTORY Instruction. |
APDU2 | 6 |
2nd APDU | This is typically a SELECT FILE Instruction. |
APDU3 | 7 |
3rd APDU | This is typically a READ BINARY or READ RECORD Instruction. |
TOF | 1 |
Output Size and Format | See details below |
LOC | 3 |
Location of Data | See details below |
OPT | 4 |
Options | Template-specific Options |
PFX | 2 |
Prefix | Template-specific Prefix |
APDU1 - 1st APDU
Offset : 5
Size : 32
Remark : The Reader checks the Status Word. In case of any error (SW!=9xxx
), the Template is terminated.
APDU2 - 2nd APDU
Offset : 6
Size : 32
Remark : The Reader checks the Status Word. In case of any error (SW!=9xxx
), the Template is terminated.
APDU3 - 3rd APDU
Offset : 7
Size : 32
Remark : The Reader checks the Status Word. In case of any error (SW!=9xxx
), the Template is terminated.
TOF - Output Size and Format
Offset : 1
Size : 2
Byte 0 : RAW Mode
Condition : When RAW Mode is selected (Bit 6 in Byte 0 is 0
)
Bit | Role | Values |
---|---|---|
7 | Invert Data? | 0 : Transmit the sequence of bytes as is1 : Transmit the sequence of bytes in reverse order |
6 | Mode | 0 : RAW Mode (Data is a numerical value)1 : String Mode (Data is an ASCII string) |
5 | Padding if Data is shorted than specified length | 0 : Padd with 0 on the left1 : Padd with F on the right |
4 | Remove leading zeroes? | 0 : Keep all digits1 : Suppress 0 digits on the left of the Data |
3-0 | Length and Format | 0 : Decimal, 10 digits (truncation on 4-B)1 : Raw (hex), 4 bytes (32 bits)2 : Raw (hex), 8 bytes (64 bits)3 : Raw (hex), 5 bytes (40 bits)4 : Raw (hex), 10 bytes (80 bits)5 : Raw (hex), 7 bytes (56 bits)6 : Raw (hex), 11 bytes (88 bits)7 : RFU8 : Raw (hex), 16 bytes (128 bits)9 : Raw (hex), 20 bytes (160 bits)10 : Raw (hex), 24 bytes (196 bits)11 : Raw (hex), 32 bytes (256 bits)12 : Decimal, 12 digits (truncation on 5-B)13 : Decimal, 13 digits (truncation on 5-B)14 : Decimal, variable length15 : Raw (hex), variable length |
Byte 0 : String Mode
Condition : When String Mode is selected (Bit 6 in Byte 0 is 1
)
Bit | Role | Values |
---|---|---|
7 | Invert Data? | 0 : Transmit the sequence of characters as is1 : Transmit the sequence of characters in reverse order |
6 | Mode | 0 : RAW Mode (Data is a numerical value)1 : String Mode (Data is an ASCII string) |
5 | Padding if Data is shorted than specified length | 0 : Variable length (no padding)1 : Padd with (space characters) on the right until the specified length |
4 | Short string or Long string? | 0 : Short string (truncate to 16 characters or less)1 : Long string (more than 16 characters) |
3-0 | Length | 0 : 16 characters1 : 1 character2 : 2 characters3 : 3 characters4 : 4 characters5 : 5 characters6 : 6 characters7 : 7 characters8 : 8 characters9 : 9 characters10 : 10 characters11 : 11 characters12 : 12 characters13 : 13 characters14 : 14 characters15 : 15 characters |
Byte 1 : Options for Long String
Condition : When Long String Mode is selected (Bit 6 in Byte 0 is 1
and Bit 4 is 1
)
Use this byte to specify the exact length to read from the card. Valid range is 1
to 255
.
LOC - Location of Data
Offset : 3
Size : 2
Byte 0 : Shift Bytes
Leading bytes to suppress.
Byte 1 : Shift Bits
Leading bits to suppress; valid range is 0
to 7
.
OPT - Options
Offset : 4
Size : 1
If this register is set, the Reader adds a token to its output to tell the receiver what kind of credential has been read.
Bit | Role | Values |
---|---|---|
7-4 | RFU | |
3-2 | Position of the Card Type Token | 0 : Before the Prefix1 : After the Prefix, before the Data2 : After the Data (before the Suffix)3 : RFU |
1-0 | Add a Card Type Token to the output stream? | 0 : Do not add a Card Type Token1 : Add Card Type Token in hex (1F )2 : Add Card Type Token as char (T )3 : RFU |
PFX - Prefix
Offset : 2
Size : 8
A Template-specific Prefix, that is added after the Reader’s global Prefix.
Remark : Use \t
for a Tab, \n
for Enter, \b
for Back space, \v
for Vertical space.