[ main | schedule | cases | smartcard practicalities | project work | side-channel practicum ]
Below some information and pointers about the smartcards we will use. This should help you get started writing your first smartcard applets and host applications.
Smart cards communicate with the outside world by receiving commands and answering them. The protocol is described in the ISO7816-4 standard.
Java Card is a "dialect" of Java for programming such smart cards. A brief introduction to Java Card is available at JavaWorld. Lots more information is available from Sun's Java Card site. In particular, you can download the Java Card Development Kit there. The kit includes the Java Card API which contains classes you can use in your applet. Applets are compiled using a normal Java compiler and transformed to CAP files using a converter included in the kit. The protocol to download CAP files onto a smartcard is described in the Global Platform standard.
We will be using JCOP smartcards, the Java Card platform developed by IBM for which support has since moved to NXP. The JCOP4.1 cards we use support Java Card 2.2.1 and Global Platform 2.1.1. (To get an idea of the specs, these cards contain a SmartMX P5CT072 chip or something very similar to this. I couldn't find precise specs of the JCOP4.1, but they can do a bit more than the older JCOP31bio and other cards from JCOP family.)
Help -> Software Updates -> Find and Install -> Search for new features -> New Archived Sitein Eclipse.
The terminal (or host application) can also written in Java.
Obviously, you will need to install a recent version of the Java
2 SDK.
For easy communication with the Java Card applets on the card you should use the Smart Card I/O API.
Since the host application will need to do some cryptographic computations, you also need to install a cryptographic provider compatible with Sun's JCE. (The standard Java library does provide an API for cryptography, but the underlying engine lacks some of the important cryptographic primitives due to export restrictions.) The Bouncy Castle provider is recommended.
We have several types of smartcard readers available for use in this course:
Jar files should be copied to the jre\lib\ext folder
of the Java 2 SDK in use. The dll files should be copied to \Windows
or \Windows\System32.
|
API |
Web site |
Side |
Docs |
|---|---|---|---|
|
Java Card |
card |
||
|
Java |
terminal |
||
|
Bouncy Castle |
terminal |
||
|
Smart Card IO |
terminal |
Some example smartcard applications (applets and terminals) are available below.
A simple terminal to get the current balance of your Chipknip card. (Chipknip
is the Dutch national E-Purse.) Have a look at the Java file:
ChipknipTerminal.java.
This example demonstrates that your setup (reader and middleware
APIs) is ok. It's safe to use your real chipknip with this application.
This simple applet implements a calculator which operates on
signed shorts. Overflow is silent. The terminal sends a command for
every key on the keypad a user presses, the applet responds by
sending the number to put on the display (i.e. the terminal has no
state at all).
Have a look at the source files in CalcApplet.zip
and CalcTerminalSmartCardIO.zip.
This example demonstrates Java Card and Smart Card I/O programming.
This simple example shows how to do RSA keypair generation,
encryption and decryption in Java. Have a look at the source files
in: RSAKeyGen.java,
RSAEncrypt.java
and RSADecrypt.java.
The applet encrypts or decrypts blocks of data (length at most 128
bytes) using RSA keys which are generated off-card and uploaded to
the card. RSA keys have to be sent to the card first and then the
card needs to be "issued" before any encryption and
decryption is done. The files with private and public keys that the
host application requires/asks for can be generated with
RSAKeyGen.java
above. Have a look at the source files in CryptoApplet.java
and CryptoTerminalSmartCardIO.java.
Some additional (but mostly outdated) info is collected on the old version of this webpage.