Smart Cards

I've been writing code for a Towitoko ChipDrive Micro smartcard reader.

Update: Towitoko was acquired by SCM Microsystems in 2002. Later that year they changed their name to Tx Systems, Inc. You can see their website here.

SMARTCARD CONTACTS

CONTACT

USE

COMMENTS

C1

Supply voltage

Between 4.5 and 5.5 volts. Consumption not to exceed 10 milliamps at any acceptable frequency.

C2

Reset signal

 

C3

Clock signal

1 to 5 MHz, provided externally.

Duty cycle of 40% to 60% of the period.

C4

Reserved

No connection.

C5

Ground

 

C6

Programming voltage

Not typically provided on plug-in SIMs.

C7

Input/Output

A 20 kilo-ohm resistor is recommeded on the interface device.

Baudrate is (clock frequency) / 372.

C8

Reserved

No connection.

ISO/IEC 7816-3 pins and their GSM values.

SUBSCRIBER IDENTITY MODULE

Global System for Mobiles (GSM) uses a personalized smartcard, called a Subscriber Identity Module (SIM) to provide storage and authentication functions for the customer.

Interesting information can be extracted from the SIM.

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’t 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.

 


Send mail to Dan Veeneman
Last revised August 10, 1998