SlideShare a Scribd company logo
1 of 57
Download to read offline
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 131
First Steps with Java Card
Eric Vétillard
Sr. Principal Product Manager, Java Card
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132
Java Card Main Use Cases
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133
Smart Cards are About Tamper Resistance
 Tamper resistance is about resisting to attacks
– Not just against software attacks coming from the Web
– Also from all kinds of physical attacks
 Observation attacks, where attackers listen to your device
 Fault attacks, where attackers use lasers and more to derail silicon
 Using a smart card with a Java Card application gives you
– A physical isolation from the client system and the Web
– A physical protection against most direct attackers
Java Card is Java on a smart card
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134
Java Card can Protect Your Credentials
 Your application will most likely manage some credentials
– PIN codes or passwords
– Cryptographic keys
 Java Card products will protect these credentials
– With specific countermeasures on all sensitive classes
– With standard management procedures, such as GlobalPlatform
 You are only responsible for your application logic
Your design, our protection
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135
How Much Should You Know About Security
to Use Java Card?
 Java Card doesn’t require any specific security skill
– It is a dialect of Java targeting smart cards
 Smart card development requires some security skills
– What if your application returns a password as cleartext?
– Some security experience is required
 In particular if you design your own applications
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136
What About Security Certifications?
 Some industries require security certifications
– In most cases, Common Criteria or FIPS140
– For instance, payment, identity, government apps, etc.
 Security certification requires specialized skills
– Not necessarily yours, many consultants are available
 Java Card provides you with significant help
– The most difficult work is done by platform providers
– Application developers only need to “prove” their application secure
 While relying on the Java Card security mechanisms
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137
First Steps with Java Card
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138
 Protect passwords by storing
them in a smart card, using a
Java Card Classic applet
 Make sure to follow best
security practice in this
development
Idea
Example: Password Storage
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139
The Functions
 Keep a base of login records
– Identifier, username, passwords
 Allow basic operations
– Add a new record
– Lookup a record (by identifier)
– List all identifiers
– Modify a record
– Delete a record
Very basic
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310
 Java constructs supported
– Classes, interfaces, …
 Limited basic types
– Byte, short, (int)
– No char, no float
 Limited libraries
– No Strings, no containers
A Subset of Java
Implementation
class PasswordEntry {
private byte[] id;
private byte[] userName;
private byte[] password;
private byte idLength;
private byte userNameLength;
private byte passwordLength;
byte getId(byte[] buf, short ofs) {
return Util.arrayCopy(id, (short)0,
buf, ofs, idLength);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311
 Objects are persistent
– Stored in flash memory
 No garbage collection
– Too time-consuming
– Objects allocated statically
 Back to “classical” algorithms
Specific memory
Implementation
private PasswordEntry next;
private static PasswordEntry first;
private static PasswordEntry deleted;
private PasswordEntry() {
id = new byte[SIZE_ID];
userName = new byte[SIZE_USERNAME];
password = new byte[SIZE_PASSWORD];
// Insert elt in front of list
next = first;
first = this;
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312
 Write operations are dangerous
– Writing is long and error-prone
– Power is external
 Atomicity is required
– Transaction mechanism
– Single write atomicity
Atomicity
Implementation
static PasswordEntry getInstance() {
{
if (deleted == null) {
return new PasswordEntry() ;
} else {
PasswordEntry instance = deleted;
JCSystem.beginTransaction();
deleted = instance.next;
first = instance;
instance.next = first;
JCSystem.commitTransaction();
return instance;
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313
 Write operations are dangerous
– Writing is long and error-prone
– Power is external
 Atomicity is required
– Transaction mechanism
– Single write atomicity
Atomicity
Implementation
static PasswordEntry getInstance() {
{
if (deleted == null) {
return new PasswordEntry() ;
} else {
PasswordEntry instance = deleted;
JCSystem.beginTransaction();
deleted = instance.next;
first = instance;
instance.next = first;
JCSystem.commitTransaction();
return instance;
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314
 Write operations are dangerous
– Writing is long and error-prone
– Power is external
 Atomicity is required
– Transaction mechanism
– Single write atomicity
Atomicity
Implementation
private PasswordEntry next;
private static PasswordEntry first;
private static PasswordEntry deleted;
private PasswordEntry() {
id = new byte[SIZE_ID];
userName = new byte[SIZE_USERNAME];
password = new byte[SIZE_PASSWORD];
// Insert elt in front of list
next = first;
first = this;
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315
Java Card Programming Style
 Need to deal with many constraints
– Very limited memory management
– Limited computing power (except for crypto)
– Limited utility classes
 Automation remains limited, developer needs to think
– Static allocation of objects: counting bytes
– Keeping track of atomicity
– …
Java outside, embedded inside
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316
The Security
 Access control
– Require a master password before to allow usage of the application
– Valid as long as the application is selected
 No secure channel requirement
– A bit optimistic, but assume that there are no hackers on the PC
Analyzing requirements
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317
 Applets are the basic class
– Processing APDU commands
– Following ISO7816 standards
 Security mechanisms are provided
– For instance, a PIN
– With “secure” implementation
Basic framework
Interface and Security
public class PasswordMgr extends Applet {
public final static byte
INS_ADD_PASSWORD_ENTRY = (byte)0x30;
public final static byte
INS_FIND_PASSWORD_ENTRY = (byte)0x32;
public final static byte
INS_LIST_IDENTIFIERS = (byte)0x34;
public final static byte
INS_VERIFY_PIN = (byte)0x38;
private OwnerPIN pin ;
public PasswordMgr() {
pin = new OwnerPIN(3,16);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318
 Applets are the basic class
– Processing APDU commands
– Following ISO7816 standards
 Security mechanisms are provided
– For instance, a PIN
– With “secure” implementation
Basic framework
Interface and Security
public class PasswordMgr extends Applet {
public final static byte
INS_ADD_PASSWORD_ENTRY = (byte)0x30;
public final static byte
INS_FIND_PASSWORD_ENTRY = (byte)0x32;
public final static byte
INS_LIST_IDENTIFIERS = (byte)0x34;
public final static byte
INS_VERIFY_PIN = (byte)0x38;
private OwnerPIN pin ;
public PasswordMgr() {
pin = new OwnerPIN(3,16);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319
 Applets are the basic class
– Processing APDU commands
– Following ISO7816 standards
 Security mechanisms are provided
– For instance, a PIN
– With “secure” implementation
Basic framework
Interface and Security
public class PasswordMgr extends Applet {
public final static byte
INS_ADD_PASSWORD_ENTRY = (byte)0x30;
public final static byte
INS_FIND_PASSWORD_ENTRY = (byte)0x32;
public final static byte
INS_LIST_IDENTIFIERS = (byte)0x34;
public final static byte
INS_VERIFY_PIN = (byte)0x38;
private OwnerPIN pin ;
public PasswordMgr() {
pin = new OwnerPIN(3,16);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320
 Applets are the basic class
– Processing APDU commands
– Following ISO7816 standards
 Security mechanisms are provided
– For instance, a PIN
– With “secure” implementation
Basic framework
Interface and Security
public class PasswordMgr extends Applet {
public final static byte
INS_ADD_PASSWORD_ENTRY = (byte)0x30;
public final static byte
INS_FIND_PASSWORD_ENTRY = (byte)0x32;
public final static byte
INS_LIST_IDENTIFIERS = (byte)0x34;
public final static byte
INS_VERIFY_PIN = (byte)0x38;
private OwnerPIN pin ;
public PasswordMgr() {
pin = new OwnerPIN(3,16);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321
 Applets are the basic class
– Processing APDU commands
– Following ISO7816 standards
 Security mechanisms are provided
– For instance, a PIN
– With “secure” implementation
Basic framework
Interface and Security
public class PasswordMgr extends Applet {
public final static byte
INS_ADD_PASSWORD_ENTRY = (byte)0x30;
public final static byte
INS_FIND_PASSWORD_ENTRY = (byte)0x32;
public final static byte
INS_LIST_IDENTIFIERS = (byte)0x34;
public final static byte
INS_VERIFY_PIN = (byte)0x38;
private OwnerPIN pin ;
public PasswordMgr() {
pin = new OwnerPIN(3,16);
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322
 Applets need to be installed
– Instantiation and registration
 Applets need to be selected
– Session data is initialized
 Deselection is also provided
– To clear some things
Lifecycle and sessions
Interface and Security
public static void install(
byte[] ba, short ofs, byte len) {
(new PasswordMgr()).register(
ba, (short)(ofs+1), ba[ofs]);
}
public boolean select() {
return true;
}
public void deselect() {
pin.reset();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323
 Applets need to be installed
– Instantiation and registration
 Applets need to be selected
– Session data is initialized
 Deselection is also provided
– To clear some things
Lifecycle and sessions
Interface and Security
public static void install(
byte[] ba, short ofs, byte len) {
(new PasswordMgr()).register(
ba, (short)(ofs+1), ba[ofs]);
}
public boolean select() {
return true;
}
public void deselect() {
pin.reset();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324
 Applets need to be installed
– Instantiation and registration
 Applets need to be selected
– Session data is initialized
 Deselection is also provided
– To clear some things
Lifecycle and sessions
Interface and Security
public static void install(
byte[] ba, short ofs, byte len) {
(new PasswordMgr()).register(
ba, (short)(ofs+1), ba[ofs]);
}
public boolean select() {
return true;
}
public void deselect() {
pin.reset();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325
 Applets need to be installed
– Instantiation and registration
 Applets need to be selected
– Session data is initialized
 Deselection is also provided
– To clear some things
Lifecycle and sessions
Interface and Security
public static void install(
byte[] ba, short ofs, byte len) {
(new PasswordMgr()).register(
ba, (short)(ofs+1), ba[ofs]);
}
public boolean select() {
return true;
}
public void deselect() {
pin.reset();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326
 Applets need to be installed
– Instantiation and registration
 Applets need to be selected
– Session data is initialized
 Deselection is also provided
– To clear some things
Lifecycle and sessions
Interface and Security
public static void install(
byte[] ba, short ofs, byte len) {
(new PasswordMgr()).register(
ba, (short)(ofs+1), ba[ofs]);
}
public boolean select() {
return true;
}
public void deselect() {
pin.reset();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Deselection is also provided
– To clear some things
Processing commands
Interface and Security
public void process(APDU apdu) {
if (selectingApplet()) return;
byte[] buf = apdu.getBuffer();
switch(buf[ISO7816.OFFSET_INS]) {
case (byte)INS_ADD_PASSWORD_ENTRY:
checkAuthenticated();
processAddPasswordEntry(apdu);
break;
case (byte)INS_VERIFY_PIN:
processVerifyPIN(apdu);
break;
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Deselection is also provided
– To clear some things
Processing commands
Interface and Security
public void process(APDU apdu) {
if (selectingApplet()) return;
byte[] buf = apdu.getBuffer();
switch(buf[ISO7816.OFFSET_INS]) {
case (byte)INS_ADD_PASSWORD_ENTRY:
checkAuthenticated();
processAddPasswordEntry(apdu);
break;
case (byte)INS_VERIFY_PIN:
processVerifyPIN(apdu);
break;
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Deselection is also provided
– To clear some things
Processing commands
Interface and Security
public void process(APDU apdu) {
if (selectingApplet()) return;
byte[] buf = apdu.getBuffer();
switch(buf[ISO7816.OFFSET_INS]) {
case (byte)INS_ADD_PASSWORD_ENTRY:
checkAuthenticated();
processAddPasswordEntry(apdu);
break;
case (byte)INS_VERIFY_PIN:
processVerifyPIN(apdu);
break;
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Deselection is also provided
– To clear some things
Processing commands
Interface and Security
public void process(APDU apdu) {
if (selectingApplet()) return;
byte[] buf = apdu.getBuffer();
switch(buf[ISO7816.OFFSET_INS]) {
case (byte)INS_ADD_PASSWORD_ENTRY:
checkAuthenticated();
processAddPasswordEntry(apdu);
break;
case (byte)INS_VERIFY_PIN:
processVerifyPIN(apdu);
break;
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
public void checkAuthenticated() {
if (pin.isValidated()) return;
ISOException.throwIt(
ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
public void verifyPIN(APDU apdu) {
byte[] buf = apdu.getBuffer();
if (Util.getShort(buf,
ISO7816.OFFSET_P1)!=0x80)
ISOException.throwIt(
ISO7816.SW_INCORRECT_P1P2);
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1332
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
public void checkAuthenticated() {
if (pin.isValidated()) return;
ISOException.throwIt(
ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
public void verifyPIN(APDU apdu) {
byte[] buf = apdu.getBuffer();
if (Util.getShort(buf,
ISO7816.OFFSET_P1)!=0x80)
ISOException.throwIt(
ISO7816.SW_INCORRECT_P1P2);
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
public void checkAuthenticated() {
if (pin.isValidated()) return;
ISOException.throwIt(
ISO7816.SW_CONDITIONS_NOT_SATISFIED);
}
public void verifyPIN(APDU apdu) {
byte[] buf = apdu.getBuffer();
if (Util.getShort(buf,
ISO7816.OFFSET_P1)!=0x80)
ISOException.throwIt(
ISO7816.SW_INCORRECT_P1P2);
…
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1334
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
if (buf[ISO7816.OFFSET_LC]==0) {
if (pin.isValidated())
return;
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN +
pin.getTriesRemaining()) ;
}
short len = APDU.setIncomingAndReceive();
verify(buf, ISO7816.OFFSET_CDATA,
(byte)len);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1335
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
if (buf[ISO7816.OFFSET_LC]==0) {
if (pin.isValidated())
return;
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN +
pin.getTriesRemaining()) ;
}
short len = APDU.setIncomingAndReceive();
verify(buf, ISO7816.OFFSET_CDATA,
(byte)len);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1336
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
if (buf[ISO7816.OFFSET_LC]==0) {
if (pin.isValidated())
return;
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN +
pin.getTriesRemaining()) ;
}
short len = APDU.setIncomingAndReceive();
verify(buf, ISO7816.OFFSET_CDATA,
(byte)len);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1337
 The JCRE invokes a method
– Passing the command
– Using a dedicated class
 The buffer is used in most cases
– Following ISO7816
 Everything is checked
– To strictly cover the spec
Processing commands
Interface and Security
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
if (buf[ISO7816.OFFSET_LC]==0) {
if (pin.isValidated())
return;
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN +
pin.getTriesRemaining()) ;
}
short len = APDU.setIncomingAndReceive();
verify(buf, ISO7816.OFFSET_CDATA,
(byte)len);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1338
 First the initial checks
– Here, checking the PIN length
– Always check everything
 Then, the comparison
 And then the result
– Building the right response
Verifying a PIN
Interface and Security
void verify(
byte[] buf, short ofs, byte len) {
if (len > 16) ISOException.throwIt(
ISO7816.SW_WRONG_DATA);
if (!pin.check(buffer,ofs, len) {
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN+
pin.getTriesRemaining());
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1339
 First the initial checks
– Here, checking the PIN length
– Always check everything
 Then, the comparison
 And then the result
– Building the right response
Verifying a PIN
Interface and Security
void verify(
byte[] buf, short ofs, byte len) {
if (len > 16) ISOException.throwIt(
ISO7816.SW_WRONG_DATA);
if (!pin.check(buffer,ofs, len) {
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN+
pin.getTriesRemaining());
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1340
 First the initial checks
– Here, checking the PIN length
– Always check everything
 Then, the comparison
 And then the result
– Building the right response
Verifying a PIN
Interface and Security
void verify(
byte[] buf, short ofs, byte len) {
if (len > 16) ISOException.throwIt(
ISO7816.SW_WRONG_DATA);
if (!pin.check(buffer,ofs, len) {
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN+
pin.getTriesRemaining());
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1341
 First the initial checks
– Here, checking the PIN length
– Always check everything
 Then, the comparison
 And then the result
– Building the right response
Verifying a PIN
Interface and Security
void verify(
byte[] buf, short ofs, byte len) {
if (len > 16) ISOException.throwIt(
ISO7816.SW_WRONG_DATA);
if (!pin.check(buffer,ofs, len) {
if (pin.getTriesRemaining()==0)
ISOException.throwIt(
ISO7816.SW_DATA_INVALID);
else
ISOException.throwIt(
ISO7816.SW_WRONG_PIN+
pin.getTriesRemaining());
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1342
The Security
 What if the user forgets the password or loses the card?
– A backup can be produced, encrypted with a key
 How to protect the backup?
– With a secret key, if this is for private use
 Then, don’t forget/lose the key
– With a public key, if this is in a commercial offer
 Decryption requires fee payment, and offline authentication method
 Smart cards don’t solve all the problems …
Tricky stuff
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1343
The Security
 Remember why you are using a smart card
– Because is it tamper-resistant
– So, what happens when the card is under attack?
 Under attack, some countermeasures are activated
– At the hardware level
– At the system software level
– At the application software level
Protecting against attacks
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1344
The Security
 A typical attack consists in leaking information from the card
– Many different ways of doing it, many countermeasures too
– Typical application-level countermeasure:
 Assume that the other countermeasures have failed
 Encrypt your data to make it unexploitable
 Another attack consists in provoking faults in the execution
– Shorting the silicon, exploiting physics
– In software, redundancy is the only direct countermeasure
What attacks? What countermeasures?
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1345
 Java is practical here
– Encapsulation works
– Encryption is local to class
 Java Card crypto is simple
– Inspired from JCE
– Implementation protects keys
Encrypting objects
Protecting Against Observation Attacks
byte getUserName(byte[] buf, short ofs) {
unCipher.init(unKey,Cipher.MODE_DECRYPT);
unCipher.doFinal(userName, (short)0,
userName.length, buf, ofs);
return getUserNameLength();
}
byte getPassword(byte[] buf, short ofs) {
password.getKey(buf,ofs);
return getPasswordLength();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1346
 Java is practical here
– Encapsulation works
– Encryption is local to class
 Java Card crypto is simple
– Inspired from JCE
– Implementation protects keys
Encrypting objects
Protecting Against Observation Attacks
byte getUserName(byte[] buf, short ofs) {
unCipher.init(unKey,Cipher.MODE_DECRYPT);
unCipher.doFinal(userName, (short)0,
userName.length, buf, ofs);
return getUserNameLength();
}
byte getPassword(byte[] buf, short ofs) {
password.getKey(buf,ofs);
return getPasswordLength();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1347
 Java is practical here
– Encapsulation works
– Encryption is local to class
 Java Card crypto is simple
– Inspired from JCE
– Implementation protects keys
Encrypting objects
Protecting Against Observation Attacks
byte getUserName(byte[] buf, short ofs) {
unCipher.init(unKey,Cipher.MODE_DECRYPT);
unCipher.doFinal(userName, (short)0,
userName.length, buf, ofs);
return getUserNameLength();
}
byte getPassword(byte[] buf, short ofs) {
password.getKey(buf,ofs);
return getPasswordLength();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1348
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1349
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1350
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1351
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1352
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1353
 Java is not really practical here
– Encapsulation doesn’t work
– Checks are everywhere
– Code is very hard to read
 Requires some specific skills
– Not that hard to acquire
Adding redundancy
Protecting Against Fault Attacks
boolean verify(
byte[] buf, short ofs, byte len) {
byte tl = triesLeft;
if (tl != (short)(~triesLeftBak))
takeCountermeasure();
if (tl<=0) return false;
JCSystem.beginTransaction();
triesLeft = --tl;
triesLeftBak++;
JCSystem.commitTransaction();
if (triesLeft != (short)(~triesLeftBak))
takeCountermeasure();
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1354
Java Card is Simple
 Using Java Card is rather simple
– Allows you to program card applications
– Provides access to required functions such as PIN and cryptography
 Your applications are not simple
– They are part of a larger, more complex system
– If they need to be on a card, it is most likely for security reasons
– Security engineering will consume most of your time
Security is complex
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1355
Some References
 The reference from Oracle
– www.oracle.com/technetwork/java/javame/javacard/
 A tutorial with the rest of today’s example
– javacard.vetilles.com/tutorial/
 GlobalPlatform’s Web site
– www.globalplatform.org
Getting started
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1356
Graphic Section Divider
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1357

More Related Content

What's hot

JavaCard development Quickstart
JavaCard development QuickstartJavaCard development Quickstart
JavaCard development QuickstartMartin Paljak
 
Security applications with Java Card
Security applications with Java CardSecurity applications with Java Card
Security applications with Java CardJulien SIMON
 
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
 
From Bitcoin Hardware Wallets to Personal Privacy Devices
From Bitcoin Hardware Wallets to Personal Privacy DevicesFrom Bitcoin Hardware Wallets to Personal Privacy Devices
From Bitcoin Hardware Wallets to Personal Privacy DevicesMecklerMedia
 
Government Citizen ID using Java Card Platform
Government Citizen ID using Java Card PlatformGovernment Citizen ID using Java Card Platform
Government Citizen ID using Java Card PlatformRamesh Nagappan
 
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, ArduinoParis Open Source Summit
 

What's hot (11)

JavaCard development Quickstart
JavaCard development QuickstartJavaCard development Quickstart
JavaCard development Quickstart
 
Javacard
Javacard Javacard
Javacard
 
Security applications with Java Card
Security applications with Java CardSecurity applications with Java Card
Security applications with Java Card
 
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
Java cardJava card
Java card
 
Java card
Java cardJava card
Java card
 
Java card
Java card Java card
Java card
 
Java card technology
Java card technologyJava card technology
Java card technology
 
From Bitcoin Hardware Wallets to Personal Privacy Devices
From Bitcoin Hardware Wallets to Personal Privacy DevicesFrom Bitcoin Hardware Wallets to Personal Privacy Devices
From Bitcoin Hardware Wallets to Personal Privacy Devices
 
Government Citizen ID using Java Card Platform
Government Citizen ID using Java Card PlatformGovernment Citizen ID using Java Card Platform
Government Citizen ID using Java Card Platform
 
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
#OSSPARIS19 : The evolving (IoT) security landscape - Gianluca Varisco, Arduino
 

Similar to 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-EnterpriseEric Vétillard
 
Java API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishJava API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishArun Gupta
 
CSE_Instructor_Materials_Chapter7.pptx
CSE_Instructor_Materials_Chapter7.pptxCSE_Instructor_Materials_Chapter7.pptx
CSE_Instructor_Materials_Chapter7.pptxMohammad512578
 
Architecture performance and tips and tricks for instantis enterprise track 8...
Architecture performance and tips and tricks for instantis enterprise track 8...Architecture performance and tips and tricks for instantis enterprise track 8...
Architecture performance and tips and tricks for instantis enterprise track 8...p6academy
 
MySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL Brasil
 
iPhone and iPad Security
iPhone and iPad SecurityiPhone and iPad Security
iPhone and iPad SecuritySimon Guest
 
Tips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramTips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramBeyondTrust
 
IBM Share Conference 2010, Boston, Ulf Mattsson
IBM Share Conference 2010, Boston, Ulf MattssonIBM Share Conference 2010, Boston, Ulf Mattsson
IBM Share Conference 2010, Boston, Ulf MattssonUlf Mattsson
 
Droidcon secureyourapp fighttheleaks-samsung
Droidcon secureyourapp fighttheleaks-samsungDroidcon secureyourapp fighttheleaks-samsung
Droidcon secureyourapp fighttheleaks-samsungottot
 
CiNPA Security SIG - Exploiting the Tiredful API
CiNPA Security SIG - Exploiting the Tiredful APICiNPA Security SIG - Exploiting the Tiredful API
CiNPA Security SIG - Exploiting the Tiredful APICiNPA Security SIG
 
ITE v5.0 - Chapter 10
ITE v5.0 - Chapter 10ITE v5.0 - Chapter 10
ITE v5.0 - Chapter 10Irsandi Hasan
 
Александр Ильин, Oracle
Александр Ильин, OracleАлександр Ильин, Oracle
Александр Ильин, OracleNata_Churda
 
Architecting Secure Web Systems
Architecting Secure Web SystemsArchitecting Secure Web Systems
Architecting Secure Web SystemsInnoTech
 
Oracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and MaskingOracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and MaskingDLT Solutions
 
Database Systems Security
Database Systems SecurityDatabase Systems Security
Database Systems Securityamiable_indian
 
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection System
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection SystemIRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection System
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection SystemIRJET Journal
 
Security Best Practices
Security Best PracticesSecurity Best Practices
Security Best PracticesClint Edmonson
 

Similar to First Steps with Java Card (20)

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
 
Java API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFishJava API for WebSocket 1.0: Java EE 7 and GlassFish
Java API for WebSocket 1.0: Java EE 7 and GlassFish
 
CSE_Instructor_Materials_Chapter7.pptx
CSE_Instructor_Materials_Chapter7.pptxCSE_Instructor_Materials_Chapter7.pptx
CSE_Instructor_Materials_Chapter7.pptx
 
Architecture performance and tips and tricks for instantis enterprise track 8...
Architecture performance and tips and tricks for instantis enterprise track 8...Architecture performance and tips and tricks for instantis enterprise track 8...
Architecture performance and tips and tricks for instantis enterprise track 8...
 
MySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de GamesMySQL para Desenvolvedores de Games
MySQL para Desenvolvedores de Games
 
iPhone and iPad Security
iPhone and iPad SecurityiPhone and iPad Security
iPhone and iPad Security
 
Tips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramTips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management Program
 
IBM Share Conference 2010, Boston, Ulf Mattsson
IBM Share Conference 2010, Boston, Ulf MattssonIBM Share Conference 2010, Boston, Ulf Mattsson
IBM Share Conference 2010, Boston, Ulf Mattsson
 
Droidcon secureyourapp fighttheleaks-samsung
Droidcon secureyourapp fighttheleaks-samsungDroidcon secureyourapp fighttheleaks-samsung
Droidcon secureyourapp fighttheleaks-samsung
 
CiNPA Security SIG - Exploiting the Tiredful API
CiNPA Security SIG - Exploiting the Tiredful APICiNPA Security SIG - Exploiting the Tiredful API
CiNPA Security SIG - Exploiting the Tiredful API
 
ITE v5.0 - Chapter 10
ITE v5.0 - Chapter 10ITE v5.0 - Chapter 10
ITE v5.0 - Chapter 10
 
Александр Ильин, Oracle
Александр Ильин, OracleАлександр Ильин, Oracle
Александр Ильин, Oracle
 
Architecting Secure Web Systems
Architecting Secure Web SystemsArchitecting Secure Web Systems
Architecting Secure Web Systems
 
Oracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and MaskingOracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and Masking
 
Database Systems Security
Database Systems SecurityDatabase Systems Security
Database Systems Security
 
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection System
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection SystemIRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection System
IRJET- Preventing of Key-Recovery Attacks on Keyed Intrusion Detection System
 
Cisco SecureX.pdf
Cisco SecureX.pdfCisco SecureX.pdf
Cisco SecureX.pdf
 
Security
SecuritySecurity
Security
 
Security Best Practices
Security Best PracticesSecurity Best Practices
Security Best Practices
 
Secure pl-sql-coding
Secure pl-sql-codingSecure pl-sql-coding
Secure pl-sql-coding
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

First Steps with Java Card

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 131 First Steps with Java Card Eric Vétillard Sr. Principal Product Manager, Java Card
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132 Java Card Main Use Cases
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133 Smart Cards are About Tamper Resistance  Tamper resistance is about resisting to attacks – Not just against software attacks coming from the Web – Also from all kinds of physical attacks  Observation attacks, where attackers listen to your device  Fault attacks, where attackers use lasers and more to derail silicon  Using a smart card with a Java Card application gives you – A physical isolation from the client system and the Web – A physical protection against most direct attackers Java Card is Java on a smart card
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134 Java Card can Protect Your Credentials  Your application will most likely manage some credentials – PIN codes or passwords – Cryptographic keys  Java Card products will protect these credentials – With specific countermeasures on all sensitive classes – With standard management procedures, such as GlobalPlatform  You are only responsible for your application logic Your design, our protection
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135 How Much Should You Know About Security to Use Java Card?  Java Card doesn’t require any specific security skill – It is a dialect of Java targeting smart cards  Smart card development requires some security skills – What if your application returns a password as cleartext? – Some security experience is required  In particular if you design your own applications
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136 What About Security Certifications?  Some industries require security certifications – In most cases, Common Criteria or FIPS140 – For instance, payment, identity, government apps, etc.  Security certification requires specialized skills – Not necessarily yours, many consultants are available  Java Card provides you with significant help – The most difficult work is done by platform providers – Application developers only need to “prove” their application secure  While relying on the Java Card security mechanisms
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137 First Steps with Java Card
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138  Protect passwords by storing them in a smart card, using a Java Card Classic applet  Make sure to follow best security practice in this development Idea Example: Password Storage
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139 The Functions  Keep a base of login records – Identifier, username, passwords  Allow basic operations – Add a new record – Lookup a record (by identifier) – List all identifiers – Modify a record – Delete a record Very basic
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310  Java constructs supported – Classes, interfaces, …  Limited basic types – Byte, short, (int) – No char, no float  Limited libraries – No Strings, no containers A Subset of Java Implementation class PasswordEntry { private byte[] id; private byte[] userName; private byte[] password; private byte idLength; private byte userNameLength; private byte passwordLength; byte getId(byte[] buf, short ofs) { return Util.arrayCopy(id, (short)0, buf, ofs, idLength); }
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311  Objects are persistent – Stored in flash memory  No garbage collection – Too time-consuming – Objects allocated statically  Back to “classical” algorithms Specific memory Implementation private PasswordEntry next; private static PasswordEntry first; private static PasswordEntry deleted; private PasswordEntry() { id = new byte[SIZE_ID]; userName = new byte[SIZE_USERNAME]; password = new byte[SIZE_PASSWORD]; // Insert elt in front of list next = first; first = this; }
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312  Write operations are dangerous – Writing is long and error-prone – Power is external  Atomicity is required – Transaction mechanism – Single write atomicity Atomicity Implementation static PasswordEntry getInstance() { { if (deleted == null) { return new PasswordEntry() ; } else { PasswordEntry instance = deleted; JCSystem.beginTransaction(); deleted = instance.next; first = instance; instance.next = first; JCSystem.commitTransaction(); return instance; } }
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313  Write operations are dangerous – Writing is long and error-prone – Power is external  Atomicity is required – Transaction mechanism – Single write atomicity Atomicity Implementation static PasswordEntry getInstance() { { if (deleted == null) { return new PasswordEntry() ; } else { PasswordEntry instance = deleted; JCSystem.beginTransaction(); deleted = instance.next; first = instance; instance.next = first; JCSystem.commitTransaction(); return instance; } }
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314  Write operations are dangerous – Writing is long and error-prone – Power is external  Atomicity is required – Transaction mechanism – Single write atomicity Atomicity Implementation private PasswordEntry next; private static PasswordEntry first; private static PasswordEntry deleted; private PasswordEntry() { id = new byte[SIZE_ID]; userName = new byte[SIZE_USERNAME]; password = new byte[SIZE_PASSWORD]; // Insert elt in front of list next = first; first = this; }
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315 Java Card Programming Style  Need to deal with many constraints – Very limited memory management – Limited computing power (except for crypto) – Limited utility classes  Automation remains limited, developer needs to think – Static allocation of objects: counting bytes – Keeping track of atomicity – … Java outside, embedded inside
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316 The Security  Access control – Require a master password before to allow usage of the application – Valid as long as the application is selected  No secure channel requirement – A bit optimistic, but assume that there are no hackers on the PC Analyzing requirements
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317  Applets are the basic class – Processing APDU commands – Following ISO7816 standards  Security mechanisms are provided – For instance, a PIN – With “secure” implementation Basic framework Interface and Security public class PasswordMgr extends Applet { public final static byte INS_ADD_PASSWORD_ENTRY = (byte)0x30; public final static byte INS_FIND_PASSWORD_ENTRY = (byte)0x32; public final static byte INS_LIST_IDENTIFIERS = (byte)0x34; public final static byte INS_VERIFY_PIN = (byte)0x38; private OwnerPIN pin ; public PasswordMgr() { pin = new OwnerPIN(3,16); }
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318  Applets are the basic class – Processing APDU commands – Following ISO7816 standards  Security mechanisms are provided – For instance, a PIN – With “secure” implementation Basic framework Interface and Security public class PasswordMgr extends Applet { public final static byte INS_ADD_PASSWORD_ENTRY = (byte)0x30; public final static byte INS_FIND_PASSWORD_ENTRY = (byte)0x32; public final static byte INS_LIST_IDENTIFIERS = (byte)0x34; public final static byte INS_VERIFY_PIN = (byte)0x38; private OwnerPIN pin ; public PasswordMgr() { pin = new OwnerPIN(3,16); }
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319  Applets are the basic class – Processing APDU commands – Following ISO7816 standards  Security mechanisms are provided – For instance, a PIN – With “secure” implementation Basic framework Interface and Security public class PasswordMgr extends Applet { public final static byte INS_ADD_PASSWORD_ENTRY = (byte)0x30; public final static byte INS_FIND_PASSWORD_ENTRY = (byte)0x32; public final static byte INS_LIST_IDENTIFIERS = (byte)0x34; public final static byte INS_VERIFY_PIN = (byte)0x38; private OwnerPIN pin ; public PasswordMgr() { pin = new OwnerPIN(3,16); }
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320  Applets are the basic class – Processing APDU commands – Following ISO7816 standards  Security mechanisms are provided – For instance, a PIN – With “secure” implementation Basic framework Interface and Security public class PasswordMgr extends Applet { public final static byte INS_ADD_PASSWORD_ENTRY = (byte)0x30; public final static byte INS_FIND_PASSWORD_ENTRY = (byte)0x32; public final static byte INS_LIST_IDENTIFIERS = (byte)0x34; public final static byte INS_VERIFY_PIN = (byte)0x38; private OwnerPIN pin ; public PasswordMgr() { pin = new OwnerPIN(3,16); }
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321  Applets are the basic class – Processing APDU commands – Following ISO7816 standards  Security mechanisms are provided – For instance, a PIN – With “secure” implementation Basic framework Interface and Security public class PasswordMgr extends Applet { public final static byte INS_ADD_PASSWORD_ENTRY = (byte)0x30; public final static byte INS_FIND_PASSWORD_ENTRY = (byte)0x32; public final static byte INS_LIST_IDENTIFIERS = (byte)0x34; public final static byte INS_VERIFY_PIN = (byte)0x38; private OwnerPIN pin ; public PasswordMgr() { pin = new OwnerPIN(3,16); }
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322  Applets need to be installed – Instantiation and registration  Applets need to be selected – Session data is initialized  Deselection is also provided – To clear some things Lifecycle and sessions Interface and Security public static void install( byte[] ba, short ofs, byte len) { (new PasswordMgr()).register( ba, (short)(ofs+1), ba[ofs]); } public boolean select() { return true; } public void deselect() { pin.reset(); }
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323  Applets need to be installed – Instantiation and registration  Applets need to be selected – Session data is initialized  Deselection is also provided – To clear some things Lifecycle and sessions Interface and Security public static void install( byte[] ba, short ofs, byte len) { (new PasswordMgr()).register( ba, (short)(ofs+1), ba[ofs]); } public boolean select() { return true; } public void deselect() { pin.reset(); }
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324  Applets need to be installed – Instantiation and registration  Applets need to be selected – Session data is initialized  Deselection is also provided – To clear some things Lifecycle and sessions Interface and Security public static void install( byte[] ba, short ofs, byte len) { (new PasswordMgr()).register( ba, (short)(ofs+1), ba[ofs]); } public boolean select() { return true; } public void deselect() { pin.reset(); }
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325  Applets need to be installed – Instantiation and registration  Applets need to be selected – Session data is initialized  Deselection is also provided – To clear some things Lifecycle and sessions Interface and Security public static void install( byte[] ba, short ofs, byte len) { (new PasswordMgr()).register( ba, (short)(ofs+1), ba[ofs]); } public boolean select() { return true; } public void deselect() { pin.reset(); }
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1326  Applets need to be installed – Instantiation and registration  Applets need to be selected – Session data is initialized  Deselection is also provided – To clear some things Lifecycle and sessions Interface and Security public static void install( byte[] ba, short ofs, byte len) { (new PasswordMgr()).register( ba, (short)(ofs+1), ba[ofs]); } public boolean select() { return true; } public void deselect() { pin.reset(); }
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1327  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Deselection is also provided – To clear some things Processing commands Interface and Security public void process(APDU apdu) { if (selectingApplet()) return; byte[] buf = apdu.getBuffer(); switch(buf[ISO7816.OFFSET_INS]) { case (byte)INS_ADD_PASSWORD_ENTRY: checkAuthenticated(); processAddPasswordEntry(apdu); break; case (byte)INS_VERIFY_PIN: processVerifyPIN(apdu); break; …
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1328  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Deselection is also provided – To clear some things Processing commands Interface and Security public void process(APDU apdu) { if (selectingApplet()) return; byte[] buf = apdu.getBuffer(); switch(buf[ISO7816.OFFSET_INS]) { case (byte)INS_ADD_PASSWORD_ENTRY: checkAuthenticated(); processAddPasswordEntry(apdu); break; case (byte)INS_VERIFY_PIN: processVerifyPIN(apdu); break; …
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1329  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Deselection is also provided – To clear some things Processing commands Interface and Security public void process(APDU apdu) { if (selectingApplet()) return; byte[] buf = apdu.getBuffer(); switch(buf[ISO7816.OFFSET_INS]) { case (byte)INS_ADD_PASSWORD_ENTRY: checkAuthenticated(); processAddPasswordEntry(apdu); break; case (byte)INS_VERIFY_PIN: processVerifyPIN(apdu); break; …
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1330  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Deselection is also provided – To clear some things Processing commands Interface and Security public void process(APDU apdu) { if (selectingApplet()) return; byte[] buf = apdu.getBuffer(); switch(buf[ISO7816.OFFSET_INS]) { case (byte)INS_ADD_PASSWORD_ENTRY: checkAuthenticated(); processAddPasswordEntry(apdu); break; case (byte)INS_VERIFY_PIN: processVerifyPIN(apdu); break; …
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1331  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security public void checkAuthenticated() { if (pin.isValidated()) return; ISOException.throwIt( ISO7816.SW_CONDITIONS_NOT_SATISFIED); } public void verifyPIN(APDU apdu) { byte[] buf = apdu.getBuffer(); if (Util.getShort(buf, ISO7816.OFFSET_P1)!=0x80) ISOException.throwIt( ISO7816.SW_INCORRECT_P1P2); …
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1332  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security public void checkAuthenticated() { if (pin.isValidated()) return; ISOException.throwIt( ISO7816.SW_CONDITIONS_NOT_SATISFIED); } public void verifyPIN(APDU apdu) { byte[] buf = apdu.getBuffer(); if (Util.getShort(buf, ISO7816.OFFSET_P1)!=0x80) ISOException.throwIt( ISO7816.SW_INCORRECT_P1P2); …
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1333  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security public void checkAuthenticated() { if (pin.isValidated()) return; ISOException.throwIt( ISO7816.SW_CONDITIONS_NOT_SATISFIED); } public void verifyPIN(APDU apdu) { byte[] buf = apdu.getBuffer(); if (Util.getShort(buf, ISO7816.OFFSET_P1)!=0x80) ISOException.throwIt( ISO7816.SW_INCORRECT_P1P2); …
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1334  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); if (buf[ISO7816.OFFSET_LC]==0) { if (pin.isValidated()) return; else ISOException.throwIt( ISO7816.SW_WRONG_PIN + pin.getTriesRemaining()) ; } short len = APDU.setIncomingAndReceive(); verify(buf, ISO7816.OFFSET_CDATA, (byte)len);
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1335  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); if (buf[ISO7816.OFFSET_LC]==0) { if (pin.isValidated()) return; else ISOException.throwIt( ISO7816.SW_WRONG_PIN + pin.getTriesRemaining()) ; } short len = APDU.setIncomingAndReceive(); verify(buf, ISO7816.OFFSET_CDATA, (byte)len);
  • 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1336  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); if (buf[ISO7816.OFFSET_LC]==0) { if (pin.isValidated()) return; else ISOException.throwIt( ISO7816.SW_WRONG_PIN + pin.getTriesRemaining()) ; } short len = APDU.setIncomingAndReceive(); verify(buf, ISO7816.OFFSET_CDATA, (byte)len);
  • 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1337  The JCRE invokes a method – Passing the command – Using a dedicated class  The buffer is used in most cases – Following ISO7816  Everything is checked – To strictly cover the spec Processing commands Interface and Security if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); if (buf[ISO7816.OFFSET_LC]==0) { if (pin.isValidated()) return; else ISOException.throwIt( ISO7816.SW_WRONG_PIN + pin.getTriesRemaining()) ; } short len = APDU.setIncomingAndReceive(); verify(buf, ISO7816.OFFSET_CDATA, (byte)len);
  • 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1338  First the initial checks – Here, checking the PIN length – Always check everything  Then, the comparison  And then the result – Building the right response Verifying a PIN Interface and Security void verify( byte[] buf, short ofs, byte len) { if (len > 16) ISOException.throwIt( ISO7816.SW_WRONG_DATA); if (!pin.check(buffer,ofs, len) { if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); else ISOException.throwIt( ISO7816.SW_WRONG_PIN+ pin.getTriesRemaining()); } }
  • 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1339  First the initial checks – Here, checking the PIN length – Always check everything  Then, the comparison  And then the result – Building the right response Verifying a PIN Interface and Security void verify( byte[] buf, short ofs, byte len) { if (len > 16) ISOException.throwIt( ISO7816.SW_WRONG_DATA); if (!pin.check(buffer,ofs, len) { if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); else ISOException.throwIt( ISO7816.SW_WRONG_PIN+ pin.getTriesRemaining()); } }
  • 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1340  First the initial checks – Here, checking the PIN length – Always check everything  Then, the comparison  And then the result – Building the right response Verifying a PIN Interface and Security void verify( byte[] buf, short ofs, byte len) { if (len > 16) ISOException.throwIt( ISO7816.SW_WRONG_DATA); if (!pin.check(buffer,ofs, len) { if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); else ISOException.throwIt( ISO7816.SW_WRONG_PIN+ pin.getTriesRemaining()); } }
  • 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1341  First the initial checks – Here, checking the PIN length – Always check everything  Then, the comparison  And then the result – Building the right response Verifying a PIN Interface and Security void verify( byte[] buf, short ofs, byte len) { if (len > 16) ISOException.throwIt( ISO7816.SW_WRONG_DATA); if (!pin.check(buffer,ofs, len) { if (pin.getTriesRemaining()==0) ISOException.throwIt( ISO7816.SW_DATA_INVALID); else ISOException.throwIt( ISO7816.SW_WRONG_PIN+ pin.getTriesRemaining()); } }
  • 42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1342 The Security  What if the user forgets the password or loses the card? – A backup can be produced, encrypted with a key  How to protect the backup? – With a secret key, if this is for private use  Then, don’t forget/lose the key – With a public key, if this is in a commercial offer  Decryption requires fee payment, and offline authentication method  Smart cards don’t solve all the problems … Tricky stuff
  • 43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1343 The Security  Remember why you are using a smart card – Because is it tamper-resistant – So, what happens when the card is under attack?  Under attack, some countermeasures are activated – At the hardware level – At the system software level – At the application software level Protecting against attacks
  • 44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1344 The Security  A typical attack consists in leaking information from the card – Many different ways of doing it, many countermeasures too – Typical application-level countermeasure:  Assume that the other countermeasures have failed  Encrypt your data to make it unexploitable  Another attack consists in provoking faults in the execution – Shorting the silicon, exploiting physics – In software, redundancy is the only direct countermeasure What attacks? What countermeasures?
  • 45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1345  Java is practical here – Encapsulation works – Encryption is local to class  Java Card crypto is simple – Inspired from JCE – Implementation protects keys Encrypting objects Protecting Against Observation Attacks byte getUserName(byte[] buf, short ofs) { unCipher.init(unKey,Cipher.MODE_DECRYPT); unCipher.doFinal(userName, (short)0, userName.length, buf, ofs); return getUserNameLength(); } byte getPassword(byte[] buf, short ofs) { password.getKey(buf,ofs); return getPasswordLength(); }
  • 46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1346  Java is practical here – Encapsulation works – Encryption is local to class  Java Card crypto is simple – Inspired from JCE – Implementation protects keys Encrypting objects Protecting Against Observation Attacks byte getUserName(byte[] buf, short ofs) { unCipher.init(unKey,Cipher.MODE_DECRYPT); unCipher.doFinal(userName, (short)0, userName.length, buf, ofs); return getUserNameLength(); } byte getPassword(byte[] buf, short ofs) { password.getKey(buf,ofs); return getPasswordLength(); }
  • 47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1347  Java is practical here – Encapsulation works – Encryption is local to class  Java Card crypto is simple – Inspired from JCE – Implementation protects keys Encrypting objects Protecting Against Observation Attacks byte getUserName(byte[] buf, short ofs) { unCipher.init(unKey,Cipher.MODE_DECRYPT); unCipher.doFinal(userName, (short)0, userName.length, buf, ofs); return getUserNameLength(); } byte getPassword(byte[] buf, short ofs) { password.getKey(buf,ofs); return getPasswordLength(); }
  • 48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1348  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1349  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1350  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1351  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 52. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1352  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 53. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1353  Java is not really practical here – Encapsulation doesn’t work – Checks are everywhere – Code is very hard to read  Requires some specific skills – Not that hard to acquire Adding redundancy Protecting Against Fault Attacks boolean verify( byte[] buf, short ofs, byte len) { byte tl = triesLeft; if (tl != (short)(~triesLeftBak)) takeCountermeasure(); if (tl<=0) return false; JCSystem.beginTransaction(); triesLeft = --tl; triesLeftBak++; JCSystem.commitTransaction(); if (triesLeft != (short)(~triesLeftBak)) takeCountermeasure();
  • 54. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1354 Java Card is Simple  Using Java Card is rather simple – Allows you to program card applications – Provides access to required functions such as PIN and cryptography  Your applications are not simple – They are part of a larger, more complex system – If they need to be on a card, it is most likely for security reasons – Security engineering will consume most of your time Security is complex
  • 55. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1355 Some References  The reference from Oracle – www.oracle.com/technetwork/java/javame/javacard/  A tutorial with the rest of today’s example – javacard.vetilles.com/tutorial/  GlobalPlatform’s Web site – www.globalplatform.org Getting started
  • 56. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1356 Graphic Section Divider
  • 57. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1357