Mifare DESFire

Elementary Data Files

Elementary Data Files contain a single data item. In the example below file ‘02’ holds the data for CCDA item DF56h, House Name/Number.

Example EF file structure

Length Format Data
13 00 (ASCII) 44,45,20,53,41,49,4C,57,41,59,20,54,45,53,53,41,43,45


‘Length’ specifies the length of actual data within the file including the data format byte.

‘Format Byte’ declares the format type of the data ‘Data’ is the data itself.

In some circumstances it may be expedient to create files that are larger than the immediate data requirement if contents are likely to change during the life of the card. As 32 bytes of NV is always allocated at file creation there is no disadvantage in using this as a default size. Unused space should be packed with FFh.

This file is created using the CreateBackupDataFile command.

Cmd File No Comms Access File Size
CB 02 00 Fx yx* As required

This file is read using the ReadData command and written with the WriteData command. When writing data CommitTransaction must be used to complete the writing and backup process. Total NV space used will be doubled due to the creation of a backup file.

* ‘x’ represents a scheme specific key number. ‘y’ represents a User PIN if required.

Access Conditions:

The table below summarises the communications and access settings for these files.

Description File ID Comms Settings   Access  
      R W RW Ch
Index File 00 00 (Plain) 0xE *K 0xF *K
Free Access File 01 00 (Plain) 0xE *K 0xF *K
Data Files 0x 00 (Plain) *P *K 0xF *K

*K denotes the diversified, scheme specific DES or TDES write key in the range 0 -13 *P denotes the read permission associated with individual EF files. This may be ‘Free Read’ or subject to authentication depending on scheme requirements. 

 Memory Considerations:  The available space on a particular platform is important if other non-LASSeO applications such as ITSO are also required. The ITSO specification stipulates that the default ITSO configuration requires 1760 bytes of memory. Because citizen data is to be stored in backup files, which effectively require double the amount of memory as standard files, space may become a significant issue on some platforms where ITSO is also resident.

Table 2. Space and Application Requirements

  MF3IC40 MF3IC21–EV1 MF3IC41-EV1 MF3IC81-EV1
Free Space 4096 bytes 2272 bytes 4832 bytes 7936 bytes
Max.Citizen applications 7 4 8 15
With ITSO application 4 N/A 5 12

* All values shown in the table above are decimal.

The table above is a guide to how many citizen applications can be stored on a particular platform besides the Service Directory. The estimate is based upon a typical application with an Index File of 2 blocks and a Free Access File of 4 blocks. It does not include any provision for individual data EFs within applications. Each additional EF will require at least 64 bytes on NV memory.

Because NV memory is always allocated in 32 byte blocks, this could be used as a default size for many single item EFs even though all the space is not required. As some data items will change within the lifecycle of a card this extra space may be useful where data items increase in size. The only guidance available for allocating space for specific items is in the Government Data Catalogue where maximum sizes for some variable items are specified. However, these sizes are in many cases inappropriate to smartcard platforms where space may be at a premium. For example, Forename (DF32h) has a stated maximum size of 80 characters. On a DESFire platform using a Backup file, adherence to this limit would require the allocation of 192 bytes of NV memory for this one item alone. This is clearly excessive.

In most circumstances a minimum 32 byte allocation (64 bytes with backup) should be sufficient. For items that could exceed this minimum a judgement needs to be made on how much space might be needed. Even in a scenario where not enough space has been allocated there is always the option to delete the file and create a new one with sufficient room. The only caveat here is that the original NV memory will be lost when the file is deleted.