Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | sriram-sundaresan |
View: | 227 times |
Download: | 0 times |
of 20
8/3/2019 563.11.1 Java Card Programming
1/20
563.11.1 Java CardProgramming: Overview
Presented by: Raman Sharykin
PISCES Group: Soumyadeb Mitra, Sruthi Bandhakavi, RagibHasan, Raman Sharikyn
University of IllinoisSpring 2006
8/3/2019 563.11.1 Java Card Programming
2/20
2
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 ofrestricted resources on card Game of Battleship: Using terminals
memory
8/3/2019 563.11.1 Java Card Programming
3/20
3
Java Card Features
Receives clock and power from terminal Three types of memory:
Random Access Memory (RAM)
Read-Only Memory (ROM) Erasable Read-Only Memory (EEPROM)
Restricted Resources Slow and simple microprocessor (8-bit)
RAM ~1Kb ROM ~64Kb EEPROM ~16-64Kb
Restricted Version of Java
8/3/2019 563.11.1 Java Card Programming
4/20
4
The use of Java Cards
SIM cards in cell phones Identity cards (government, health-care) Financial cards supporting online and
offline transactions Smart tickets for mass transit
8/3/2019 563.11.1 Java Card Programming
5/20
5
Java Card/Terminal System
APDU = Application Protocol Data Unit
An introduction to Java Card Technology
http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/8/3/2019 563.11.1 Java Card Programming
6/20
6
Java for Java Cards Features
Small primitive datatypes: boolean, byte,
short. One dimensionalarrays.
Object orientedfeatures: inheritance,virtual methods,dynamic objectcreation, overloading,scope.
Large primitive datatypes: long, double,
float. Characters, strings. Multidimensional
arrays. Dynamic class loading. Garbage collection. Threads. Object Cloning.
Supported Not Supported
8/3/2019 563.11.1 Java Card Programming
7/207
Developing a Java Card Applet
1. Write the Java source2. Compile your source3. Convert the class files into a Converted
Applet (CAP) file (binary representationof classes and interfaces)
4. Verify that the CAP is valid (structure,valid bytecode subset, inter-packagedependencies)
5. Install the CAP file
8/3/2019 563.11.1 Java Card Programming
8/208
Message-Passing Model
An introduction to Java Card Technology
http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/8/3/2019 563.11.1 Java Card Programming
9/209
APDU Structure
CLA, INS define the command P1, P2 parameters
Lc data field lentgh Le maximum response length SW1, SW2 response status
An introduction to Java Card Technology
http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/http://developers.sun.com/techtopics/mobility/javacard/articles/javacard1/8/3/2019 563.11.1 Java Card Programming
10/2010
Applet Structure
import javacard.framework.*...public class MyApplet extends Applet {
// Definitions of APDU-related instruction codes
...MyApplet() {...} // Constructor // Life-cycle methodsinstall() {...}select() {...}deselect() {...}process() {...}
// Private methods ...}
8/3/2019 563.11.1 Java Card Programming
11/2011
Important Methods: Install
install()called when a new applet is being installedpublic static void install
( byte[] bArray, short bOffset,byte bLength) {
new myApplet(null);
} Must call register() to let JCRE know that a
new applet has been installed.
8/3/2019 563.11.1 Java Card Programming
12/2012
Important Methods: Select/Deselect
select() when we want to use an applet is called when SELECT APDU is received
deselect() is called when another SELECT APDU is
received
8/3/2019 563.11.1 Java Card Programming
13/2013
Important Methods: Use
process() when an APDU is received and applet is
selected its method process is called to
process the APDU the selected applet parses the APDU and
perform whatever it needs to perform normally the body of process() method is a
big switch with code for each INS valuedefined
8/3/2019 563.11.1 Java Card Programming
14/2014
A Challenge in Java Card Programming
Java Cards have very restricted resources Limited Memory Limited Computing Power
Can we use terminals resources toovercome the restriction provided that theterminal is potentially untrusted?
At Penn we used terminals memory toovercome the first restriction
8/3/2019 563.11.1 Java Card Programming
15/2015
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
8/3/2019 563.11.1 Java Card Programming
16/2016
How to Prevent Cheating?
Before starting the game players assign randomnumbers to each cell, compute the hash of theresulting pair and exchange the tables of hashes
When a player shoots, the opponent providesnot only the contain of the requested cell, butalso the random number assigned to it and thehash
This way the other player can compute the hashof the delivered data and check if it coincideswith the value stored in the beginning.
8/3/2019 563.11.1 Java Card Programming
17/2017
Terminal Services Card
If we want to play the game on 10 by 10field we need 10*10*16*2 = 3200 byteswhen only ~600 is available
We used terminals memory to store thetables of random numbers and hashes To request a services from the terminal we
have two types of respond APDUs The result A request from the card to perform an
operation (store or retrieve data)
8/3/2019 563.11.1 Java Card Programming
18/2018
Terminals Structure
Java Card
Service Layer
Application
Terminal
request
request servicerequest1
servicerepond1 servicerequest2
servicerepond2 respond
respond
8/3/2019 563.11.1 Java Card Programming
19/2019
Data Flow and the Structure of an Applet
Terminal Java Card
Request
Service Request 1
Respond
process(apdu) {.....
switch (message){....
case Request:.....send ServiceRequest1;
break;.....
case ServiceResponde1:.....send ServiceRequest2;
break;.....
case ServiceResponde2:.....send Respond;
}
Service Respond 1
Service Request 2
Service Respond 2
8/3/2019 563.11.1 Java Card Programming
20/20
Future Work
The implementation stores its data on terminalwithout making sure that the server does notalternate the stored data (also it can just look atit!)
The structure of the code on card is complicatedwhen 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