Smartcard Seminar : Assignment 1 : M-Card Scanning
1/23/2000, Naomaru Itoi (itoi@eecs.umich.edu)
Updated, 11/4/2000, Naomaru Itoi
In this assignment, you are to learn the directory structures of
smartcards, smartcard file types, and usage of APDUs. You are asked
to write a program to scan the M-Card and print out the account
balance.
Problem Description
Obtaining the account balance is done by three steps.
- Find out the class byte
Find out the class byte of M-Card by trying all possible values (0x00 -
0xff) in an APDU that you know will work (for example, selecting the root
file 3f.00 should always work) if used with the correct
class byte. M-Card returns 6e.00 if it does not know the class
byte, and 90.00 if the APDU succeeds.
- Scan the M-Card, and locate the purse file
Scan the M-Card by selecting files one by one. To reduce your
scanning time, you can assume that file name ranges from 00.00 to
02.ff. If you find directories, scan inside them as
well. M-Card returns 6a.82 if the specified file does not exist, and
90.00 if it exists. The purse file is the only record file in
M-Card.
After selecting a file, you can retrieve information associated with
the file from M-Card
with get response APDU. M-Card returns 0x1c byte if the selected file
is a directory file (DF), 0x0b byte if it is a binary file, and 0x0e
byte if it is a record file. get response fails with 67.00 if the
length asked differs from the length of the information.
Note that, when you select a file, if the file is a DF, you move into
the selected DF. In contrast, if it is a binary file or a record
file, you are still in the parent directory of the selected file.
- Obtain the balance
The length of the record is 6 byte. First two byte represent
transaction number, and the last 4 bytes represent balance in cents.
Your program must print out the file names of selected files as it
traverses the directory tree, and the balance. The print out should
look like this:
class 77
00.40 -- EF
00.80 -- EF
00.c0 -- DF
__00.f0 -- EF
01.00 -- DF
__00.ff -- record -- account $2.05
Reference
OK, that's it. Send questions to smartcards@umich.edu. Obviously,
doing more analysis on
M-Card is welcome. If you are interested in doing more, talk to
us about potential projects. Good luck. :)