The file system used on a SIM is identical to that laid down by
ISO 7816 for smart cards, and is fairly basic. Anyone familiar with
common desktop computer systems should be aware of the following
differences:
Ø All files are identified
(named) in 4 bytes
Ø Directories are of fixed
size, and known as "dedicated"
Ø Files must be 'selected'
before you can do anything with them
Files on a SIM come in a variety of types:
|
File Type
|
Description
|
|
Transparent
|
Random access file that can contain anything.
|
|
Linear fixed file
|
Records of fixed length; can be navigated by moving to 'next',
'last', etc. Examples include an address book function.
|
|
Cyclic
|
Fixed length records, where selecting the 'next' of the last one
leads to the first. Examples include last numbers dialed.
|
|
Variable length records
|
Not supported in GSM.
|
|
Incremental
|
Very useful files, but very small. A single byte that can be
incremented or decremented by one. Useful because control can be
very granular: one PIN to decrement, one to increment. Examples
include pay-as-you-go applications.
|
There are already many files on a typical SIM, and indeed, to
conform to the GSM protocol you need a number of files. The
following tree structure shows the files required for GSM
compatibility:

Some Useful Files
Ø 2FE2 - Unique integrated
circuit number
Ø 6F05 - Language choice
Ø 6F07 - Unique subscriber
number
Ø 6F3C - SMS messages (176
length fixed linear)
Ø 6F44 - Last number
dialed
Creating Files
When creating new files, it's important to avoid namespace
problems, and the best process is certainly to create your own
directory off the root (which is always known as 3F00, for arcane
reasons) and place all your data there. Creating files is just a
matter of sending the correct commands to the SIM:
|
F0
|
Create LF /DA01
|
|
E0
|
|
00
|
|
00
|
|
11
|
|
FF
|
|
FF
|
|
00
|
Block Size
|
|
80
|
|
DA
|
File ID
|
|
01
|
|
02
|
Type
|
|
00
|
Valid Action
|
|
44
|
Access Conditions
|
|
F1
|
|
44
|
|
01
|
Status
|
|
04
|
Bytes
|
|
11
|
Access Keys
|
|
11
|
|
11
|
|
20
|
Optional (in this case, record length)
|
This example creates a linear fixed file, with a fixed length of
32 bytes. The directory will already have been selected. Note the
complexity of "Access Conditions" and "Access Keys" - in this
example, only one PIN is required, and it allows full read/write
access.
However, files are generally written to the SIM during the
manufacturing process, for security reasons. These files generally
make up a "Soft Mask" that cannot be changed, ever. SIMs also hold
a "Hard Mask", which contains the OS and system files. The "Hard
Mask" is not normally available, even to developers.
Details of all the available commands can be found in ISO 7816,
or the programming manual for your particular SIM.
PIN Security
Access to files may be controlled in an extremely granular
manner, using only the ISO 7816 required controls. Files may be
read (or write) only, may allow read or write after the
presentation of a particular PIN, or never allow any kind of
external access. This gives an enormous amount of security, with
very little programming.
GSM PINs should generally be numerical (given the restrictions
of the keypad), but ISO 7816 allows any combination of bytes to be
used.
Once a PIN has been presented, it remains valid for the duration
of the session. This may be until power down, or until a different
directory is selected. (This will be the same thing in most cases,
but not always.) This means that a user can be asked for a PIN,
which is then presented to the SIM, which allows use until power
down without storing the PIN on the handset (which wouldn't be very
secure).