分享

sim command

 天蝎泪 2006-06-20
SIM COMMANDS

The mobile equipment communicates with the SIM using standard ISO 7816-3 Operating Procedures (a copy of parts 1, 2, and 3 can be found here).

This transmission protocol uses Application Protocol Data Units (APDU), which can be either commands or responses. These are sent across the electrical interface between the SIM and the mobile equipment, or the SIM-ME interface for short.

CLA

INS

P1

P2

P3

Data

Command APDU format.

There are five fields in an APDU command. The class of instruction (CLA) is always A0 for GSM. The instruction code (INS) indicates the particular command to be performed. P1, P2, and P3 are parameters for the command, with P3 containing the length of the Data segment, if any.

Data

SW1

SW2

Response APDU format.

The response to a command is returned in three fields. The Data portion, if any, contains information requested in the command. SW1 and SW2 are status words indicating the success or failure of the command.

A number of commands are defined for GSM SIM cards, including functions to read and write data, confirm security features, and run the GSM authentication algorithm. Completing an entire GSM procedure may require a series of APDU command/response pairs.

 

COMMAND

INS

P1

P2

P3

SELECT

A4

00

00

02

STATUS

F2

00

00

length

READ BINARY

B0

offset (high)

offset (low)

length

UPDATE BINARY

D6

offset (high)

offset (low)

length

READ RECORD

B2

record number

mode

length

UPDATE RECORD

DC

record number

mode

length

SEEK

A2

00

type/mode

length

INCREASE

32

00

00

03

VERIFY CHV

20

00

CHV number

08

CHANGE CHV

24

00

CHV number

10

DISABLE CHV

26

00

01

08

ENABLE CHV

28

00

01

08

UNBLOCK CHV

2C

00

00 (for CHV1)

02 (for CHV2)

10

INVALIDATE

04

00

00

00

REHABILITATE

44

00

00

00

RUN GSM ALGORITHM

88

00

00

00

SLEEP

FA

00

00

00

GET RESPONSE

C0

00

00

length

SIM command coding.

 

SIM FILE SYSTEM

The SIM maintains information in a series of "files" that are organized hierarchically, much like the operating system of a personal computer. These files may be for administrative purposes or be specific to the GSM user application. Data in these files are accessed through APDU commands sent to the operating system.

A file is composed of a header and a body. The header contains structure and attribute information and is managed by the operating system. The body, which is optional, contains the actual data. Files are uniquely identified by a two-byte hexadecimal number.

First Byte

GSM file type

3F

Master File

7F

Dedicated File

2F

Elementary File under the Master File

6F

Elementary File under a Dedicated File

GSM file type identifiers (first byte).

There are three different types of files on a SIM: a master file (MF), dedicated files (DF), and elementary files (EF). There is one master file on a SIM, which holds all the other files in a tree-like structure. Dedicated files are headers that hold hierarchical trees of elementary files, but don抰 have data of their own. GSM defines two dedicated files immediately under the MF, DFGSM

containing GSM application files and DFTELECOM containing the application service features.

Elementary files (EF) have both a header and a body, and come in three flavors. The first, called transparent, is a binary file that can store information of varying length in any location. This is a raw, unstructured, random access file. The second is called linear fixed and stores data records that all have the same fixed length. The third is termed cyclic and is designed to store records in chronological order. It also uses fixed-length records, but when the last entry is full the next record overwrites the oldest entry.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多