Smart Cards and Crypto Devices: Smart Cards? Well, A Certain Animal Cunning Perhaps
Smart Cards and Crypto Devices: Smart Cards? Well, A Certain Animal Cunning Perhaps
Smart Cards
Invented in the early 1970s
Technology became viable in the early 1980s
Other uses
Student ID/library cards
Patient data
Micropayments (bus fares, photocopying, snack food)
Memory Cards
Cost: $5
Microprocessor Cards
16-bi
t
=28-bit register pairs
Di
gi
t
a
ls
i
gna
t
ur
e
=s
i
mpl
ec
he
c
ks
umorMAC
Ce
r
t
i
f
i
c
a
t
e
=da
t
a+
d
i
gi
t
a
ls
i
gna
t
ur
e
File Structures
File Types
Transparent
Binary blob
Linear fixed
n fixed-length records
Linear variable
n records of fixed (but different) lengths
Cyclic
Linear fixed, oldest record gets overwritten
Execute
Special case of transparent file
File Attributes
EEPROM has special requirements (slow write, limited
number of write cycles) that are supported by card
attributes
WORM, only written once
Multiple write, uses redundant cells to recover when some cells
die
Error detection/correction capabilities for high-value data
Error recovery, ensures atomic file writes
Power can be removed at any point
Requires complex buffering and state handling
Card Commands
Typical commands are
CREATE/SELECT/DELETE FILE
READ/WRITE/UPDATE BINARY
Write can only change bits from 1 to 0 because of
EEPROM technology limits
Update is a genuine write
ERASE BINARY
READ/WRITE/UPDATE RECORD
APPEND RECORD
INCREASE/DECREASE
Changes cyclic file position
Authentication
Simple challenge/response authentication protocol
INTERNAL AUTHENTICATE
Authenticate card to terminal
EXTERNAL AUTHENTICATE
Authenticate terminal to card
Application-specific instructions
RUN GSM ALGORITHM
prEN 1546 commands INITIALISE IEP, CREDIT IEP, DEBIT
IEP, CONVERT IEP CURRENCY, and UPDATE IEP
PARAMETER
St
a
nda
r
di
s
e
dAPI
swe
r
equi
t
es
l
owt
oa
p
pe
a
r
PKCS #11, general API for any crypto device
PC/SC, Windows HAL for smart cards
JavaCard, Java-like language for restricted environments
PKCS #11
Object-oriented interface to any type of crypto token
Smart card
Crypto hardware accelerator
Fortezza card
USB-based token
Handheld PC (e.g. PalmPilot)
Software implementation
Private Key
RSA Private Key
DSA Private Key
DH Private Key
Secret Key
DES Key
3DES Key
RC2/RC4/RC5 Key
Certificate
X.509 Certificate
Data
(persistent object)
(needs login to use)
(
c
a
n
tbea
l
t
e
r
e
d)
(object ID for humans)
Key attributes
CKA_KEY_TYPE = CKK_RSA
CKA_ID = 2A170D462582F309
CKA_LOCAL = TRUE
(
a
t
t
r
i
b
ut
e
sc
a
n
tber
e
ve
a
l
e
do
u
t
s
i
det
h
et
o
ke
n
)
(
c
a
n
tbee
x
po
r
t
e
df
r
o
mt
het
o
ke
n)
(can be used to decrypt data)
(can be used to sign data)
(can be used to unwrap encryption keys)
PC/SC
Interoperability Specification for I
CC
sand Personal
Computer Systems
Mi
c
r
os
of
t
sa
t
t
e
mptt
oki
l
lPKCS#11(
c
.
f
.PCTv
s
.SSL)
Goes a long way towards solving the Smart Card Problem
PC/SC (ctd)
PC/SC spec (ctd)
ICC service provider (ICCSP)
Maintains context of a card session
Crypto service provider (CSP)
Optional manager for crypto functionality
Separated out for export control purposes
smus
c
l
ec
oul
df
i
na
l
l
yge
tt
hec
a
r
dve
ndor
st
o
play ball
PC/SC (ctd)
JavaCard
Standard smart card with an interpreter for a Java-like
language in ROM
Card runs Java with most features (multiple data types,
memory management, most class libraries, and all security (via
the bytecode verifier)) stripped out
Can run up to 200 times slower than card native code
Language is pseudo-Java, not real Java
No security, a simple out-of-bounds memory access can
destroy the code
Pr
ovi
d
e
st
h
ea
bi
l
i
t
yt
ome
nt
i
onb
ot
h
J
a
v
a
a
nd
s
ma
r
t
c
a
r
ds
i
nt
h
es
a
mes
a
l
e
sl
i
t
e
r
a
t
ur
e
JavaCard (ctd)
Card contains multiple applets
External client sends select command to card
Card selects applet and invokes its select method
Further commands sent by the client are forwarded to the
a
ppl
e
t
sprocess method
Applet is shut down via deselect method when a new select
command is received
OCF
Open Card Framework, object-oriented framework for
smart card developers
Class contains a
blueprint for an
object
Object is an
instance of a class
OCF (ctd)
class SmartCard
CardID
Information identifying the card
CardServiceFactory
CardService: PurseCardService
CardService: FileSystemCardService
CardService:
CardServiceRegistry
Looks up requested CardService in CardServiceFactory
Instantiates a new CardService object for the caller
CardServiceScheduler
Communicates with the card terminal
Coordinates access to card services
OCF (ctd)
class CardFile
Attributes
TRANSPARENT,LI
NEARFI
XED,
CardFilePath, CardFileInputStream, CardFileOutputStream
class Terminal
Slot
Information on reader slot + optional display, keyboard
CardTerminalFactory
CardTerminal
CardTerminalRegistry
As CardServiceRegistry
Abstraction
Level
Any
High
PC/SC
Any
Windows Low
OCF
Java
JVM
Low
sWi
nd
ows
(limited availability under Linux)
OCF: By Java programmers for Java programmers
Multiapplication Cards
Sma
r
tc
a
r
dsa
r
e
n
tt
a
ki
n
gof
f
Multiapplication smart cards may help
The
r
ea
r
enoa
ppl
i
c
a
t
i
onsf
ort
he
mnow,buti
fyougowi
t
ha
multiapplication card you can charge others to put their apps in
yourc
a
r
d
Dallas iButton
Avoids most smart card problems by changing the
packaging
Device is contained in 165mm microcan
Stainless steel case is much stronger than a smart card
Case contains a built-in battery and clock
I
/
Odoe
s
n
tt
i
eupas
e
r
i
a
lpor
t
$10 iButton interface is cheaper than $50 card reader
iButton Security
iButton package allows for much better security measures
than smart cards
Various triggers erase memory if tampering is detected
iButton Programming
The device recognises two roles
Crypto officer initialises the device
Create transaction group(s)
Set up information (keys, monetary value, etc)
Set initial user PIN
Lock transaction group(s)
User utilises it after initialisation by the crypto officer
Signing process
User hashes data with MD5, SHA-1, RIPEMD-1
60,
iButton hashes the user-supplied hash with the device serial
number, transaction counter, and timestamp
iButton signs the hash using its private key
User retrieves the serial number, transaction counter,
timestamp, and signature from the iButton
l
lb
ekewler if we Java-ise it
Rip out all the security features, lobotomise the security model
Turn it into a Javacard in a can
Short-term effect
Pos
i
t
i
vepubl
i
c
i
t
ybe
c
a
us
ei
tc
ont
a
i
n
st
hewor
d
J
a
va
Long-term effect
Look,aJ
a
vap
r
oc
e
s
s
ori
nac
a
n
Ye
s
,butwha
t
si
tgoodf
or
?
No,youdon
tunde
r
s
t
a
nd.I
t
saJ
a
vapr
oc
e
s
s
or
!I
nac
a
n!
Contactless Cards
Several levels of contactless cards
Contact, ISO 7816
Close-coupled, 0-2mm, ISO 10536
Abandoned in favour of proximity cards
Proximity, 0-10cm, ISO 14443
Typical use: MIFARE, transport applications
Vicinity, ~1m, ISO 15693
Typical use: RFID
Vicinity Cards
Extend proximity card ideas
PCD VCD (Vicinity card device)
PICC VICC (Vicinity integrated circuit card)
Protocol attacks
Card security protocols are often simple and not terribly secure
set ctr = 8
loop: read PIN digit
cmp stored PIN digit
jne error
loop ctr
Physical Attacks
Erase onboard EPROM with UV spot beam
Remove chip from encapsulation with nitric acid
Use microprobing to access internal circuit sections
Use an electron-beam tester to read signals from the
operational circuit
Possible attacks
Cycle the RNG until the EEPROM locks up
Drop the operating voltage to upset analog-circuit RNGs
French government attack: Force manufacturers to disable key
generation
This was probably a blessing in disguise, since externally
generated keys may be much safer to use
Timing/Power Analysis
Crypto operations in cards
Take variable amounts of time depending on key and data bits
Use variable amounts of power depending on key and data bits
Transistors are voltage-controlled switches that consume
power and produce electromagnetic radiation
Power analysis can provide a picture of DES or RSA
en/decrypt operations
Recovers 512-bit RSA key at ~3 bits/min on a PPro 200