563.11.1 Java Card Programming
563.11.1 Java Card Programming
Overview
Java Cards Java Card/Terminal System Features of Java for Java Cards compared to Java Java Card Applets: Developing Cycle Structure of Applets and Messages On approach to overcome the issue of restricted resources on card Game of Battleship: Using terminals memory
2
Restricted Resources
Slow and simple microprocessor (8-bit) RAM ~1Kb ROM ~64Kb EEPROM ~16-64Kb
3
Not Supported
Large primitive data types: long, double, float. Characters, strings. Multidimensional arrays. Dynamic class loading. Garbage collection. Threads. Object Cloning. 6
Message-Passing Model
APDU Structure
CLA, INS define the command P1, P2 parameters Lc data field lentgh Le maximum response length SW1, SW2 response status
9
Applet Structure
import javacard.framework.* ... public class MyApplet extends Applet { // Definitions of APDU-related instruction codes ... MyApplet() {...} // Constructor // Life-cycle methods install() {...} select() {...} deselect() {...} process() {...} // Private methods ... }
10
11
deselect()
is called when another SELECT APDU is received
12
13
Can we use terminals resources to overcome the restriction provided that the terminal is potentially untrusted? At Penn we used terminals memory to overcome the first restriction
14
Game of Battleship
Playing Field is n by n Ships are vertical or horizontal and of a fixed length Players shoot in turns The winner is the player who has eliminated the ships of the opponent first
15
Terminals Structure
Terminal Application
request respond
Service Layer
request service service service repond1 service repond2 respond request1 request2
Java Card
18
Java Card
Service Request 1
process(apdu){ ..... switch(message){ .... caseRequest: ..... sendServiceRequest1; break; ..... caseServiceResponde1: ..... send ServiceRequest2; break; ..... case ServiceResponde2: ..... send Respond; }
19
Future Work
The implementation stores its data on terminal without making sure that the server does not alternate the stored data (also it can just look at it!) The structure of the code on card is complicated when we need Service Requests
inside a function call inside a loop
It would be interesting to know if we can use the computational power of the terminal as well
20