EF file structures
In contrast to files in Windows systems, EFs in smart cards have internal structures. The structure can be individually selected for each EF according to the intended purpose of the file. This has major advantages for the outside world, since the internal structure allows data elements to be constructed such that they can be accessed very quickly and effectively. Managing these data structures requires a significant amount of program code in the smart card. This is why the data structures are not all mutually symmetrical, but instead occur only in the forms often needed in practice.

Transparent file structure
The transparent data structure is often referred to as a binary or amorphous structure; in other words, a transparent file has no internal structure. The data contained in the file can be accessed for reading or writing in bytes or blocks using an offset value. The READ BINARY, WRITE BINARY and UPDATE BINARY commands are used for this purpose.
The minimum size of a file with a transparent structure is one byte. No maximum size is explicitly specified in any standard. However, the maximum number of bytes that can be read in the short format (255) or the long format (65,536), combined with the maximum offset value (32,767), allows a maximum size of 65,791 bytes or 98,303 bytes, espectively.With the memory capacities of contemporary smart cards, these maximum sizes are slowly slipping into the realm of what is feasible, although in current practice transparent files are rarely larger than a few hundred bytes. Figure 5.20 illustrates the organization of the transparent file structure, and Figure 5.21 illustrates how six bytes can be accessed for reading from a 12-byte long file using an offset of 4 bytes. A transparent file structure is primarily used for very small amounts of data or for data
having no internal structure. An example of a typical use would be storing a digitized passport photograph that could be read from the smart card by the terminal. However, this linear, onedimensional data structure can also be used to simulate other data structures if necessary. Of course, in such cases the terminal access takes a more complex form, since parameters related to the structure of the file must be stored inside the file itself.

Linear fixed file structure
The linear fixed data structure is based on chaining fixed-length records. A record consists of a series of individual bytes. Individual records within this data structure can be freely accessed. The smallest unit of access is one record, which means that it is not possible to access only part of a record. The commands READ RECORD, WRITE RECORD and UPDATE RECORD can be used for reading and writing within this data structure. The first record is always numbered record 1. The largest allowed record number is ‘FE’, or 254 in decimal notation, since’FF’is reserved for future extensions. The length of a single record is determined by the access commands, and can range from 1 to 254 bytes, but all records in the file must have the same length. Figure 5.22 illustrates the organization of the linear fixed file structure. A typical application for this data structure is a telephone directory, in which the name comes first, followed by the associated telephone number in a fixed position.

Linear variable file structure
The fact that all records in a linear fixed file structure have the same length means that memory space is often wasted when this structure is used, since many record-oriented data items have variable lengths. One example is the names in a telephone directory. The challenge of minimizing the amount of memory space is met by the linear variable structure, in which each record can have an individually defined length. The unavoidable consequence of this is that each record must have a supplementary field that contains information about its length. This structure is otherwise similar to the linear fixed structure. The first record is numbered 1, and the maximum file length is 254 records. The length of an individual record is determined by the access commands, and can range from 1 to 254 bytes. The access commands for this structure are the same as for the linear fixed structure, namely READ RECORD, WRITE RECORD and UPDATE RECORD. This file structure is preferably used when records with highly variable lengths are to be stored and the use of smart card memory must be minimized. For example, the previously mentioned telephone directory could be optimized by making each record exactly as long as the actual entry, so the records would not all have the same length. However, managing this file structure requires program code in the smart card operating system and extra memory space to store the record length information. For this reason, operating systems for microcontrollers with small memories often do not offer this file structure. Consequently, the ISO/IEC 7816-4 standard explicitly allows this limitation in some profiles.

Cyclic file structure
The cyclic structure is based on the linear fixed file structure, and thus consists of a certain number of records that all have the same length. In addition, the EF contains a pointer that always indicates the record that was last written. This record is always numbered record 1. If the pointer reaches the last record in the EF, the operating system automatically adjusts it to point to the first record in the EF when the next write access occurs. It thus behaves the same as the hour hand of an analog clock. If a cyclic file contains n records, the last one that was written is record number 1. The one that was written just before that is number 2, and the oldest record is number n. This file structure, like the other two record-oriented file structures, can also be accessed by addressing the first, last, next or previous record. The number and size of the records are fully analogous to those for the linear fixed structure. Due to the limitations of the write and read commands, a maximum of 254 records can be created, each with a maximum length of 254 bytes. This structure is typically used for log files within the smart card, in which the oldest entry is always overwritten by a new entry.

Execute file structure
The ‘execute’ structure is in principle not a separate structure, since it is based on the transparent structure. It is described in the EN 7826-3 standard and offers numerous extension options within the operating system. The execute structure is not intended to be used for storing data, but rather for storing executable program code.4 A file with execute structure can be accessed using the same commands as for transparent files. Of course, this structure creates a sort of ‘back door’, since anyone who can write to such a file can download his or her own program code into the card, possibly including a Trojan horse. The maximum program size is the same as the maximum size of a transparent file, and is thus 65,791 bytes without offset addressing or 98,303 bytes with offset addressing, using the UPDATE BINARYcommand. No internal data structure is specified, but it is certainly possible for the program code contained in the file to introduce one, so that the executable program can define its own data regions in the execute file and access them internally.

Database file structure
The ISO/IEC 7816-7 standard defines a subset of SQL for smart cards with the designation SCQL (smart card query language). In order to store data in the file system of a smart card such that they can be read using SCQL commands, it is necessary to provide a suitable file structure. The layout of this structure is not standardized; instead, its design is left up to individual operating system producers. A database file stores the actual user data, various ‘views’ of the database, the access privileges and user profiles.

Data object file structure
The ISO 7816-4 commands PUT DATA and GET DATA are used to store TLV-coded data objects in smart cards and to read out such stored objects. This can be implemented either completely independent of the file management system, or within the file management system using a special structure for storing data objects. If the implementation is within the file management system, a slightly modified transparent or linear fixed file can be used as a storage location for data objects. In this case, the PUT DATA and GET DATA commands access these modified file structures via the file management system.

Sequence control file structure
If a smart card operating system has a command sequence controller, information regarding the commands that can be accepted must also be stored in memory. This is normally done using a file whose structure is specially adapted to this task. However, this is not standardized, so every operating system with sequence control has its own format, which is not compatible with that of any other operating system.