SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
jCardSim – Java Card is simple!
Mikhail Dudarev, CTO of jCardSim.org
JavaOne Moscow, 2013
Agenda
•  Brief history of Java Card
•  Basics standards
•  How is that works?
•  Developer Tools
•  Writing our first real life Java Card application
•  NFC and Java Card
•  jCardSim: real story of real open source project
Birth of Java Card
Sun Microsystems announces Java Card API
MOUNTAIN VIEW, Calif.--(BUSINESS WIRE)--Oct. 29, 1996--
Sun Microsystems, Inc. today announced completion of the Java(TM) Card application
programming interface (API) specification.
The Java Card specification will bring the power of Java to hundreds of millions of
smart cards worldwide.
Quotes by Gemplus, IBM, Integrity Arts, OKI Electric Industry Co., NTT, Philips,
Schlumberger, Texas Instruments, Toshiba, Visa International
First steps
February 2, 1997, the first Java card was received from the factory
June, 2005
Sun Microsystems, Inc. announces that 1 billion Java Card cards
have been sold.
Standardization
12 February, 1997
Leading Smart Card Manufacturers Announce Formation of Java Card Forum -
Industry initiative endorsed by Sun, creator of the Java™ Card API standard
20 October, 1997
Public review on version 2.0 of the Java Card specification
March, 1999
Java Card version 2.1 announced. There are three specifications: Java Card API,
Java Card Runtime Environment, Java Card Virtual Machine
May, 2006
Java Card version 2.2.2 announced. Adds contactless capabilities and biometry
support for smart card chip manufacturers
New Age
March, 2008
Java Card version 3.0 announced. Classic and Connected Editions.
•  Classic Edition is an evolution of the Java Card 2.2.2
•  Connected Edition is a revolution technology for high-end smart cards
Today
•  More than 10 billion Java technology based smart cards have been deployed
•  NFC wallets requires Java Card
•  Secure M2M Solutions
Basic Standards
•  ISO 7816
•  ISO 14443
•  Java Card Specification
•  Global Platform
ISO 7816 standards
•  7816-1 – Physical characteristics
•  7816-2 – Dimension and locations of contacts
•  7816-3 – Electrical interface and transmission protocols (T0/T1)
•  7816-4 – Organization, security and commands for interchange
ISO 14443 standards (Contactless)
•  14443-1 – Physical characteristics
•  14443-2 – Radio frequency power and signal interface
•  14443-3 – Initialization and anticollision
•  14443-4 – Transmission protocol
Must know facts about smartcards and ISO-standards
•  Smartcard – small secure computer on chip
•  CPU
•  Crypto Processor
•  ROM
•  EEPROM
•  FLASH
•  Smart card requires terminal (contact/contactless). It provides supply and clock.
•  Communication protocol is command-response based.
Client
Application
Card
Application
Command APDU
Response APDU
APDU Structure (1/2)
Command APDU
Field Length Description
CLA 1 Class of instruction
INS 1 Instruction code
P1 1 Instruction parameter 1
P2 1 Instruction parameter 2
Lc 1 or 3 Number of bytes present in the data field
of the command
Data Lc String of bytes sent in the data field of the
command
Le 1 or 3 Maximum number of bytes expected in
the data field of the response to the
command
APDU Structure (2/2)
Response APDU
Field Length Description
Data Lr String of bytes received in the data field
of the response
SW1 1 Command processing status
SW2 1 Command processing qualifier
The favorite response code is 0x9000 – SW_NO_ERROR
Java Card Classic Architecture
Card Management
Security Policy/
Global Platform API
Issuer/Vertical Market Defined API
Applet 1 Applet 2
Native Operation System
…
Java CardTM Runtime
Environment
Java CardTM API
Java CardTM Virtual Machine
Native Operation System
•  File System Operations
•  Crypto Algorithms
•  Data integrity
•  Memory/Transactions management
•  Hardware Interfaces
•  Access Controller
Java Card Classic Virtual Machine (version 3.0.4) 1/3
Split VM Architecture
•  Off-card
•  Class loading, linking and name resolution
•  Bytecode verification, optimization and conversion
•  On-card
•  Bytecode execution and security enforcement
Class
files Converter
Cap
file
Interpreter
CardComputer
JCVM
Java Card Classic Virtual Machine (version 3.0.4) 2/3
•  Unsupported Features
•  Dynamic Class Loading
•  Security Manager
•  Finalization
•  Threads
•  Cloning
•  Access Control in Java Packages
•  Typesafe Enums
•  Enhanced for Loop
•  Varargs
•  Runtime Visible Metadata (Annotations)
•  Assertions
•  Unsupported Types
The Java Card platform does not support types char, double, float and long. It also
does not support arrays of more than one dimension.
Java Card Classic Virtual Machine (version 3.0.4) 3/3
•  Supported Features
•  Packages
•  Dynamic Object Creation
•  Virtual Methods
•  Interfaces
•  Exceptions
•  Generics
•  Static Import
•  Runtime Invisible Metadata (Annotations)
•  Runtime Visible Metadata (Annotations)
•  Assertions
•  GC (optional)
•  Supported Types
Java programming language types boolean, byte, short are supported. Objects (class
instances and single-dimensional arrays) are also supported.
The int keyword and 32-bit integer data support is optional.
Java Card Runtime Environment (version 3.0.4)
•  Card resource management
•  Communications
•  Applet execution
•  Applet security (firewall)
Firewall
•  Provides isolation between applications
•  Operates dynamically at run-time
•  Isolation is at the package level
•  Applets can explicitly share objects (javacard.framework.Shareable)
Java Card API (version 3.0.4)
•  java.io
•  java.lang
•  java.rmi
•  javacard.framework
•  javacard.security
•  javacardx.annotations
•  javacardx.apdu
•  javacardx.biometry
•  javacardx.crypto
•  javacardx.external
•  javacardx.framework.math
•  javacardx.framework.string
•  javacardx.framework.tlv
•  javacardx.framework.util
•  javacardx.framework.util.intx
Global Platform
Global Platform Card Specification is a secure, dynamic card and application
management specification
•  Security Domains
•  Secure channels
•  Application Management
•  Card Management
http://www.globalplatform.org/
How is that works ?
•  Application Model
•  Development Workflow
Application Model
•  Java Card Application is always a subclass of the javacard.framework.Applet
class
•  Each applet has unique id - AID
•  Only one active applet at a time
•  Several applet can be selected at the time but can not work in parallel
•  Applet class provides the following entry points:
•  install(..)
•  register(..)
•  deselect(..)
•  select(..)
•  selectingApplet(..)
•  process(..)
•  getShareableInterfaceObject(..)
Development Workflow
Source
Java
Compiler
Class
files
Java VM
Java Card
Converter
CAP file
Java Card
C-JCRE
Simulator
JCWDE jCardSim
Developer Tools
•  Java Card Development Kit
•  GPShell
•  JCOP Tools from NXP (IBM)
•  jCardSim
jCardSim (1/3)
Java CardTM Runtime
Environment Implementation
Java CardTM API Implementaion
Java Virtual Machine
jCardSim is an open source simulator implements Java Card, v.2.2.1
•  javacard.framework
•  javacard.security
•  javacardx.crypto
jCardSim (2/3)
Key Features
•  Rapid application prototyping
•  Ease of writing Unit-tests
•  Emulation of Java Card Terminal, ability to use javax.smartcardio
•  APDU scripting (scripts are compatible with apdutool from Java Card
Development Kit)
•  Ease of verification tests creation
jCardSim (3/3)
What is the difference from JCWDE?
•  Implementation of javacard.security
One of the main differences is the implementation of javacard.security: current
version is analogous with NXP JCOP 31/36k card. For example, in jCardSim we
have support an on-card KeyPair.ALG_EC_F2M/ALG_RSA_CRT-key generation
•  Simulator API
jCardSim has simple and usable API, which allows you to work with simulator like
with real Java Card using javax.smartcardio
•  Cross-platform
jCardSim completely written in Java and can therefore be used at all platforms
which supports Java (Windows, Linux, MacOS, etc)
Writing our first real life
Java Card application
•  PetID – ePassport for home pets
•  Concepts
•  Architecture
•  Implementation Notes
•  Protocol
•  Demo
PetID – ePassport for home pets
Nowadays, one of the main applications of Java Card is electronic identity cards
(i.e. ePassport)
Are pets worse than men?
Lets create Java Card application – ePassport for Pets
Concepts
•  The application must provide the ability to store, receive and transmit
information about a pet.
•  Must provide protection against modification of the data from a malicious
person.
Information to be stored in ePassport:
•  Pet’s name
•  Date of birth
•  Sex
•  Breed
Architecture
•  Client Application – JavaFX application with the following functionality:
•  ePassport application initialization
•  Store pet’s information
•  Read pet’s information
•  Java Card Application
•  Supported Commands
•  Personalize
•  Store Pet Info
•  Read Pet Info
Implementation Notes
•  Way to interact with the Java Card – javax.smartcardio
•  Version of Java Card API - 2.2.1
•  Protection against modification (digital signature)
•  Elliptic curve cryptography
•  Issuer Public Key stored in Personalize phase
•  Store commands data is signed
Protocol (1/4)
Field Value
CLA AA
INS 0
P1 0
P2 0
Lc Issuer public key length
Data Issuer public key
PERSONALIZE
Protocol (2/4)
Field Value
CLA AA
INS 1
P1 0
P2 0
Lc Pet info data length
Data Pet info data
STORE_PET_INFO
Protocol (3/4)
Tag Value
01 Pet name
02 Date of birth
03 Breed
04 Sex
05 Signature
PET_INFO DATA (TLV-encoded)
Protocol (4/4)
Field Value
CLA AA
INS 2
P1 0
P2 0
LOAD_PET_INFO
CODING
Source Applet (1/2)
public class PetIDApplet extends Applet {
private final static byte BASE_CLA = (byte) 0xAA;
private final static byte PERSONALIZE_INS = 0x00;
private final static byte STORE_PET_INFO_INS = 0x01;
private final static byte LOAD_PET_INFO_INS = 0x02;
private ECPublicKey issuerPublicKey;
private byte[] petInfoData;
public PetIDApplet () {
petInfoData= new byte[4086];
register();
}
public static void install(byte[] bArray, short bOffset, byte bLength) throws
ISOException {
new PetIDApplet ();
}
Source Applet (2/2)
public void process(APDU apdu) throws ISOException {
if (selectingApplet()) return;
byte[] buffer = apdu.getBuffer();
if (buffer[ISO7816.OFFSET_CLA] != BASE_CLA) {
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
byte ins = buffer[ISO7816.OFFSET_INS];
switch (ins) {
case PERSONALIZE_INS:
personalize(apdu);
break;
case STORE_PET_INFO_INS:
storePetInfo(apdu);
break;
case LOAD_PET_INFO_INS:
loadPetInfo(apdu);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
Source PetInfo
public class PetInfo {
// tlv types
private final static byte NAME_TAG = 1;
private final static byte BIRTH_TAG = 2;
private final static byte BREED_TAG = 3;
private final static byte SEX_TAG = 4;
private final static byte SIGNATURE_TAG = 5;
//
private String name;
private boolean sex;
private String breed;
private Calendar dateOfBirth;
…
}
Source Unit-test (1/3)
System.setProperty("com.licel.jcardsim.smartcardio.applet.0.AID", TEST_APPLET_AID);
System.setProperty("com.licel.jcardsim.smartcardio.applet.0.Class",
“samples.PetIDApplet");
if (Security.getProvider("jCardSim") == null) {
JCardSimProvider provider = new JCardSimProvider();
Security.addProvider(provider);
}
TerminalFactory tf = TerminalFactory.getInstance("jCardSim", null);
CardTerminals ct = tf.terminals();
List<CardTerminal> list = ct.list();
CardTerminal jcsTerminal = null;
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getName().equals("jCardSim.Terminal")) {
jcsTerminal = list.get(i);
break;
}
}
Source Unit-test (2/3)
// create applet data = aid len (byte), aid bytes, params lenth (byte), param
byte[] aidBytes = Hex.decode(TEST_APPLET_AID);
CommandAPDU createApplet = new CommandAPDU(0x80, 0xb8, 0, 0);
ResponseAPDU response = jcsChannel.transmit(createApplet);
assertEquals(response.getSW(), 0x9000);
assertEquals(true, Arrays.equals(response.getData(), aidBytes));
// select applet
CommandAPDU selectApplet = new CommandAPDU(ISO7816.CLA_ISO7816, ISO7816.INS_SELECT, 0,
0, Hex.decode(TEST_APPLET_AID));
response = jcsChannel.transmit(selectApplet);
assertEquals(response.getSW(), 0x9000);
// create issuer keys & PERSONALIZE
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", "BC");
ECGenParameterSpec ecsp = new ECGenParameterSpec(“sect113r1”);
kpg.initialize(ecsp);
KeyPair kp = kpg.generateKeyPair();
CommandAPDU personalizeApplet = new CommandAPDU(0xAA,0, 0, 0,
kp.getPublic().getEncoded());
response = jcsChannel.transmit(personalizeApplet);
assertEquals(response.getSW(), 0x9000);
Source Unit-test (3/3)
// store pet info
PetInfo pet = new PetInfo(“Leon”, “Cat”, “male”, “28.01.2005”);
CommandAPDU storePetInfo = new CommandAPDU(0xAA, 1, 0, 0,
pet.getEncoded(kp.getPrivate()));
response = jcsChannel.transmit(storePetInfo);
assertEquals(response.getSW(), 0x9000);
// load pet info
CommandAPDU loadPetInfo = new CommandAPDU(0xAA, 2, 0, 0);
response = jcsChannel.transmit(loadPetInfo);
assertEquals(response.getSW(), 0x9000);
PetInfo test = new PetInfo(response.getData());
assertEquals(pet, test);
DEMO
NFC and Java Card
•  NFC Brief Overview
•  Secure Element
NFC
NFC - A new radio communication interface for mobile phones
•  Range 2 – 4 cm
•  13.56 MHz
•  Approx. 100 million devices shipped in 2012
•  Modes
•  Tag read/write
•  P2P
•  Card emulation (”secure NFC”)
Secure NFC
NFC API Phone OS
NFC
Controller
SE
NFC Antenna
Secure Element
Java Card
Application
jCardSim Facts
•  The initial project team consisted of three developers
•  First public release has been announced in December
2011
•  In June 2012 the official site, jcardsim.org, has been
started and available in following languages: English,
Russian, Spanish
•  Main audience of the project is students which are
learning Java Card and professional Java Card developers
jCardSim RoadMap
2Q 2013
•  Shareable Interface Support
•  Service Framework Support
•  Multiple Logical Channels
3Q 2013
•  Application Firewall Support
•  Basic Global Platform functionality
THANKS!
Email: jcardsim@licel.ru
Twitter: @MikhailDudarev
WWW: jcardsim.org

Mais conteúdo relacionado

Mais procurados

Pertemuan 1 Pemodelan Perangkat Lunak
Pertemuan 1 Pemodelan Perangkat LunakPertemuan 1 Pemodelan Perangkat Lunak
Pertemuan 1 Pemodelan Perangkat LunakDisma Ariyanti W
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaGlenn Guden
 
[PBO] Pertemuan 10 - Exception & Error Handling
[PBO] Pertemuan 10 - Exception & Error Handling[PBO] Pertemuan 10 - Exception & Error Handling
[PBO] Pertemuan 10 - Exception & Error Handlingrizki adam kurniawan
 
Smart attendance system using facial recognition
Smart attendance system using facial recognitionSmart attendance system using facial recognition
Smart attendance system using facial recognitionVigneshLakshmanan8
 
Online grocery store
Online grocery storeOnline grocery store
Online grocery storeKavita Sharma
 
History and Versions of Java Programming.pdf
History and Versions of Java Programming.pdfHistory and Versions of Java Programming.pdf
History and Versions of Java Programming.pdfJavaTpoint.Com
 
Rekayasa Perangkat Lunak
Rekayasa Perangkat LunakRekayasa Perangkat Lunak
Rekayasa Perangkat LunakYudi Purwanto
 
Student portal system application -Project Book
Student portal system application -Project BookStudent portal system application -Project Book
Student portal system application -Project BookS.M. Fazla Rabbi
 
OOP - Java is pass-by-value
OOP - Java is pass-by-valueOOP - Java is pass-by-value
OOP - Java is pass-by-valueMudasir Qazi
 

Mais procurados (20)

Pengenalan Pemrograman Java
Pengenalan Pemrograman JavaPengenalan Pemrograman Java
Pengenalan Pemrograman Java
 
Pertemuan 1 Pemodelan Perangkat Lunak
Pertemuan 1 Pemodelan Perangkat LunakPertemuan 1 Pemodelan Perangkat Lunak
Pertemuan 1 Pemodelan Perangkat Lunak
 
Perkuliahan 01 Teknik kompilasi
Perkuliahan 01 Teknik kompilasiPerkuliahan 01 Teknik kompilasi
Perkuliahan 01 Teknik kompilasi
 
Java basic
Java basicJava basic
Java basic
 
String Dan Array
String Dan ArrayString Dan Array
String Dan Array
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 
[PBO] Pertemuan 10 - Exception & Error Handling
[PBO] Pertemuan 10 - Exception & Error Handling[PBO] Pertemuan 10 - Exception & Error Handling
[PBO] Pertemuan 10 - Exception & Error Handling
 
Smart attendance system using facial recognition
Smart attendance system using facial recognitionSmart attendance system using facial recognition
Smart attendance system using facial recognition
 
Online grocery store
Online grocery storeOnline grocery store
Online grocery store
 
Etika Komputer
Etika Komputer Etika Komputer
Etika Komputer
 
Weather Display app
Weather Display appWeather Display app
Weather Display app
 
History and Versions of Java Programming.pdf
History and Versions of Java Programming.pdfHistory and Versions of Java Programming.pdf
History and Versions of Java Programming.pdf
 
Rekayasa Perangkat Lunak
Rekayasa Perangkat LunakRekayasa Perangkat Lunak
Rekayasa Perangkat Lunak
 
Prototyping
PrototypingPrototyping
Prototyping
 
Student portal system application -Project Book
Student portal system application -Project BookStudent portal system application -Project Book
Student portal system application -Project Book
 
what is java?
  what is java?  what is java?
what is java?
 
OOP - Java is pass-by-value
OOP - Java is pass-by-valueOOP - Java is pass-by-value
OOP - Java is pass-by-value
 
Major project srs
Major project srsMajor project srs
Major project srs
 
Defensive Programming
Defensive ProgrammingDefensive Programming
Defensive Programming
 
Bahan ajar TIK
Bahan ajar TIKBahan ajar TIK
Bahan ajar TIK
 

Destaque

Technical Overview of Java Card
Technical Overview of Java CardTechnical Overview of Java Card
Technical Overview of Java CardAnshuman Sinha
 
VISIONFC - an NFC Forum event: NFC Payment & beyond presentations
VISIONFC - an NFC Forum event: NFC Payment & beyond presentationsVISIONFC - an NFC Forum event: NFC Payment & beyond presentations
VISIONFC - an NFC Forum event: NFC Payment & beyond presentationsNFC Forum
 
Standardization and connectivity of smart metering solutions
Standardization and connectivity of smart metering solutionsStandardization and connectivity of smart metering solutions
Standardization and connectivity of smart metering solutionsLandis+Gyr
 
Echelon Smart Metering - Grid Analytics
Echelon Smart Metering - Grid AnalyticsEchelon Smart Metering - Grid Analytics
Echelon Smart Metering - Grid AnalyticsEchelon Corporation
 
NFC and the Web
NFC and the WebNFC and the Web
NFC and the WebNFC Forum
 
SaaS Springboard API
SaaS Springboard APISaaS Springboard API
SaaS Springboard APIRob Bertholf
 
NFC, RFID, beacons and proximity technology in retail
NFC, RFID, beacons and proximity technology in retailNFC, RFID, beacons and proximity technology in retail
NFC, RFID, beacons and proximity technology in retailCraig Smith
 
Building Cloud Native Software
Building Cloud Native SoftwareBuilding Cloud Native Software
Building Cloud Native SoftwarePaul Fremantle
 
Food Importing & Re-Expor Recuirments in the UAE
Food Importing & Re-Expor Recuirments in the UAEFood Importing & Re-Expor Recuirments in the UAE
Food Importing & Re-Expor Recuirments in the UAEDubaiExports
 
Smart grid communications
Smart grid communicationsSmart grid communications
Smart grid communicationssrikanth reddy
 
Apple NFC smartphone
Apple NFC smartphoneApple NFC smartphone
Apple NFC smartphoneacardoso78
 
Embedded Systems Security News Feb 2011
Embedded Systems Security News Feb 2011Embedded Systems Security News Feb 2011
Embedded Systems Security News Feb 2011AurMiana
 
EE Reports Metering 101 Guide: Benefits and Applications of Submetering
EE Reports Metering 101 Guide: Benefits and Applications of SubmeteringEE Reports Metering 101 Guide: Benefits and Applications of Submetering
EE Reports Metering 101 Guide: Benefits and Applications of SubmeteringEEReports.com
 
Contextually Relevant Retail APIs for Dynamic Insights & Experiences
Contextually Relevant Retail APIs for Dynamic Insights & ExperiencesContextually Relevant Retail APIs for Dynamic Insights & Experiences
Contextually Relevant Retail APIs for Dynamic Insights & ExperiencesJason Lobel
 
Is there such a thing as smart retail
Is there such a thing as smart retailIs there such a thing as smart retail
Is there such a thing as smart retailPierre Metivier
 
NFC Forum Tap Into NFC Developer Event
NFC Forum Tap Into NFC Developer EventNFC Forum Tap Into NFC Developer Event
NFC Forum Tap Into NFC Developer EventNFC Forum
 

Destaque (20)

Technical Overview of Java Card
Technical Overview of Java CardTechnical Overview of Java Card
Technical Overview of Java Card
 
Nokia 700 & Nokia 701 - Try something new!
Nokia 700 & Nokia 701 - Try something new!Nokia 700 & Nokia 701 - Try something new!
Nokia 700 & Nokia 701 - Try something new!
 
VISIONFC - an NFC Forum event: NFC Payment & beyond presentations
VISIONFC - an NFC Forum event: NFC Payment & beyond presentationsVISIONFC - an NFC Forum event: NFC Payment & beyond presentations
VISIONFC - an NFC Forum event: NFC Payment & beyond presentations
 
Standardization and connectivity of smart metering solutions
Standardization and connectivity of smart metering solutionsStandardization and connectivity of smart metering solutions
Standardization and connectivity of smart metering solutions
 
Echelon Smart Metering - Grid Analytics
Echelon Smart Metering - Grid AnalyticsEchelon Smart Metering - Grid Analytics
Echelon Smart Metering - Grid Analytics
 
NFC and the Web
NFC and the WebNFC and the Web
NFC and the Web
 
SaaS Springboard API
SaaS Springboard APISaaS Springboard API
SaaS Springboard API
 
NFC, RFID, beacons and proximity technology in retail
NFC, RFID, beacons and proximity technology in retailNFC, RFID, beacons and proximity technology in retail
NFC, RFID, beacons and proximity technology in retail
 
Building Cloud Native Software
Building Cloud Native SoftwareBuilding Cloud Native Software
Building Cloud Native Software
 
Food Importing & Re-Expor Recuirments in the UAE
Food Importing & Re-Expor Recuirments in the UAEFood Importing & Re-Expor Recuirments in the UAE
Food Importing & Re-Expor Recuirments in the UAE
 
Smart grid communications
Smart grid communicationsSmart grid communications
Smart grid communications
 
Java card technology
Java card technologyJava card technology
Java card technology
 
Apple NFC smartphone
Apple NFC smartphoneApple NFC smartphone
Apple NFC smartphone
 
Thinaire deck redux
Thinaire deck reduxThinaire deck redux
Thinaire deck redux
 
Embedded Systems Security News Feb 2011
Embedded Systems Security News Feb 2011Embedded Systems Security News Feb 2011
Embedded Systems Security News Feb 2011
 
Making Waves with NFC 2011
Making Waves with NFC 2011Making Waves with NFC 2011
Making Waves with NFC 2011
 
EE Reports Metering 101 Guide: Benefits and Applications of Submetering
EE Reports Metering 101 Guide: Benefits and Applications of SubmeteringEE Reports Metering 101 Guide: Benefits and Applications of Submetering
EE Reports Metering 101 Guide: Benefits and Applications of Submetering
 
Contextually Relevant Retail APIs for Dynamic Insights & Experiences
Contextually Relevant Retail APIs for Dynamic Insights & ExperiencesContextually Relevant Retail APIs for Dynamic Insights & Experiences
Contextually Relevant Retail APIs for Dynamic Insights & Experiences
 
Is there such a thing as smart retail
Is there such a thing as smart retailIs there such a thing as smart retail
Is there such a thing as smart retail
 
NFC Forum Tap Into NFC Developer Event
NFC Forum Tap Into NFC Developer EventNFC Forum Tap Into NFC Developer Event
NFC Forum Tap Into NFC Developer Event
 

Semelhante a Java Card is simple

Eric java card-basics-140314
Eric java card-basics-140314Eric java card-basics-140314
Eric java card-basics-140314Eric Vétillard
 
Tu dresden 290404_jcop
Tu dresden 290404_jcopTu dresden 290404_jcop
Tu dresden 290404_jcoppri18saini
 
jCardSim - development platform for Java Card Applications
jCardSim - development platform for Java Card ApplicationsjCardSim - development platform for Java Card Applications
jCardSim - development platform for Java Card ApplicationsMikhail Dudarev
 
JavaCard development Quickstart
JavaCard development QuickstartJavaCard development Quickstart
JavaCard development QuickstartMartin Paljak
 
Java Card Technology: The Foundations of NFC
Java Card Technology: The Foundations of NFCJava Card Technology: The Foundations of NFC
Java Card Technology: The Foundations of NFCEric Vétillard
 
Java card technology
Java card technologyJava card technology
Java card technologyAmol Kamble
 
Game Development for Nokia Asha Devices with Java ME #1
Game Development for Nokia Asha Devices with Java ME #1Game Development for Nokia Asha Devices with Java ME #1
Game Development for Nokia Asha Devices with Java ME #1Marlon Luz
 
PlaySIM Project Java One 2009
PlaySIM Project Java One 2009PlaySIM Project Java One 2009
PlaySIM Project Java One 2009Sebastian Hans
 
Security applications with Java Card
Security applications with Java CardSecurity applications with Java Card
Security applications with Java CardJulien SIMON
 
Nokia Asha App Development - Part 1
Nokia Asha App Development - Part 1Nokia Asha App Development - Part 1
Nokia Asha App Development - Part 1Marlon Luz
 
Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Raymond Roestenburg
 
Apache Geode Meetup, Cork, Ireland at CIT
Apache Geode Meetup, Cork, Ireland at CITApache Geode Meetup, Cork, Ireland at CIT
Apache Geode Meetup, Cork, Ireland at CITApache Geode
 
Study of Java Card and its Application
Study of Java Card and its ApplicationStudy of Java Card and its Application
Study of Java Card and its Applicationeditor1knowledgecuddle
 
Smart Cards, ePassports, and open source
Smart Cards, ePassports, and open sourceSmart Cards, ePassports, and open source
Smart Cards, ePassports, and open sourceMartijn Oostdijk
 
java-card20232024999999999999999999999999999999999999999999999999999999999999...
java-card20232024999999999999999999999999999999999999999999999999999999999999...java-card20232024999999999999999999999999999999999999999999999999999999999999...
java-card20232024999999999999999999999999999999999999999999999999999999999999...ouahibakellou
 

Semelhante a Java Card is simple (20)

Eric java card-basics-140314
Eric java card-basics-140314Eric java card-basics-140314
Eric java card-basics-140314
 
Tu dresden 290404_jcop
Tu dresden 290404_jcopTu dresden 290404_jcop
Tu dresden 290404_jcop
 
Java card technology
Java card technologyJava card technology
Java card technology
 
jCardSim - development platform for Java Card Applications
jCardSim - development platform for Java Card ApplicationsjCardSim - development platform for Java Card Applications
jCardSim - development platform for Java Card Applications
 
JavaCard development Quickstart
JavaCard development QuickstartJavaCard development Quickstart
JavaCard development Quickstart
 
Java card
Java card Java card
Java card
 
Javacard
Javacard Javacard
Javacard
 
Java Card Technology: The Foundations of NFC
Java Card Technology: The Foundations of NFCJava Card Technology: The Foundations of NFC
Java Card Technology: The Foundations of NFC
 
Java card technology
Java card technologyJava card technology
Java card technology
 
Game Development for Nokia Asha Devices with Java ME #1
Game Development for Nokia Asha Devices with Java ME #1Game Development for Nokia Asha Devices with Java ME #1
Game Development for Nokia Asha Devices with Java ME #1
 
PlaySIM Project Java One 2009
PlaySIM Project Java One 2009PlaySIM Project Java One 2009
PlaySIM Project Java One 2009
 
Security applications with Java Card
Security applications with Java CardSecurity applications with Java Card
Security applications with Java Card
 
JavaAndNetBeans.pdf
JavaAndNetBeans.pdfJavaAndNetBeans.pdf
JavaAndNetBeans.pdf
 
Nokia Asha App Development - Part 1
Nokia Asha App Development - Part 1Nokia Asha App Development - Part 1
Nokia Asha App Development - Part 1
 
Javacardtech
JavacardtechJavacardtech
Javacardtech
 
Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011
 
Apache Geode Meetup, Cork, Ireland at CIT
Apache Geode Meetup, Cork, Ireland at CITApache Geode Meetup, Cork, Ireland at CIT
Apache Geode Meetup, Cork, Ireland at CIT
 
Study of Java Card and its Application
Study of Java Card and its ApplicationStudy of Java Card and its Application
Study of Java Card and its Application
 
Smart Cards, ePassports, and open source
Smart Cards, ePassports, and open sourceSmart Cards, ePassports, and open source
Smart Cards, ePassports, and open source
 
java-card20232024999999999999999999999999999999999999999999999999999999999999...
java-card20232024999999999999999999999999999999999999999999999999999999999999...java-card20232024999999999999999999999999999999999999999999999999999999999999...
java-card20232024999999999999999999999999999999999999999999999999999999999999...
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 

Último (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 

Java Card is simple

  • 1. jCardSim – Java Card is simple! Mikhail Dudarev, CTO of jCardSim.org JavaOne Moscow, 2013
  • 2. Agenda •  Brief history of Java Card •  Basics standards •  How is that works? •  Developer Tools •  Writing our first real life Java Card application •  NFC and Java Card •  jCardSim: real story of real open source project
  • 3. Birth of Java Card Sun Microsystems announces Java Card API MOUNTAIN VIEW, Calif.--(BUSINESS WIRE)--Oct. 29, 1996-- Sun Microsystems, Inc. today announced completion of the Java(TM) Card application programming interface (API) specification. The Java Card specification will bring the power of Java to hundreds of millions of smart cards worldwide. Quotes by Gemplus, IBM, Integrity Arts, OKI Electric Industry Co., NTT, Philips, Schlumberger, Texas Instruments, Toshiba, Visa International
  • 4. First steps February 2, 1997, the first Java card was received from the factory June, 2005 Sun Microsystems, Inc. announces that 1 billion Java Card cards have been sold.
  • 5. Standardization 12 February, 1997 Leading Smart Card Manufacturers Announce Formation of Java Card Forum - Industry initiative endorsed by Sun, creator of the Java™ Card API standard 20 October, 1997 Public review on version 2.0 of the Java Card specification March, 1999 Java Card version 2.1 announced. There are three specifications: Java Card API, Java Card Runtime Environment, Java Card Virtual Machine May, 2006 Java Card version 2.2.2 announced. Adds contactless capabilities and biometry support for smart card chip manufacturers
  • 6. New Age March, 2008 Java Card version 3.0 announced. Classic and Connected Editions. •  Classic Edition is an evolution of the Java Card 2.2.2 •  Connected Edition is a revolution technology for high-end smart cards Today •  More than 10 billion Java technology based smart cards have been deployed •  NFC wallets requires Java Card •  Secure M2M Solutions
  • 7. Basic Standards •  ISO 7816 •  ISO 14443 •  Java Card Specification •  Global Platform
  • 8. ISO 7816 standards •  7816-1 – Physical characteristics •  7816-2 – Dimension and locations of contacts •  7816-3 – Electrical interface and transmission protocols (T0/T1) •  7816-4 – Organization, security and commands for interchange ISO 14443 standards (Contactless) •  14443-1 – Physical characteristics •  14443-2 – Radio frequency power and signal interface •  14443-3 – Initialization and anticollision •  14443-4 – Transmission protocol
  • 9. Must know facts about smartcards and ISO-standards •  Smartcard – small secure computer on chip •  CPU •  Crypto Processor •  ROM •  EEPROM •  FLASH •  Smart card requires terminal (contact/contactless). It provides supply and clock. •  Communication protocol is command-response based. Client Application Card Application Command APDU Response APDU
  • 10. APDU Structure (1/2) Command APDU Field Length Description CLA 1 Class of instruction INS 1 Instruction code P1 1 Instruction parameter 1 P2 1 Instruction parameter 2 Lc 1 or 3 Number of bytes present in the data field of the command Data Lc String of bytes sent in the data field of the command Le 1 or 3 Maximum number of bytes expected in the data field of the response to the command
  • 11. APDU Structure (2/2) Response APDU Field Length Description Data Lr String of bytes received in the data field of the response SW1 1 Command processing status SW2 1 Command processing qualifier The favorite response code is 0x9000 – SW_NO_ERROR
  • 12. Java Card Classic Architecture Card Management Security Policy/ Global Platform API Issuer/Vertical Market Defined API Applet 1 Applet 2 Native Operation System … Java CardTM Runtime Environment Java CardTM API Java CardTM Virtual Machine
  • 13. Native Operation System •  File System Operations •  Crypto Algorithms •  Data integrity •  Memory/Transactions management •  Hardware Interfaces •  Access Controller
  • 14. Java Card Classic Virtual Machine (version 3.0.4) 1/3 Split VM Architecture •  Off-card •  Class loading, linking and name resolution •  Bytecode verification, optimization and conversion •  On-card •  Bytecode execution and security enforcement Class files Converter Cap file Interpreter CardComputer JCVM
  • 15. Java Card Classic Virtual Machine (version 3.0.4) 2/3 •  Unsupported Features •  Dynamic Class Loading •  Security Manager •  Finalization •  Threads •  Cloning •  Access Control in Java Packages •  Typesafe Enums •  Enhanced for Loop •  Varargs •  Runtime Visible Metadata (Annotations) •  Assertions •  Unsupported Types The Java Card platform does not support types char, double, float and long. It also does not support arrays of more than one dimension.
  • 16. Java Card Classic Virtual Machine (version 3.0.4) 3/3 •  Supported Features •  Packages •  Dynamic Object Creation •  Virtual Methods •  Interfaces •  Exceptions •  Generics •  Static Import •  Runtime Invisible Metadata (Annotations) •  Runtime Visible Metadata (Annotations) •  Assertions •  GC (optional) •  Supported Types Java programming language types boolean, byte, short are supported. Objects (class instances and single-dimensional arrays) are also supported. The int keyword and 32-bit integer data support is optional.
  • 17. Java Card Runtime Environment (version 3.0.4) •  Card resource management •  Communications •  Applet execution •  Applet security (firewall) Firewall •  Provides isolation between applications •  Operates dynamically at run-time •  Isolation is at the package level •  Applets can explicitly share objects (javacard.framework.Shareable)
  • 18. Java Card API (version 3.0.4) •  java.io •  java.lang •  java.rmi •  javacard.framework •  javacard.security •  javacardx.annotations •  javacardx.apdu •  javacardx.biometry •  javacardx.crypto •  javacardx.external •  javacardx.framework.math •  javacardx.framework.string •  javacardx.framework.tlv •  javacardx.framework.util •  javacardx.framework.util.intx
  • 19. Global Platform Global Platform Card Specification is a secure, dynamic card and application management specification •  Security Domains •  Secure channels •  Application Management •  Card Management http://www.globalplatform.org/
  • 20. How is that works ? •  Application Model •  Development Workflow
  • 21. Application Model •  Java Card Application is always a subclass of the javacard.framework.Applet class •  Each applet has unique id - AID •  Only one active applet at a time •  Several applet can be selected at the time but can not work in parallel •  Applet class provides the following entry points: •  install(..) •  register(..) •  deselect(..) •  select(..) •  selectingApplet(..) •  process(..) •  getShareableInterfaceObject(..)
  • 22. Development Workflow Source Java Compiler Class files Java VM Java Card Converter CAP file Java Card C-JCRE Simulator JCWDE jCardSim
  • 23. Developer Tools •  Java Card Development Kit •  GPShell •  JCOP Tools from NXP (IBM) •  jCardSim
  • 24. jCardSim (1/3) Java CardTM Runtime Environment Implementation Java CardTM API Implementaion Java Virtual Machine jCardSim is an open source simulator implements Java Card, v.2.2.1 •  javacard.framework •  javacard.security •  javacardx.crypto
  • 25. jCardSim (2/3) Key Features •  Rapid application prototyping •  Ease of writing Unit-tests •  Emulation of Java Card Terminal, ability to use javax.smartcardio •  APDU scripting (scripts are compatible with apdutool from Java Card Development Kit) •  Ease of verification tests creation
  • 26. jCardSim (3/3) What is the difference from JCWDE? •  Implementation of javacard.security One of the main differences is the implementation of javacard.security: current version is analogous with NXP JCOP 31/36k card. For example, in jCardSim we have support an on-card KeyPair.ALG_EC_F2M/ALG_RSA_CRT-key generation •  Simulator API jCardSim has simple and usable API, which allows you to work with simulator like with real Java Card using javax.smartcardio •  Cross-platform jCardSim completely written in Java and can therefore be used at all platforms which supports Java (Windows, Linux, MacOS, etc)
  • 27. Writing our first real life Java Card application •  PetID – ePassport for home pets •  Concepts •  Architecture •  Implementation Notes •  Protocol •  Demo
  • 28. PetID – ePassport for home pets Nowadays, one of the main applications of Java Card is electronic identity cards (i.e. ePassport) Are pets worse than men? Lets create Java Card application – ePassport for Pets
  • 29. Concepts •  The application must provide the ability to store, receive and transmit information about a pet. •  Must provide protection against modification of the data from a malicious person. Information to be stored in ePassport: •  Pet’s name •  Date of birth •  Sex •  Breed
  • 30. Architecture •  Client Application – JavaFX application with the following functionality: •  ePassport application initialization •  Store pet’s information •  Read pet’s information •  Java Card Application •  Supported Commands •  Personalize •  Store Pet Info •  Read Pet Info
  • 31. Implementation Notes •  Way to interact with the Java Card – javax.smartcardio •  Version of Java Card API - 2.2.1 •  Protection against modification (digital signature) •  Elliptic curve cryptography •  Issuer Public Key stored in Personalize phase •  Store commands data is signed
  • 32. Protocol (1/4) Field Value CLA AA INS 0 P1 0 P2 0 Lc Issuer public key length Data Issuer public key PERSONALIZE
  • 33. Protocol (2/4) Field Value CLA AA INS 1 P1 0 P2 0 Lc Pet info data length Data Pet info data STORE_PET_INFO
  • 34. Protocol (3/4) Tag Value 01 Pet name 02 Date of birth 03 Breed 04 Sex 05 Signature PET_INFO DATA (TLV-encoded)
  • 35. Protocol (4/4) Field Value CLA AA INS 2 P1 0 P2 0 LOAD_PET_INFO
  • 37. Source Applet (1/2) public class PetIDApplet extends Applet { private final static byte BASE_CLA = (byte) 0xAA; private final static byte PERSONALIZE_INS = 0x00; private final static byte STORE_PET_INFO_INS = 0x01; private final static byte LOAD_PET_INFO_INS = 0x02; private ECPublicKey issuerPublicKey; private byte[] petInfoData; public PetIDApplet () { petInfoData= new byte[4086]; register(); } public static void install(byte[] bArray, short bOffset, byte bLength) throws ISOException { new PetIDApplet (); }
  • 38. Source Applet (2/2) public void process(APDU apdu) throws ISOException { if (selectingApplet()) return; byte[] buffer = apdu.getBuffer(); if (buffer[ISO7816.OFFSET_CLA] != BASE_CLA) { ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED); } byte ins = buffer[ISO7816.OFFSET_INS]; switch (ins) { case PERSONALIZE_INS: personalize(apdu); break; case STORE_PET_INFO_INS: storePetInfo(apdu); break; case LOAD_PET_INFO_INS: loadPetInfo(apdu); break; default: ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); } }
  • 39. Source PetInfo public class PetInfo { // tlv types private final static byte NAME_TAG = 1; private final static byte BIRTH_TAG = 2; private final static byte BREED_TAG = 3; private final static byte SEX_TAG = 4; private final static byte SIGNATURE_TAG = 5; // private String name; private boolean sex; private String breed; private Calendar dateOfBirth; … }
  • 40. Source Unit-test (1/3) System.setProperty("com.licel.jcardsim.smartcardio.applet.0.AID", TEST_APPLET_AID); System.setProperty("com.licel.jcardsim.smartcardio.applet.0.Class", “samples.PetIDApplet"); if (Security.getProvider("jCardSim") == null) { JCardSimProvider provider = new JCardSimProvider(); Security.addProvider(provider); } TerminalFactory tf = TerminalFactory.getInstance("jCardSim", null); CardTerminals ct = tf.terminals(); List<CardTerminal> list = ct.list(); CardTerminal jcsTerminal = null; for (int i = 0; i < list.size(); i++) { if (list.get(i).getName().equals("jCardSim.Terminal")) { jcsTerminal = list.get(i); break; } }
  • 41. Source Unit-test (2/3) // create applet data = aid len (byte), aid bytes, params lenth (byte), param byte[] aidBytes = Hex.decode(TEST_APPLET_AID); CommandAPDU createApplet = new CommandAPDU(0x80, 0xb8, 0, 0); ResponseAPDU response = jcsChannel.transmit(createApplet); assertEquals(response.getSW(), 0x9000); assertEquals(true, Arrays.equals(response.getData(), aidBytes)); // select applet CommandAPDU selectApplet = new CommandAPDU(ISO7816.CLA_ISO7816, ISO7816.INS_SELECT, 0, 0, Hex.decode(TEST_APPLET_AID)); response = jcsChannel.transmit(selectApplet); assertEquals(response.getSW(), 0x9000); // create issuer keys & PERSONALIZE KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC", "BC"); ECGenParameterSpec ecsp = new ECGenParameterSpec(“sect113r1”); kpg.initialize(ecsp); KeyPair kp = kpg.generateKeyPair(); CommandAPDU personalizeApplet = new CommandAPDU(0xAA,0, 0, 0, kp.getPublic().getEncoded()); response = jcsChannel.transmit(personalizeApplet); assertEquals(response.getSW(), 0x9000);
  • 42. Source Unit-test (3/3) // store pet info PetInfo pet = new PetInfo(“Leon”, “Cat”, “male”, “28.01.2005”); CommandAPDU storePetInfo = new CommandAPDU(0xAA, 1, 0, 0, pet.getEncoded(kp.getPrivate())); response = jcsChannel.transmit(storePetInfo); assertEquals(response.getSW(), 0x9000); // load pet info CommandAPDU loadPetInfo = new CommandAPDU(0xAA, 2, 0, 0); response = jcsChannel.transmit(loadPetInfo); assertEquals(response.getSW(), 0x9000); PetInfo test = new PetInfo(response.getData()); assertEquals(pet, test);
  • 43. DEMO
  • 44. NFC and Java Card •  NFC Brief Overview •  Secure Element
  • 45. NFC NFC - A new radio communication interface for mobile phones •  Range 2 – 4 cm •  13.56 MHz •  Approx. 100 million devices shipped in 2012 •  Modes •  Tag read/write •  P2P •  Card emulation (”secure NFC”)
  • 46. Secure NFC NFC API Phone OS NFC Controller SE NFC Antenna Secure Element Java Card Application
  • 47. jCardSim Facts •  The initial project team consisted of three developers •  First public release has been announced in December 2011 •  In June 2012 the official site, jcardsim.org, has been started and available in following languages: English, Russian, Spanish •  Main audience of the project is students which are learning Java Card and professional Java Card developers
  • 48. jCardSim RoadMap 2Q 2013 •  Shareable Interface Support •  Service Framework Support •  Multiple Logical Channels 3Q 2013 •  Application Firewall Support •  Basic Global Platform functionality