jcardsim Java Card is simple!



Similar documents
Java Card TM Open Platform for Smart Cards

JavaCard. Java Card - old vs new

Smart Card Application Development Using the Java Card Technology

Developing secure Java Card applications

Smart Cards a(s) Safety Critical Systems

Java Applet and Terminal Application for Financial transactions

Java Card. Smartcards. Demos. . p.1/30

Smart Card Based User Authentication

Smart Card Application Standard Draft

Chytré karty opět o rok dál...

RMI Client Application Programming Interface

Java Card Application Programming Interface

An evaluation of the Java Card environment

Training. MIFARE4Mobile. Public. MobileKnowledge April 2015

Security & Chip Card ICs SLE 44R35S / Mifare

Your Mobile Phone as a Ticket (NFC)

JCAT. Java Card TM. An environment for attack and test on. Serge Chaumette, Iban Hatchondo, Damien Sauveron CCCT 03 & ISAS 03

Smart Card Technology Capabilities

Application Programming Interface

An Overview of Java. overview-1

Malicious Code on Java Card Smartcards: Attacks and Countermeasures

Overview of Contactless Payment Cards. Peter Fillmore. July 20, 2015

RVS Seminar Deployment and Performance Analysis of JavaCards in a Heterogenous Environment. Carolin Latze University of Berne

Exercise 1: Set up the Environment

Embedded Java & Secure Element for high security in IoT systems

Banking. Extending Value to Customers. KONA Banking product matrix. is leading the next generation of payment solutions.

Using RFID Techniques for a Universal Identification Device

NFC Hacking: The Easy Way

Loyalty Systems over Near Field Communication (NFC)

NFC Testing. Near Field Communication Research Lab Hagenberg. Gerald Madlmayr. NFC Research Lab, Hagenberg. E-Smart 2008, Sophia Antipolis

Gemalto Mifare 1K Datasheet

Smart Cards and their Operating Systems

Java Programming Fundamentals

Introducing etoken. What is etoken?

Java Card Development Kit. 1 Table of Contents. 2 Introduction. Release Notes for Java Card 3 Platform, Classic Edition, Version 3.0.

CHAPTER 5 SMART CARD TECHNOLOGY

picojava TM : A Hardware Implementation of the Java Virtual Machine

AP Computer Science Java Subset

A Guide to EMV. Version 1.0 May Copyright 2011 EMVCo, LLC. All rights reserved.

NFC Hacking: The Easy Way

Study of Java Card and its Application 1 Nainesh Rawani, 2 Akhil Patel

Reverse engineering smart cards

Java Card Protection Profile Open Configuration

Best Practises for LabVIEW FPGA Design Flow. uk.ni.com ireland.ni.com

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

Measurement and Analysis Introduction of ISO7816 (Smart Card)

Chapter 3 Operating-System Structures

Smart Card. Smart Card applications

MDG. MULTOS Developer's Guide. MAO-DOC-TEC-005 v MAOSCO Limited. MULTOS is a registered trademark of MULTOS Limited.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Evaluating Elliptic Curve Cryptography for Use on Java Card

Crash Course in Java

DEVELOPING NFC APPS for BLACKBERRY

Pemrograman Dasar. Basic Elements Of Java

Risks of Offline Verify PIN on Contactless Cards

RF-Enabled Applications and Technology: Comparing and Contrasting RFID and RF-Enabled Smart Cards

Freescale Semiconductor, I

Side-Channel Monitoring of Contactless Java Cards

Java Application Developer Certificate Program Competencies

PUF Physical Unclonable Functions

Nokia 9210i/9290 Communicators and PersonalJava TM Application Development

EMV-TT. Now available on Android. White Paper by

Java Card 3 Platform. Virtual Machine Specification, Classic Edition. Version May 2015

Mobile MasterCard PayPass Testing and Approval Guide. December Version 2.0

Contactless Smart Cards vs. EPC Gen 2 RFID Tags: Frequently Asked Questions. July, Developed by: Smart Card Alliance Identity Council

Lesson-3 CASE STUDY OF AN EMBEDDED SYSTEM FOR SMART CARD

SMARTCARD SECURITY. Java Card Security. Marc Witteman. Introduction

Significance of Tokenization in Promoting Cloud Based Secure Elements

GlobalPlatform. Card Specification. Version 2.2

Distributed Network Management Using SNMP, Java, WWW and CORBA

Java Interview Questions and Answers

Project SailFin: Building and Hosting Your Own Communication Server.

Smart Card APDU Analysis

Hardware/Software Co-Design of a Java Virtual Machine

The Hotspot Java Virtual Machine: Memory and Architecture

SEEK project - Access to Secure Elements on Android. Frank Schäfer

The BSN Hardware and Software Platform: Enabling Easy Development of Body Sensor Network Applications

Secure Over the Air (OTA) Management Of Mobile Applications

Testing the Java Card Applet Firewall

Location-Aware and Safer Cards: Enhancing RFID Security and Privacy

MIFARE ISO/IEC PICC

Can You Trust Your JVM Diagnostic Tools?

Performance Evaluation of Java Card Bytecodes

Mobile NFC 101. Presenter: Nick von Dadelszen Date: 31st August 2012 Company: Lateral Security (IT) Services Limited

1. Overview of the Java Language

RE-TRUST Design Alternatives on JVM

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

AN1305. MIFARE Classic as NFC Type MIFARE Classic Tag. Application note COMPANY PUBLIC. Rev October Document information

ACR120 Technical Specifications version 2.9 November 2005

Open Mobile API Test Specification for Transport API

Java (12 Weeks) Introduction to Java Programming Language

ETSI TS V7.1.0 ( ) Technical Specification

SIM cards for cellular networks

Transcription:

JavaOne Moscow, 2013 jcardsim Java Card is simple! Mikhail Dudarev, CTO of jcardsim.org

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 Agenda

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

ISO 7816 ISO 14443 Java Card Specification Global Platform Basic Standards

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 Command APDU Response APDU Card Application

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 Applet 1 Applet 2 Issuer/Vertical Market Defined API Java CardTM Runtime Environment Java CardTM API Java CardTM Virtual Machine Native Operation System

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 JCVM Class files Converter Cap file Interpreter Computer Card

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/

Application Model Development Workflow How is that works?

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 Java Compiler Source Java VM Class files Java Card Converter CAP file JCWDE jcardsim Java Card C-JCRE Simulator

Java Card Development Kit GPShell JCOP Tools from NXP (IBM) jcardsim Developer Tools

jcardsim (1/3) jcardsim is an open source simulator implements Java Card, v.2.2.1 javacard.framework javacard.security javacardx.crypto Java Card TM Runtime Environment Implementation Java Card TM API Implementaion Java Virtual Machine

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)

PetID epassport for home pets Concepts Architecture Implementation Notes Protocol Demo Writing our first real life Java Card application

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) PERSONALIZE Field Value CLA AA INS 0 P1 0 P2 0 Lc Issuer public key length Data Issuer public key

Protocol (2/4) STORE_PET_INFO Field Value CLA AA INS 1 P1 0 P2 0 Lc Pet info data length Data Pet info data

Protocol (3/4) PET_INFO DATA (TLV-encoded) Tag Value 01 Pet name 02 Date of birth 03 Breed 04 Sex 05 Signature

Protocol (4/4) LOAD_PET_INFO Field Value CLA AA INS 2 P1 0 P2 0

CODING

Source Applet (1/2) public class PetIDApplet extends Applet { private private private private private private final static byte BASE_CLA = (byte) 0xAA; final static byte PERSONALIZE_INS = 0x00; final static byte STORE_PET_INFO_INS = 0x01; final static byte LOAD_PET_INFO_INS = 0x02; ECPublicKey issuerpublickey; 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 Brief Overview Secure Element NFC and Java Card

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 Secure Element NFC API Phone OS Application NFC Controller SE Java Card NFC Antenna

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 Facts

2Q 2013 Shareable Interface Support Service Framework Support Multiple Logical Channels 3Q 2013 Application Firewall Support Basic Global Platform functionality jcardsim RoadMap

THANKS! Email: jcardsim@licel.ru Twitter: @MikhailDudarev WWW: jcardsim.org