SlideShare a Scribd company logo
Step-by-Step development
of an Application for the
Java Card 3.0™ platform
Anki Nelaturu Eric Vétillard
Sun Microsystems Trusted Labs
2
About the speakers
> Eric Vétillard
● CTO of Trusted Labs
● Technical Chair, Java Card Forum
> Anki Nelaturu
● Staff engineer, Java Card Technology Group,
Sun Microsystems
3
Session objectives
> Learn the basic principles of Java Card 3.0
● Based on a small realistic application
● Step-by-step building of a first version
● Including typical smart card issues
● Security, performance, deployment
> Discover the development tools
● Building a project
● Using the Reference Implementation
4
The Session at a Glance
> An introduction to Java Card 3.0
> Writing a first application
> Building and running the application
> Making your application realistic
> Further options
> Deploying your application
5
Smart Card Characteristics
> Smart cards are small
● Best in class have 32k RAM, 1M Flash
> Smart cards are cheap
● A single chip, embedded in plastic
> Smart cards are secure
● They are often used to manage sensitive assets
> Smart cards are manageable
● Powerful remote app management tools
6
Why a Specific Platform?
> Limited resources
● RAM is very scarce; object use is limited
● Flash memory is hard to access
● Computing power is limited
> Specific requirements
● High level of security
● Several applications share the same VM
● Persistence is achieved through objects
7
Java Card 3.0 in One Slide
> VM and core API based on CLDC
● Minus floating-point numbers and a few details
● Plus persistent objects
● Plus a firewall between applications
● Plus detailed permissions
> A servlet application model
● Plus a legacy smart card application model
8
The First Application
> A basic password manager
● Stores triplets made of
● An identifier (URL or simple string)
● A user name
● A password
> Available through a Web interface
● Main application is a servlet
9
A Password Record
package com.vetilles.passwords;
public class PasswordEntry ;
private String userName;
private String password;
public PasswordEntry(String userName, String password) {
this.userName = userName;
this.password = password;
}
public String getUserName() {
return userName ;
}
public void setUserName(String userName) {
this.userName = userName;
}
...
10
A Password Manager
package com.vetilles.passwords;
import java.util.Hashtable;
import java.util.Enumeration;
import javacardx.framework.TransactionType;
import javacardx.framework.TransactionTypeValue;
public class PasswordManager ;
private Hashtable<String,PasswordEntry> entries;
public PasswordManager() {
entries = new Hashtable();
}
...
11
A Password Manager
...
@TransactionType(TransactionTypeValue.REQUIRED)
public boolean addPasswordEntry
(String id, String userName, String password) {
if (entries.containsKey(id)) return false ;
entries.put(id, new PasswordEntry(userName, password);
return true ;
}
public PasswordEntry retrievePasswordEntry(String id)
{
return entries.get(id) ;
}
...
12
A Password Manager
...
@TransactionType(TransactionTypeValue.REQUIRED)
public boolean deletePasswordEntry(String id) {
return entries.remove(id) != null ;
}
public Enumeration<String> listIdentifiers()
{
return entries.keys() ;
}
}
13
Persistence basics
> Persistence by reachability
● Reachability by a root of persistence
● Static field, servlet context, applet object
● All persistent objects stored in persistent memory
> Guarantees on persistent objects
● Individual write operations are atomic
● All writes in a transaction are atomic
14
Transaction basics
> Inspired from Java EE persistence
● With some specific details
● A smart card is not a database
> Three basic principles
● The scope of the transaction is a method
● Commit occurs on normal return
● Abort occurs on exception exit
15
Transaction types
> SUPPORTS
● By default, transaction optional
> REQUIRED
● When a transaction is needed
> REQUIRES_NEW
● For a separate transaction
> MANDATORY, NEVER, NOT_SUPPORTED:
● For special cases
16
A Password Servlet
package com.vetilles.passwords;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** A Simple Hello Servlet */
public class PassServlet extends HttpServlet {
private static PasswordManager manager =
new PasswordManager();
...
17
A Password Servlet
@Override
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
// First interprets the command
String command = request.getServletPath();
// Matches the possible incoming commands
if (command.equals("/addentry"))
addEntry(request, response);
else if (command.equals("/retrieveentry"))
retrieveEntry(request, response);
else if (command.equals("/deleteentry"))
deleteEntry(request, response);
else if (command.equals("/listidentifiers"))
listIdentifiers(request, response);
}
18
A Password Servlet
private void addEntry(
HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
boolean status = manager.addPasswordEntry(
request.getParameter("id"),
request.getParameter("name"),
request.getParameter("pass")) ;
PrintWriter out = startResponse(response);
if (status)
out.println(HTML_ADD_ENTRY_SUCCESS);
else
out.println(HTML_ADD_ENTRY_FAILED);
finishResponse(response);
}
19
A Password Servlet
private static final String HTML_ADD_ENTRY_SUCCESS =
"<p align="center">"
+ "Password entry added successfully"
+ "</p><br>";
private static final String HTML_ADD_ENTRY_FAILED =
"<p align="center">"
+ "Password entry addition failed."
+ "</p>"
+ "<p align="center">"
+ "Identifier already in use."
+ "</p><br>";
20
A Password Servlet
private PrintWriter startResponse(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Set content type first
response.setContentType("text/html");
// Uses RequestDispatcher to write the header
RequestDispatcher dispatcher =
request.getRequestDispatcher("/WEB-INF/header.i");
dispatcher.include(request, response);
// Get PrintWriter object to create response
return response.getWriter();
}
21
A Password Servlet
private void finishResponse(
HttpServletRequest request)
HttpServletResponse response)
throws IOException
{
// Uses RequestDispatcher to write the footer
RequestDispatcher dispatcher =
request.getRequestDispatcher("/WEB-INF/footer.i");
dispatcher.include(request, response);
}
22
HTML file: header.i
<html>
<head><title>Password Manager</title></head>
<body>
<table><tr>
<h1 align="center">Password Manager</h1><br>
<td><a href="/pass/add.html">Add entry</a></td>
<td><a href="/pass/retrieve.html">
Retrieve entry
</a></td>
<td><a href="/pass/delete.html">
Delete entry
</a></td>
<td><a href="/pass/listidentifiers">
List identifiers
</a></td>
</tr></table>
<br><br>
23
HTML file: footer.i
</body>
</html>
24
Access Control
> No access control
● The user must be authenticated
> Container-managed authentication is possible
● BASIC authentication for simplicity
● FORM-based for more flexibility
> Role-based security is available
● Access rights orthogonal to authentication
25
So ?
> For Java Card 2.x developers
● Java Card 3.0 is a major breakthrough
● The servlet model is entirely new
> For other Java developers
● Java Card 3.0 is more traditional
● Well integrated into standard tool chain
● NetBeans, debugger, etc.
26
Demo
27
What is Wrong with this Application?
> Security
● Content is not well protected
● No protection against Web attacks
> Performance
● Too much content going back and forth
● Card-specific optimizations
28
Why Protect the Content?
> No separation in n tiers
● Data is stored by the presentation application
> Smart cards are subject to attacks
● They are a Web server in the attacker's hands
● Attacks on the hardware are possible
● Observation and fault induction attacks
> Content is sensitive
29
Secure Storage of Passwords
> Issue 1: Upon deletion, passwords must be wiped
● How do you wipe a String?
● Persistent storage must be in a byte array
> Issue 2: Passwords should be stored encrypted
● Once again, byte arrays are required
> The PasswordEntry class needs some work
● Storage of passwords in encrypted byte arrays
30
Secure Storage of Passwords
package com.vetilles.passwords;
import javacard.security.DESKey ;
import javacard.security.KeyBuilder ;
import javacardx.crypto.Cipher ;
import javacardx.crypto.RandomData ;
public class PasswordEntry {
private String userName;
private byte[] password;
private static DESKey theKey ;
private static Cipher cipher ;
public PasswordEntry(String userName, String password) {
if (theKey == null)
initCrypto() ;
this.userName = userName;
setPassword(password);
}
31
Secure Storage of Passwords
private static void initCrypto()
{
// Allocates the objects
theKey = (DESKey)KeyBuilder.buildKey(
"DES",KeyBuilder.LENGTH_DES3_2KEY, false);
cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true);
// Generates a random key value
RandomData rnd = RandomData.getInstance("SECURE_RANDOM");
byte[] value = new byte[16] ;
rnd.generateData(value, (short)0, (short)16);
theKey.setKey(value);
// Clears the key value before to return
rnd.generateData(value, (short)0, (short)16);
}
32
Secure Storage of Passwords
public void setPassword(String pass)
{
byte[] bytes = pass.bytes();
password = new byte[bytes.length+9];
cipher.init(theKey,Cipher.MODE_ENCRYPT);
password[0] = (byte)cipher.doFinal(
bytes, (short)0, (short)bytes.length, password, (short)1 );
}
public String getPassword()
{
byte[] bytes = new byte[password.length];
cipher.init(theKey,Cipher.MODE_DECRYPT);
short len = cipher.doFinal(
password, (short)1, password[0], bytes, (short)0 );
return new String(bytes,(short)0,len);
}
33
Secure Communication
> Several issues are present
● All data is transmitted in clear
● Master password is transmitted in clear
> One simple solution: SSL
● Supported at the container level
● Not a single line of code
● Only constraint: manage the certificates
34
Web Security
> Web applications have many security issues
> See OWASP for a starting point
● In particular the “Top 10 Vulnerabilities”
> Some countermeasures are required
● Input filtering
● Output canonicalization
● Proper session management
35
Validating Input
private void addEntry(
HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
boolean status ;
try {
status = manager.addPasswordEntry(
validateId(request.getParameter("id")),
validateId(request.getParameter("name")),
request.getParameter("pass")) ;
} catch(Exception e) {
sendError(response,e.getMessage());
return;
}
...
}
36
Validating Input
private static final String otherChars = "-_@." ;
private String validateId(String id) throws IOException
{
char[] chars = id.toCharArray() ;
for(char c:chars)
{
if (Character.isDigit(c)) continue;
if (Character.isLowerCase(c)) continue;
if (Character.isUpperCase(c)) continue;
if (otherChars.indexOf(c)!=-1) continue;
throw new IOException("Invalid identifier string");
}
// If we get here, all characters are acceptable
return id ;
}
37
Canonicalizing Output
> The idea is to make the output innocuous
● Make sure that characters are not interpreted
● The following only works on ASCII characters
private String encodeUnverifiedString(String str)
{
StringBuffer s = new StringBuffer();
char[] chars = str.toCharArray() ;
for(char c:chars)
{
s.append("<span>#&" + Integer.toString(c) + ";</span>");
}
return s.toString();
}
38
Communication Performance
> Card communication remains slow
● Content production also has limits
> Similar to other elements of the “Web of Things”
● Servers are less powerful than clients
● The work must be delegated to clients
> Ajax can be used
● Limits the amount of communication
● Limits HTML overhead on the server side
39
Ajax on a Smart Card?
> Ajax is an interesting technique
● It is entirely managed on the card
● It uses the client's resources
> Aren't there security issues ?
● No, not really
● The browser must be trusted anyway
40
Performance Optimization
Persistent memory
private static void initCrypto()
{
// Allocates the objects
theKey = (DESKey)KeyBuilder.buildKey(
"DES",KeyBuilder.LENGTH_DES3_2KEY, false);
cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true);
// Generates a random key value
RandomData rnd = RandomData.getInstance("SECURE_RANDOM");
byte[] value = new byte[16] ;
rnd.generateData(value, (short)0, (short)16);
theKey.setKey(value);
// Clears the key value before to return
rnd.generateData(value, (short)0, (short)16);
}
41
Performance Optimization
Persistent memory
private static void initCrypto()
{
// Allocates the objects
DESKey newKey = (DESKey)KeyBuilder.buildKey(
"DES",KeyBuilder.LENGTH_DES3_2KEY, false);
cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true);
// Generates a random key value
RandomData rnd = RandomData.getInstance("SECURE_RANDOM");
byte[] value = new byte[16] ;
rnd.generateData(value, (short)0, (short)16);
newKey.setKey(value);
// Clears the key value before to return
rnd.generateData(value, (short)0, (short)16);
// Promotes the key to persistent memory
theKey = newKey ;
}
42
What more could we do ?
> Manage the data in a separate application
● Use sharing to communicate
> Add an APDU interface
● Work with legacy smart card applications
> Manage our own authenticators
● Rather than use the platform's default ones
> Backup our passwords
● Open a connection to a backup server
43
What about Deployment?
> Many instances
● Not a single server
● Instead, millions of cards/objects
> A mutualized server
● Several providers represented on the server
● Usually, one single issuer (the owner)
● Some resource allocation to manage
44
GlobalPlatform
> Card management technology since 1999
● Standards to deploy/manage applications
● Standards to manage relationships
● Between card issuers and application providers
● Including trusted third parties when needed
> Currently being adapted to a Web model
● Update of application management
● Addition of new resources to be managed
45
GlobalPlatform Architecture
FromGlobalPlatform
Card Spec v2.2,2006
46
Issuer-Centric Deployment
> Current model for smart cards
● The issuer owns the card
> Many deployment options
● The issuer manages all applications
● Simple and practical
● A third party needs to sign all applications
● Practical to enforce issuer policies
● Management can be delegated
● All operations may still be explicitly authorized
47
Alternative Deployment Scenarios
> White card schemes
● Very similar to an issuer-centric scheme
● But the “issuer” is an association/public entity
> Cardholder-owned cards
● Not the tendency for traditional cards
● Likely trend with smart objects
> ...
48
GlobalPlatform Networked Framework
> Adapts the existing model to the Web
● HTTP and SSL as transport
● ASN.1 as encoding
> Supports specific Web application features
● Management of URIs
● Who can use the http://localhost:8019/google ?
● Management of realms and authenticators
● Who can use the “Visa” authentication realm?
49
Recap
> Java Card 3.0 brings Web servers everywhere
● On cards and on other devices
● Using a very classical model
> Of course, there is a catch
● Resources are severely limited
● Deployment needs to be carefully planned
● Applications and devices may be linked
50
Getting More Information
> Spec and Development Kit
● java.sun.com/products/javacard
● Look at the samples ...
> Blogs
● javacard.vetilles.com
> Other sessions at JavaOne
Anki Nelaturu
anki.nelaturu@sun.com
Eric Vétillard
eric.vetillard@trusted-labs.com

More Related Content

What's hot

Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewallskkkseld
 
Ipsec vpn v0.1
Ipsec vpn v0.1Ipsec vpn v0.1
Mutating Admission Webhook creation
Mutating Admission Webhook creationMutating Admission Webhook creation
Mutating Admission Webhook creation
Victor Morales
 
IPSec Overview
IPSec OverviewIPSec Overview
IPSec Overview
davisli
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
Kernel TLV
 
Mikrotik Hotspot User Manager
Mikrotik Hotspot User ManagerMikrotik Hotspot User Manager
Mikrotik Hotspot User Manager
KHNOG
 
Practical Trusted Platform Module (TPM2) Programming
Practical Trusted Platform Module (TPM2) ProgrammingPractical Trusted Platform Module (TPM2) Programming
Practical Trusted Platform Module (TPM2) Programming
Brandon Arvanaghi
 
Nmap
NmapNmap
Linux DMA Engine
Linux DMA EngineLinux DMA Engine
Cisco Connect Toronto 2018 dc-aci-anywhere
Cisco Connect Toronto 2018   dc-aci-anywhereCisco Connect Toronto 2018   dc-aci-anywhere
Cisco Connect Toronto 2018 dc-aci-anywhere
Cisco Canada
 
3 additional dpdk_theory(1)
3 additional dpdk_theory(1)3 additional dpdk_theory(1)
3 additional dpdk_theory(1)
videos
 
NMAP
NMAPNMAP
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall introRich Helton
 
Embedded Linux Basics
Embedded Linux BasicsEmbedded Linux Basics
Embedded Linux Basics
Marc Leeman
 
Understanding and Troubleshooting ASA NAT
Understanding and Troubleshooting ASA NATUnderstanding and Troubleshooting ASA NAT
Understanding and Troubleshooting ASA NAT
Cisco Russia
 
ISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
ISSCC 2018: "Zeppelin": an SoC for Multi-chip ArchitecturesISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
ISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
AMD
 
IOS Cisco - Cheat sheets
IOS Cisco - Cheat sheetsIOS Cisco - Cheat sheets
IOS Cisco - Cheat sheets
Alejandro Marin
 
S/MIME & E-mail Security (Network Security)
S/MIME & E-mail Security (Network Security)S/MIME & E-mail Security (Network Security)
S/MIME & E-mail Security (Network Security)
Prafull Johri
 
Switch security
Switch securitySwitch security
Switch security
nullowaspmumbai
 

What's hot (20)

Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewalls
 
Ipsec vpn v0.1
Ipsec vpn v0.1Ipsec vpn v0.1
Ipsec vpn v0.1
 
Mutating Admission Webhook creation
Mutating Admission Webhook creationMutating Admission Webhook creation
Mutating Admission Webhook creation
 
IPSec Overview
IPSec OverviewIPSec Overview
IPSec Overview
 
Linux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use CasesLinux Kernel Cryptographic API and Use Cases
Linux Kernel Cryptographic API and Use Cases
 
Mikrotik Hotspot User Manager
Mikrotik Hotspot User ManagerMikrotik Hotspot User Manager
Mikrotik Hotspot User Manager
 
Practical Trusted Platform Module (TPM2) Programming
Practical Trusted Platform Module (TPM2) ProgrammingPractical Trusted Platform Module (TPM2) Programming
Practical Trusted Platform Module (TPM2) Programming
 
Nmap
NmapNmap
Nmap
 
Linux DMA Engine
Linux DMA EngineLinux DMA Engine
Linux DMA Engine
 
Cisco Connect Toronto 2018 dc-aci-anywhere
Cisco Connect Toronto 2018   dc-aci-anywhereCisco Connect Toronto 2018   dc-aci-anywhere
Cisco Connect Toronto 2018 dc-aci-anywhere
 
3 additional dpdk_theory(1)
3 additional dpdk_theory(1)3 additional dpdk_theory(1)
3 additional dpdk_theory(1)
 
NMAP
NMAPNMAP
NMAP
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall intro
 
Embedded Linux Basics
Embedded Linux BasicsEmbedded Linux Basics
Embedded Linux Basics
 
GPU: Understanding CUDA
GPU: Understanding CUDAGPU: Understanding CUDA
GPU: Understanding CUDA
 
Understanding and Troubleshooting ASA NAT
Understanding and Troubleshooting ASA NATUnderstanding and Troubleshooting ASA NAT
Understanding and Troubleshooting ASA NAT
 
ISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
ISSCC 2018: "Zeppelin": an SoC for Multi-chip ArchitecturesISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
ISSCC 2018: "Zeppelin": an SoC for Multi-chip Architectures
 
IOS Cisco - Cheat sheets
IOS Cisco - Cheat sheetsIOS Cisco - Cheat sheets
IOS Cisco - Cheat sheets
 
S/MIME & E-mail Security (Network Security)
S/MIME & E-mail Security (Network Security)S/MIME & E-mail Security (Network Security)
S/MIME & E-mail Security (Network Security)
 
Switch security
Switch securitySwitch security
Switch security
 

Viewers also liked

jCardSim – Java Card is simple!
jCardSim – Java Card is simple!jCardSim – Java Card is simple!
jCardSim – Java Card is simple!
Mikhail Dudarev
 
Java ring
Java ringJava ring
Java ring
Kaushik Banerjee
 
FIPS 201 / PIV
FIPS 201 / PIVFIPS 201 / PIV
FIPS 201 / PIV
Anshuman Sinha
 
Java card technology
Java card technologyJava card technology
Java card technology
Amol Kamble
 

Viewers also liked (7)

jCardSim – Java Card is simple!
jCardSim – Java Card is simple!jCardSim – Java Card is simple!
jCardSim – Java Card is simple!
 
Java ring
Java ringJava ring
Java ring
 
FIPS 201 / PIV
FIPS 201 / PIVFIPS 201 / PIV
FIPS 201 / PIV
 
Java card
Java cardJava card
Java card
 
Java card technology
Java card technologyJava card technology
Java card technology
 
Java card technology
Java card technologyJava card technology
Java card technology
 
Dif fft
Dif fftDif fft
Dif fft
 

Similar to Step-by-step Development of an Application for the Java Card Connected Platform

General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
jemond
 
Mitigating Java Deserialization attacks from within the JVM (improved version)
Mitigating Java Deserialization attacks from within the JVM (improved version)Mitigating Java Deserialization attacks from within the JVM (improved version)
Mitigating Java Deserialization attacks from within the JVM (improved version)
Apostolos Giannakidis
 
Curator intro
Curator introCurator intro
Curator intro
Jordan Zimmerman
 
JavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developersJavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developers
FestGroup
 
Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019
Balázs Tatár
 
Mitigating Java Deserialization attacks from within the JVM
Mitigating Java Deserialization attacks from within the JVMMitigating Java Deserialization attacks from within the JVM
Mitigating Java Deserialization attacks from within the JVM
Apostolos Giannakidis
 
Struts2 notes
Struts2 notesStruts2 notes
Struts2 notes
Rajiv Gupta
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
Lukas Smith
 
Lesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdfLesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdf
Scott Anderson
 
Application Security
Application SecurityApplication Security
Application Securityflorinc
 
Session - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptxSession - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptx
imjdabhinawpandey
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding API
Alex Theedom
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Alena Holligan
 
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
PROIDEA
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
Ballerina
 
Integrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight ApplicationsIntegrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight ApplicationsDan Wahlin
 

Similar to Step-by-step Development of an Application for the Java Card Connected Platform (20)

General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Mitigating Java Deserialization attacks from within the JVM (improved version)
Mitigating Java Deserialization attacks from within the JVM (improved version)Mitigating Java Deserialization attacks from within the JVM (improved version)
Mitigating Java Deserialization attacks from within the JVM (improved version)
 
Curator intro
Curator introCurator intro
Curator intro
 
JavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developersJavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developers
 
Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019Let's write secure Drupal code! - DrupalCamp London 2019
Let's write secure Drupal code! - DrupalCamp London 2019
 
Mitigating Java Deserialization attacks from within the JVM
Mitigating Java Deserialization attacks from within the JVMMitigating Java Deserialization attacks from within the JVM
Mitigating Java Deserialization attacks from within the JVM
 
Struts2 notes
Struts2 notesStruts2 notes
Struts2 notes
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
Lesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdfLesson_07_Spring_Security_Register_NEW.pdf
Lesson_07_Spring_Security_Register_NEW.pdf
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 
Application Security
Application SecurityApplication Security
Application Security
 
Session - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptxSession - 1 Forms and Session management.pptx
Session - 1 Forms and Session management.pptx
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding API
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
JDD 2016 - Michał Balinski, Oleksandr Goldobin - Practical Non Blocking Micro...
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
 
Integrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight ApplicationsIntegrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight Applications
 

More from Eric Vétillard

New Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web ServersNew Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web Servers
Eric Vétillard
 
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
Eric Vétillard
 
Java Card Platform Security and Performance
Java Card Platform Security and PerformanceJava Card Platform Security and Performance
Java Card Platform Security and Performance
Eric Vétillard
 
Java Card in Banking and NFC
Java Card in Banking and NFCJava Card in Banking and NFC
Java Card in Banking and NFC
Eric Vétillard
 
First Steps with Java Card
First Steps with Java CardFirst Steps with Java Card
First Steps with Java Card
Eric Vétillard
 
Java Solutions for Securing Edge-to-Enterprise
Java Solutions for Securing Edge-to-EnterpriseJava Solutions for Securing Edge-to-Enterprise
Java Solutions for Securing Edge-to-Enterprise
Eric Vétillard
 
Threat Modeling for the Internet of Things
Threat Modeling for the Internet of ThingsThreat Modeling for the Internet of Things
Threat Modeling for the Internet of Things
Eric Vétillard
 
Eric java card-basics-140314
Eric java card-basics-140314Eric java card-basics-140314
Eric java card-basics-140314
Eric Vétillard
 
Java Card, 15 years later
Java Card, 15 years laterJava Card, 15 years later
Java Card, 15 years later
Eric Vétillard
 

More from Eric Vétillard (9)

New Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web ServersNew Security Issues related to Embedded Web Servers
New Security Issues related to Embedded Web Servers
 
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 Platform Security and Performance
Java Card Platform Security and PerformanceJava Card Platform Security and Performance
Java Card Platform Security and Performance
 
Java Card in Banking and NFC
Java Card in Banking and NFCJava Card in Banking and NFC
Java Card in Banking and NFC
 
First Steps with Java Card
First Steps with Java CardFirst Steps with Java Card
First Steps with Java Card
 
Java Solutions for Securing Edge-to-Enterprise
Java Solutions for Securing Edge-to-EnterpriseJava Solutions for Securing Edge-to-Enterprise
Java Solutions for Securing Edge-to-Enterprise
 
Threat Modeling for the Internet of Things
Threat Modeling for the Internet of ThingsThreat Modeling for the Internet of Things
Threat Modeling for the Internet of Things
 
Eric java card-basics-140314
Eric java card-basics-140314Eric java card-basics-140314
Eric java card-basics-140314
 
Java Card, 15 years later
Java Card, 15 years laterJava Card, 15 years later
Java Card, 15 years later
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

Step-by-step Development of an Application for the Java Card Connected Platform

  • 1. Step-by-Step development of an Application for the Java Card 3.0™ platform Anki Nelaturu Eric Vétillard Sun Microsystems Trusted Labs
  • 2. 2 About the speakers > Eric Vétillard ● CTO of Trusted Labs ● Technical Chair, Java Card Forum > Anki Nelaturu ● Staff engineer, Java Card Technology Group, Sun Microsystems
  • 3. 3 Session objectives > Learn the basic principles of Java Card 3.0 ● Based on a small realistic application ● Step-by-step building of a first version ● Including typical smart card issues ● Security, performance, deployment > Discover the development tools ● Building a project ● Using the Reference Implementation
  • 4. 4 The Session at a Glance > An introduction to Java Card 3.0 > Writing a first application > Building and running the application > Making your application realistic > Further options > Deploying your application
  • 5. 5 Smart Card Characteristics > Smart cards are small ● Best in class have 32k RAM, 1M Flash > Smart cards are cheap ● A single chip, embedded in plastic > Smart cards are secure ● They are often used to manage sensitive assets > Smart cards are manageable ● Powerful remote app management tools
  • 6. 6 Why a Specific Platform? > Limited resources ● RAM is very scarce; object use is limited ● Flash memory is hard to access ● Computing power is limited > Specific requirements ● High level of security ● Several applications share the same VM ● Persistence is achieved through objects
  • 7. 7 Java Card 3.0 in One Slide > VM and core API based on CLDC ● Minus floating-point numbers and a few details ● Plus persistent objects ● Plus a firewall between applications ● Plus detailed permissions > A servlet application model ● Plus a legacy smart card application model
  • 8. 8 The First Application > A basic password manager ● Stores triplets made of ● An identifier (URL or simple string) ● A user name ● A password > Available through a Web interface ● Main application is a servlet
  • 9. 9 A Password Record package com.vetilles.passwords; public class PasswordEntry ; private String userName; private String password; public PasswordEntry(String userName, String password) { this.userName = userName; this.password = password; } public String getUserName() { return userName ; } public void setUserName(String userName) { this.userName = userName; } ...
  • 10. 10 A Password Manager package com.vetilles.passwords; import java.util.Hashtable; import java.util.Enumeration; import javacardx.framework.TransactionType; import javacardx.framework.TransactionTypeValue; public class PasswordManager ; private Hashtable<String,PasswordEntry> entries; public PasswordManager() { entries = new Hashtable(); } ...
  • 11. 11 A Password Manager ... @TransactionType(TransactionTypeValue.REQUIRED) public boolean addPasswordEntry (String id, String userName, String password) { if (entries.containsKey(id)) return false ; entries.put(id, new PasswordEntry(userName, password); return true ; } public PasswordEntry retrievePasswordEntry(String id) { return entries.get(id) ; } ...
  • 12. 12 A Password Manager ... @TransactionType(TransactionTypeValue.REQUIRED) public boolean deletePasswordEntry(String id) { return entries.remove(id) != null ; } public Enumeration<String> listIdentifiers() { return entries.keys() ; } }
  • 13. 13 Persistence basics > Persistence by reachability ● Reachability by a root of persistence ● Static field, servlet context, applet object ● All persistent objects stored in persistent memory > Guarantees on persistent objects ● Individual write operations are atomic ● All writes in a transaction are atomic
  • 14. 14 Transaction basics > Inspired from Java EE persistence ● With some specific details ● A smart card is not a database > Three basic principles ● The scope of the transaction is a method ● Commit occurs on normal return ● Abort occurs on exception exit
  • 15. 15 Transaction types > SUPPORTS ● By default, transaction optional > REQUIRED ● When a transaction is needed > REQUIRES_NEW ● For a separate transaction > MANDATORY, NEVER, NOT_SUPPORTED: ● For special cases
  • 16. 16 A Password Servlet package com.vetilles.passwords; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** A Simple Hello Servlet */ public class PassServlet extends HttpServlet { private static PasswordManager manager = new PasswordManager(); ...
  • 17. 17 A Password Servlet @Override public void doGet( HttpServletRequest request, HttpServletResponse response) throws IOException { // First interprets the command String command = request.getServletPath(); // Matches the possible incoming commands if (command.equals("/addentry")) addEntry(request, response); else if (command.equals("/retrieveentry")) retrieveEntry(request, response); else if (command.equals("/deleteentry")) deleteEntry(request, response); else if (command.equals("/listidentifiers")) listIdentifiers(request, response); }
  • 18. 18 A Password Servlet private void addEntry( HttpServletRequest request, HttpServletResponse response) throws IOException { boolean status = manager.addPasswordEntry( request.getParameter("id"), request.getParameter("name"), request.getParameter("pass")) ; PrintWriter out = startResponse(response); if (status) out.println(HTML_ADD_ENTRY_SUCCESS); else out.println(HTML_ADD_ENTRY_FAILED); finishResponse(response); }
  • 19. 19 A Password Servlet private static final String HTML_ADD_ENTRY_SUCCESS = "<p align="center">" + "Password entry added successfully" + "</p><br>"; private static final String HTML_ADD_ENTRY_FAILED = "<p align="center">" + "Password entry addition failed." + "</p>" + "<p align="center">" + "Identifier already in use." + "</p><br>";
  • 20. 20 A Password Servlet private PrintWriter startResponse( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Set content type first response.setContentType("text/html"); // Uses RequestDispatcher to write the header RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/header.i"); dispatcher.include(request, response); // Get PrintWriter object to create response return response.getWriter(); }
  • 21. 21 A Password Servlet private void finishResponse( HttpServletRequest request) HttpServletResponse response) throws IOException { // Uses RequestDispatcher to write the footer RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/footer.i"); dispatcher.include(request, response); }
  • 22. 22 HTML file: header.i <html> <head><title>Password Manager</title></head> <body> <table><tr> <h1 align="center">Password Manager</h1><br> <td><a href="/pass/add.html">Add entry</a></td> <td><a href="/pass/retrieve.html"> Retrieve entry </a></td> <td><a href="/pass/delete.html"> Delete entry </a></td> <td><a href="/pass/listidentifiers"> List identifiers </a></td> </tr></table> <br><br>
  • 24. 24 Access Control > No access control ● The user must be authenticated > Container-managed authentication is possible ● BASIC authentication for simplicity ● FORM-based for more flexibility > Role-based security is available ● Access rights orthogonal to authentication
  • 25. 25 So ? > For Java Card 2.x developers ● Java Card 3.0 is a major breakthrough ● The servlet model is entirely new > For other Java developers ● Java Card 3.0 is more traditional ● Well integrated into standard tool chain ● NetBeans, debugger, etc.
  • 27. 27 What is Wrong with this Application? > Security ● Content is not well protected ● No protection against Web attacks > Performance ● Too much content going back and forth ● Card-specific optimizations
  • 28. 28 Why Protect the Content? > No separation in n tiers ● Data is stored by the presentation application > Smart cards are subject to attacks ● They are a Web server in the attacker's hands ● Attacks on the hardware are possible ● Observation and fault induction attacks > Content is sensitive
  • 29. 29 Secure Storage of Passwords > Issue 1: Upon deletion, passwords must be wiped ● How do you wipe a String? ● Persistent storage must be in a byte array > Issue 2: Passwords should be stored encrypted ● Once again, byte arrays are required > The PasswordEntry class needs some work ● Storage of passwords in encrypted byte arrays
  • 30. 30 Secure Storage of Passwords package com.vetilles.passwords; import javacard.security.DESKey ; import javacard.security.KeyBuilder ; import javacardx.crypto.Cipher ; import javacardx.crypto.RandomData ; public class PasswordEntry { private String userName; private byte[] password; private static DESKey theKey ; private static Cipher cipher ; public PasswordEntry(String userName, String password) { if (theKey == null) initCrypto() ; this.userName = userName; setPassword(password); }
  • 31. 31 Secure Storage of Passwords private static void initCrypto() { // Allocates the objects theKey = (DESKey)KeyBuilder.buildKey( "DES",KeyBuilder.LENGTH_DES3_2KEY, false); cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true); // Generates a random key value RandomData rnd = RandomData.getInstance("SECURE_RANDOM"); byte[] value = new byte[16] ; rnd.generateData(value, (short)0, (short)16); theKey.setKey(value); // Clears the key value before to return rnd.generateData(value, (short)0, (short)16); }
  • 32. 32 Secure Storage of Passwords public void setPassword(String pass) { byte[] bytes = pass.bytes(); password = new byte[bytes.length+9]; cipher.init(theKey,Cipher.MODE_ENCRYPT); password[0] = (byte)cipher.doFinal( bytes, (short)0, (short)bytes.length, password, (short)1 ); } public String getPassword() { byte[] bytes = new byte[password.length]; cipher.init(theKey,Cipher.MODE_DECRYPT); short len = cipher.doFinal( password, (short)1, password[0], bytes, (short)0 ); return new String(bytes,(short)0,len); }
  • 33. 33 Secure Communication > Several issues are present ● All data is transmitted in clear ● Master password is transmitted in clear > One simple solution: SSL ● Supported at the container level ● Not a single line of code ● Only constraint: manage the certificates
  • 34. 34 Web Security > Web applications have many security issues > See OWASP for a starting point ● In particular the “Top 10 Vulnerabilities” > Some countermeasures are required ● Input filtering ● Output canonicalization ● Proper session management
  • 35. 35 Validating Input private void addEntry( HttpServletRequest request, HttpServletResponse response) throws IOException { boolean status ; try { status = manager.addPasswordEntry( validateId(request.getParameter("id")), validateId(request.getParameter("name")), request.getParameter("pass")) ; } catch(Exception e) { sendError(response,e.getMessage()); return; } ... }
  • 36. 36 Validating Input private static final String otherChars = "-_@." ; private String validateId(String id) throws IOException { char[] chars = id.toCharArray() ; for(char c:chars) { if (Character.isDigit(c)) continue; if (Character.isLowerCase(c)) continue; if (Character.isUpperCase(c)) continue; if (otherChars.indexOf(c)!=-1) continue; throw new IOException("Invalid identifier string"); } // If we get here, all characters are acceptable return id ; }
  • 37. 37 Canonicalizing Output > The idea is to make the output innocuous ● Make sure that characters are not interpreted ● The following only works on ASCII characters private String encodeUnverifiedString(String str) { StringBuffer s = new StringBuffer(); char[] chars = str.toCharArray() ; for(char c:chars) { s.append("<span>#&" + Integer.toString(c) + ";</span>"); } return s.toString(); }
  • 38. 38 Communication Performance > Card communication remains slow ● Content production also has limits > Similar to other elements of the “Web of Things” ● Servers are less powerful than clients ● The work must be delegated to clients > Ajax can be used ● Limits the amount of communication ● Limits HTML overhead on the server side
  • 39. 39 Ajax on a Smart Card? > Ajax is an interesting technique ● It is entirely managed on the card ● It uses the client's resources > Aren't there security issues ? ● No, not really ● The browser must be trusted anyway
  • 40. 40 Performance Optimization Persistent memory private static void initCrypto() { // Allocates the objects theKey = (DESKey)KeyBuilder.buildKey( "DES",KeyBuilder.LENGTH_DES3_2KEY, false); cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true); // Generates a random key value RandomData rnd = RandomData.getInstance("SECURE_RANDOM"); byte[] value = new byte[16] ; rnd.generateData(value, (short)0, (short)16); theKey.setKey(value); // Clears the key value before to return rnd.generateData(value, (short)0, (short)16); }
  • 41. 41 Performance Optimization Persistent memory private static void initCrypto() { // Allocates the objects DESKey newKey = (DESKey)KeyBuilder.buildKey( "DES",KeyBuilder.LENGTH_DES3_2KEY, false); cipher = Cipher.getInstance("DES_CBC_ISO9797_M2", true); // Generates a random key value RandomData rnd = RandomData.getInstance("SECURE_RANDOM"); byte[] value = new byte[16] ; rnd.generateData(value, (short)0, (short)16); newKey.setKey(value); // Clears the key value before to return rnd.generateData(value, (short)0, (short)16); // Promotes the key to persistent memory theKey = newKey ; }
  • 42. 42 What more could we do ? > Manage the data in a separate application ● Use sharing to communicate > Add an APDU interface ● Work with legacy smart card applications > Manage our own authenticators ● Rather than use the platform's default ones > Backup our passwords ● Open a connection to a backup server
  • 43. 43 What about Deployment? > Many instances ● Not a single server ● Instead, millions of cards/objects > A mutualized server ● Several providers represented on the server ● Usually, one single issuer (the owner) ● Some resource allocation to manage
  • 44. 44 GlobalPlatform > Card management technology since 1999 ● Standards to deploy/manage applications ● Standards to manage relationships ● Between card issuers and application providers ● Including trusted third parties when needed > Currently being adapted to a Web model ● Update of application management ● Addition of new resources to be managed
  • 46. 46 Issuer-Centric Deployment > Current model for smart cards ● The issuer owns the card > Many deployment options ● The issuer manages all applications ● Simple and practical ● A third party needs to sign all applications ● Practical to enforce issuer policies ● Management can be delegated ● All operations may still be explicitly authorized
  • 47. 47 Alternative Deployment Scenarios > White card schemes ● Very similar to an issuer-centric scheme ● But the “issuer” is an association/public entity > Cardholder-owned cards ● Not the tendency for traditional cards ● Likely trend with smart objects > ...
  • 48. 48 GlobalPlatform Networked Framework > Adapts the existing model to the Web ● HTTP and SSL as transport ● ASN.1 as encoding > Supports specific Web application features ● Management of URIs ● Who can use the http://localhost:8019/google ? ● Management of realms and authenticators ● Who can use the “Visa” authentication realm?
  • 49. 49 Recap > Java Card 3.0 brings Web servers everywhere ● On cards and on other devices ● Using a very classical model > Of course, there is a catch ● Resources are severely limited ● Deployment needs to be carefully planned ● Applications and devices may be linked
  • 50. 50 Getting More Information > Spec and Development Kit ● java.sun.com/products/javacard ● Look at the samples ... > Blogs ● javacard.vetilles.com > Other sessions at JavaOne