PC as Smart Card Terminal

Java Smart Cards
FAQ
Smart Card Links

[Home Page Entry: Smart Cards and Java Card

last modified: 3. Dec. 2006
Copyright © 2003-2006 Wolfgang Rankl, Munich
Impressum und rechtliche Hinweise

Content

Examples for Java on PC

PC as Smart Card Terminal

Simple Applet

Data transmission by means of OCF and PC/SC to a smart card

File read and write with OCF

File Searcher

Command Searcher

Reading a Random Number from a Smart Card

Reading abbreviated dialling numbers and short messages from a SIM

Controlling a Mobile Phone from a PC Java Applet (SMS Transceiver)

EEPROM Life Time Test

Examples for Java on PC

The following paragraphs contains a set of source text examples for Java on PCs and in connection with smart cards.

NOTE: The execution of one of the following source texts can kill your smart card under some circumstances. I don't take over any responsibility for the execution of one of the following source texts. Therefore the serious-common advice: in the case of doubt only have a look at the source code and use for all experiments with smart cards only trial worthless test cards.

The technical background why one with the execution one of the following source texts the smart card to make useless can is multilayered. Some of the following programs start a PIN verification as the first to get some files access rights. If one has now forgotten those PINs in the source code accordingly too change, then depending upon application of smart cards of the error counter the PIN ran off after three program executions. When other deterring example in this connection could for example the command scanner depending upon operating system a not documented instruction of the smart card calls, which the deletion of the entire EEPROM of the smart card has as a consequence (DELETES COMPLETION). So improbably this sounds, it to me already twice passed, however with worthless test cards.

Simple Applet

The following program is a very simple Java applet for PC that I used only for the configuration (new) of a development environment. Strictly speaking it is a somewhat developed "Hello World".

Simple Applet for Java on PC (4. Feb. 2003 - V 3)

Data transmission by means of OCF and PC/SC to a smart card

The following source text shows the connection of a map terminal (e.g. chip drive of ToWiToKo) by means of OCF and PC/SC to a PC. Thus it is possible to establish a communication with a smart card from a programming language such as Java. The example shows a very simple variant with the drivers of the company ToWiToKo. It can be extended still in many places.
This program is the basis for all following Java of programs for data exchange with smart cards.

Terminal connection with OCF and PC/SC (10. July 2003 - V 11)

File read and write with OCF

The following source text shows reads and writes a EFs of the structure transparency. The program is based on the aforementioned OCF connection of a terminal..

File write and read (15. Dez. 2003 - V 7)

File Searcher

The following source text shows the systematic scanning of a DFs on a SIM after GSM 11,11 after all existing EFs. The program is based on the above OCF connection of a terminal. The operational principle is thereby the selection attempt by means of all possible 2 byte for FIDs within a DFs. A detailed description in addition is in the Smart Card Handbook.

File Searcher (18. Dez. 2003 - V 8)

Command Searcher

The following source text shows the systematic determining of the supported commands by a smart card. On the basis of the class and instruction byte the programm makes also a decoding of the recognized commands. A detailed description of the principles of this programm can be found in the Smart Card Handbook. The programm ScanCmds (2. Sept. 2004 - V 5) consists of 3 parts:

ScanCmds
ICC
Commands

Reading random numbers from a smart card

The following source text shows a reading from random numbers by means of GET CHALLENGE of a smart card. The received random numbers could then be used with a spread-sheet to analyse their characteristics.

Reading Random Numbers (9. Dez. 2003 - V 5)

Reading abbreviated dialling numbers and short messages from a SIM

The following source text shows the reading and the subsequently decoding of the abbreviated dialling numbers (ADN) and the short messages (SMS) after a successful verification of the PIN. The program shows descriptive and (hopefully) comprehensibly the decoding of abbreviated dialling numbers and short messages records.

Reading data from a SIM (18. Dez. 2003 - V 5)

Controlling a mobile phone from a PC Java applet (SMS Transceiver)

The following source code shows the controlling of a mobile telephone by a Java program on a PC that over a serial connection with the mobile telephone communicates. The program has to do few with smart cards, but possesses some good routines for sending, receiving, codes and decodes from short messages (SMS), which can be use very well in connection with smart cards. I use a similar program for the world-wide remote control of devices over SMS.

SMS Transceiver

EEPROM Life Time Test

The following source code ist a typical test of the EEPROM life time of a smart card. The test is done by first writing specific pattern into a whole EEPROM page and second verifying this pattern. The two typical patterns for a whole page are 0x55 and 0xAA. This causes the need for a page deletion which is necessary to get realistic value for the EEPROM life time. This OCF based appelt have a lot of different parameters and can be used for a quite big bandwith of EEPROM life time tests.

This diagramm shows the run time in seconds of the test vs. the number of write-erase-cycles of a EEPROM page on a typical smart card microcontroller.

EEPROMTest (25. July 2004 - V 2)
ICC