EECS 598-2 / Winter 2000
Homework Assignment #1

How to compile, download, and run software on Cyberflex Access smartcard
1/6/2000, Naomaru Itoi (itoi@eecs.umich.edu)

In this assignment, you are to learn how to compile a sample Java applet called "Wallet.java" for smartcards, download it into your smartcard, and communicate with it. You do not have to submit anything.

Compilation is done by two steps. The first is javac -g (Make sure to use /usr/um/jdk-1.2.2/bin/javac, not /usr/um/bin/javac nor /usr/bin/javac. Also, do not forget -g) on Sun workstation in CAEN labs (or any computer with javac version 1.2 or higher), and the second is mksolo (in /afs/engin.umich.edu/class/w00/eecs598/002/software/bin), which must be run on Linux. We provide a Linux box called snoopy.citi.umich.edu for this purpose. snoopy has afs mounted on it so that you can share files between Sun workstation and snoopy. Try to ssh to snoopy, and let me know if you cannot. If you get the applet compiled, then download it to your Cyberflex Access smartcard. Put your Todos Argos Mini smartcard reader on your workstation's serial port (do not forget the power), insert your card in the reader, and run smartcard command interpretor called pay. You use pay command "jl" to load the applet, and "jp" to select it.

Once the applet is downloaded and selected, you can communicate with the applet with APDUs (APplication Data Unit). Wallet.java (which is in /afs/engin.umich.edu/class/w00/eecs598/002/software/example) takes four types of APDUs, i.e., deposit (03 10), debit (03 20), balance (03 30), and validate PIN (03 40).

When finished communicating with it, use "jq" to unselect the applet, and "ju" to unload it.

Now step-by-step example.

/* First, compile your applet with -g and appropriate class path. */

decoder% /usr/um/jdk-1.2.2/bin/javac -g -classpath /afs/engin.umich.edu/class/w00/eecs598/002/software/class Wallet.java
-> Wallet.class
/* login to snoopy.citi.umich.edu, and get AFS token of engin cell */
decoder% ssh snoopy.citi.umich.edu
itoi@snoopy :) /usr/vice/bin/klog itoi@ENGIN.UMICH.EDU
/* (Linux) Then, run mksolo on the .class file and get .bin file */
itoi@snoopy :) /afs/engin.umich.edu/class/w00/eecs598/002/software/bin/mksolo -usemap=/afs/engin.umich.edu/class/w00/eecs598/002/software/map/Access.map -v -d Wallet.class
-> Wallet.bin
/* start pay */
decoder% /afs/engin.umich.edu/class/w00/eecs598/002/software/bin/pay
/* help is available by typing 'h' in pay. */
pay> h
/* Pick the serial port. If you put your smartcard to serial port A, type '1'. If it is on port B, type '2'. */
pay> 2
1:3b 2:16 3:94 4:81 5:10 6:6 7:1 8:81 9:2f /* this is answer to reset */
/* download "Wallet.bin" to the card */
pay> jl Wallet.bin
applet file "Wallet.bin"
program ID 77.77 /* program installed in file 3f00/7777 */
container ID 77.78 /* data container installed in file 3f00/7777 */
instance container size 2048
instance data size 1024
AID 7777777777 /* Application ID is 7777777777 */
signature eed461e31de414c1
90 00 ok
/* select the applet */
pay> jp
select applet
AID 7777777777
90 00 ok
/* Now applet "Wallet.bin" is ready to take your APDUs. */
/* first, validate PIN (it is 00 00 00 00) */
pay> ic 03 40 00 00 04
Enter 4 data bytes (hex):
00 00 00 00
90 00 ok
/* check the balance (default value = 0x20) */
pay> oc 03 30 00 00 01
1:20
90 00 ok
/* debit 0x10 */
pay> ic 03 20 00 00 01
Enter 1 data bytes (hex):
10
90 00 ok
/* check balance. 0x20 - 0x10 = 0x10. :) */
pay> oc 03 30 00 00 01
1:10
90 00 ok
/* unselect and unload the applet */
pay> jq
90 00 ok
pay> ju
90 00 ok
That's it!! You are welcome to modify Wallet.java and play with it. :)