This article describes the Logical Model of a SIM Card File System according to 3GPP TS 11.11 which you can download for free here. The File Selection and Read/Write Data will be discussed on another post.
So, have you ever wonder how SIM card organizes data inside it? Actually, SIM cards organizes data just like modern computers! Wow?? Well... actually with limitations.
Let's take a look at the following picture as approach:
Seems familiar? Yes, it is indeed is a screenshot Windows Explorer with modification.
Q: The GUI to access the SIM card files just like the above picture is cool, is it for real?
A: Basicly, the SIM talk to terminal using APDU. However, SIM card vendors may have their proprietary tool to achieve this.
Type of File
The type of an entity in the SIM card file system is referred as Type of File:
- MF (Master File) is similar to Drive. There is only one MF in a card.
- DF (Dedicated File) is similar to Folder/Directory. The maximum level of DF is only two level.
- EF (Elementary File) is similar to File.
Each type of file has header, which contain the properties of the file, such as its identifier, parent, size, etc. And only EF that has data inside it (still sounds familiar right?).
File Structure
If in the modern computers we can have lots of file extensions, in SIM card there are only three File Structures:
- Transparent EF
- Linear Fixed EF
- Cyclic EF
What? Where is JPEG, XLS, DOC, PDF, TXT, etc? How if I would like to store image? Well, you must choose from those three, most likely Transparent EF.
Let's see each structure in detail.
Transparent File
Transparent file contains binaries data.
Its size can be from 1 up to 65535 bytes. However for Java SIM card the maximum is only 32767 bytes due to limitation on short range. As a note, there is no maximum size stated on the specification.
To access data inside transparent file, a two-bytes offset shall be used. The offset starts from 0x0000 with Big Endian format.
NOTE: Block read/write mechanism shall be used to read/write data if the number of bytes exceed 256/255 bytes for read/write respectively. This is related to limitation of length that fits into a single APDU.
Linear Fixed File
Linear Fixed file contains records of data having same length, just like drawers.
The GSM specification refers to ISO/IEC 7816-4 which stated that the number of records cannot more than 254, and maximum record length is 255 bytes. Therefore, the maximum size of Linear Fixed file is 64770 bytes (simply by multiplying those numbers).
Q: My friend names in my SIM phonebook are not of the same length, is it Linear Fixed?
A: Yes, padding is added.
Cyclic File
Cyclic file similar to Linear Fixed file, but its first and last record has link.
The size of cyclic file can be up to 255 records x 255 bytes/record = 65,025 bytes.
Q: What is the Cyclic EF used for?
A: It is usually used to store historical data. Some examples are Last Number Dialled (EF LND) and Accumulated Call Meter (EF ACM). There are not many files using this structure.