ISO/IEC 7816-4
Identification cards — Integrated circuit cards — Part 4: Organization, security and commands for interchange
Cartes d’identification — Cartes à circuit intégré — Partie 4: Organisation, sécurité et commandes pour les échanges
APPEND RECORD command
The command initiates either the writing of a new record at the end of an EF supporting a linear structure, or the writing of record number one in an EF supporting a cyclic structure. When using current record addressing, the command shall set the record pointer on the successfully appended record. If the command applies to an EF supporting a linear structure full of records, then the command is aborted because there is not enough memory space in the file.
If the command applies to an EF supporting a cyclic structure full of records, then the record with the highest record number is replaced. This record becomes record number one. If the records are SIMPLE-TLV data objects (see 5.2.1), then Table 53 illustrates the command data field.
Table 56 —APPEND RECORDcommand-response pair | |
CLA INS P1 P2 | As defined in 5.1.1 ‘E2′ ’00′ (any other value is invalid) See Table 47 with bits 3 to 1 set to 000 (any other value is reserved for future use) |
Lcfield | Present for encoding Nc> 0 |
Data field | Record to be appended |
Lefield | Absent for encoding Ne= 0 |
Data field | Absent |
SW1-SW2 | See Tables 5 and 6 when relevant, e.g., ’63CX’ (see 7.3.2), ’6581′, ’6700′, ’6981′, ’6982′, ’6986′, ’6A81′, ’6A82′, ’6A83, ’6A84′, ’6A85′ |
SEARCH RECORD command
The command initiates a simple or enhanced or proprietary search on records stored within an EF. The search can be limited to records with a given identifier or to records with a number greater or smaller than a given number. It can be performed in increasing or in decreasing order of record numbers. The search starts either from the first byte of the records (simple search), or from a given offset within the records (enhanced search), or from the first occurrence of a given byte within the records (enhanced search). The response data field gives the numbers of the records matching the search criteria within an EF supporting records. The command shall set the record pointer on the first record matching the search criteria. In an EF supporting records of variable size with linear structure, the search shall not take into account the records shorter than the search string. In an EF supporting records of fixed size with linear or cyclic structure, if the search string is longer than the records, then the card shall abort the command.
Table 57 —SEARCH RECORDcommand-response pair | |
CLA INS P1 P2 | As defined in 5.1.1 ‘A2′ Record number or record identifier (’00′ references the current record) See Table 58 |
Lcfield | Present for encoding Nc> 0 |
Data field | Search string (bits 3 and 2 of P2 not set to 11, simple search), or Search indication (2 bytes) followed by search string (bits 3, 2 and 1 of P2 set to 110, enhanced search), or Proprietary (bits 3, 2 and 1 of P2 set to 111, proprietary search) |
Lefield | Absent for encoding Ne= 0, present for encoding Ne> 0 |
Data field | Absent or record numbers |
SW1-SW2 | See Tables 5 and 6 when relevant, e.g., ’6282′, ’6982′, ’6CXX’ |
The response data field is absent either because the L efield is absent, or because no match is found.
The response data field does not give record identifiers because they may not be unique. |
Table 58 —P2 | ||||||||
b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | Meaning |
x | x | x | x | x | - | - | - | Short EF identifier according to Table 47 |
——– | ——– | ——– | ——– | ——– | 0 0 0 0 0 1 1 1 | x 0 0 1 1 0 0 0 | x 0 1 0 1 x 0 1 | Simple search with record identifier in P1 —Forward from first occurrence —Backward from last occurrence —Forward from next occurrence —Backward from previous occurrence Simple search with record number in P1 —Forward from P1 —Backward from P1 |
- | - | - | - | - | 1 | 1 | 0 | Enhanced search(see Table 59) |
- | - | - | - | - | 1 | 1 | 1 | Proprietary search |
In an enhanced search (bits 3, 2 and 1 of P2 set to 110), the command data field consists of a search indication on two bytes followed by a search string. Table 59 specifies the first search indication byte. According to the first byte of the search indication, the second byte is either an offset or a value, i.e., the search in the records shall start either from this offset (absolute position) or after the first occurrence of this value.
Table 59 —First byte of the search indication | ||
b8 b7 b6 b5 b4 | b3 b2 b1 | Meaning |
0 0 0 0 0 0 0 0 0 1 | —— | The subsequent byte is an offset (start from that position) The subsequent byte is a value (start after the first occurrence) |
————————————————– | 0 x x 0 0 0 0 0 1 0 1 0 0 1 1 1 x x 1 0 0 1 0 1 1 1 0 1 1 1 | Record identifier in P1 —Forward from first occurrence —Backward from last occurrence —Forward from next occurrence —Backward from previous occurrence Record number in P1 —Forward from P1 —Backward from P1 —Forward from next record —Backward from previous record |
Any other value is reserved for future use by ISO/IEC JTC 1/SC 17. |