+ All Categories
Home > Documents > Opportunities and challenges for formal specification of ... · –de-activating applications ......

Opportunities and challenges for formal specification of ... · –de-activating applications ......

Date post: 29-Apr-2018
Category:
Upload: duongkien
View: 216 times
Download: 3 times
Share this document with a friend
35
1 Smartcards ISO 7816 & smartcard operating systems Erik Poll Digital Security Radboud University Nijmegen
Transcript
Page 1: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

1

Smartcards

ISO 7816 &

smartcard operating systems

Erik Poll

Digital Security

Radboud University Nijmegen

Page 2: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Standard for contact smartcards ISO7816

• 7816-1 Physical characteristics

• 7816-2 Dimension & size of contacts

• 7816-3 Electronic signals and transmission protocols

– defines voltage & current requirements

• 7816-4 Inter-industry commands

– standard set of commands

• 7816-5 Numbering system for application identifiers (AIDs)

• 7816-6 …

• 7816-...

• 7816-...

• 7816-15

2

Page 3: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Contact cards (ISO 7816-2)

• Vcc originally 5 V, now also 3V or 1.8V

• Vpp, higher voltage for writing to EEPROM, no longer used as

it introduces security weakness

• Clock originally 3.57 MHz or 4.92MHz

• I/O speeds in order of > 100 Kbit/s

• C4 & C8 can be used for USB2.0 up to 12 Mbit/s

• C6 can be used for Single Wire Protocol (SWP)

to connect SIM card to the phone’s NFC antenna

3

1. Vcc

2. Clock

3. Reset

5. Ground

6. Vpp

7. I/O

4 & 8 RFU (Reserved for Future Use)

Page 4: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Smart card terminals

Master-Slave communication:

terminal (aka CAD, card acceptance device) is master

smartcard is slave

Hence: terminal takes the initiative,

smartcard cannot initiate actions

For SIM cards a polling mechanism is used to overcome this

limitation: the handset will regularly poll the SIM card to ask if it

wants to do something

4

Page 5: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

The Terminal Problem!

No I/O between user and card

– no display

– no keyboard

Why is this a problem?

Some experimental cards with displays, keyboards, or fingerprint

readers.

5

Page 6: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Trusted I/O to the card holder

I/O via such devices is always trusted

but not necesarilly trustworthy

Page 7: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Card Activation (ISO 7816-3)

1. terminal activates card

– earth; voltage; clock; reset

2. card responds with ATR (Answer To Reset)

– max 33 bytes, usually a lot less (for speed)

– must be sent between 400 & 40,000 clock cycles

– obligatory info about the protocol used

– T=0 byte-oriented

– T=1 block-oriented

– supported baud rate for I/O

– usually some manufacturer info

– id of OS and version no. of ROM mask

– obligatory last byte XOR checksum

7

Page 8: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

APDU communication (ISO 7816-4)

All subsequent communication via APDUs

Application Protocol Data Units

which are just sequences of bytes in particular format

1. Terminal sends command APDU

2. Card replies with response APDU

etc, etc ....

8

Page 9: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Command APDU

• CLA class byte

• INS instruction byte

• P1,P2 parameters

• Lc length of data block

• Data Lc bytes of data

• Le length of expected response

9

CLA INS P1 P2 Lc ...Data .... Le

obligatory

optional

Page 10: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Response APDU

• Data : Le bytes of data (optional)

• SW1, SW2 : status word (obligatory)

10

Data ... SW1 SW2

Page 11: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

APDU coding conventions

• Conventions for CLA, INS etc. are given in ISO 7816-4

• Conventions for status word SW1 SW2

– normal processing 61xx, 9000

– warning processing 62xx, 63xx

– execution error 64xx, 65xx

– coding error 67xx, 6Fxx

11

Page 12: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Logical channels

• Modern cards provide several logical channels to talk

to multiple applications on the card concurrently

– eg mobile phone talking to contact list and other

applets on SIM card

12

Page 13: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Future

ISO7816 protocol stems from 1880s and it shows!

Slow speed & small size of APDUs can be a bottleneck

• Faster communication speeds wanted?

– eg. USB 2.0

• More modern protocols wanted?

– eg http(s) support on experimental JavaCard 3.0x

Connected edition

13

Page 14: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

14

Smartcard software

and Operating Systems

Page 15: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Smartcard operating systems

• Similar evolution as for normal OSs, but faster

– additional factor: storing code in ROM vs EEPROM

• Still very primitive compared to normal OSs such as

Windows or Linux/UNIX

– no multi-programming, hardly any I/O, ...

– but multi-threading in newest JavaCard 3.0...

15

Page 16: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Smartcard OS

Tasks:

• life-cycle management

– of card + individual applications (called applets)

• instruction processing

• memory management

• I/O

• hardware error handling

– incl. support for atomic EEPROM updates, needed

because the possibility of power failure by card tear

16

Page 17: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Typical application life cycle

• installation of application (aka applet)

– uploading & installing code

• personalisation

– uploading application data

– afterwards, application starts in normal active life

• end-of-life

– disabling all functionality

– possibly leaving logging functionality enabled

– upon external command or because the card notices

something fishy going on

17

Page 18: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Smartcard life cycle (ISO 10202-1 - cancelled)

Production of chip & card

– testing & removing test functionality

Card preparation

– completing OS

Application preparation incl. Personalisation

– initialising applications

– personalisation aka individualisation

• both electrically & optically

Card utilisation

– (de)activation of applications

End of card utilisation

– de-activating applications

– de-activating card

18

Page 19: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Smartcard OS evolution

1. no OS: one application, burnt into ROM

2. standard libraries in ROM, applications in EEPROM

3. proprietary operating systems

– programs written in machine code or C

– providing standardised file system (IS07816-4) with

access control

4. modern multi-application smartcards

– MULTOS

– JavaCard

5. next generation, experimental `concept' card

– JavaCard 3.n Connected Edition

19

Page 20: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

OS "completion"

1. Initially, card contains ROM mask

2. Simple loader in ROM executed to load EEPROM

3. Checksum computed

4. Switch to mode where code in ROM and EEPROM can be

executed

20

Page 21: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Modern multi-application cards

– Multi-application: more than one program (applet) on a

card

– Post-issuance download: applet can be installed or

removed on issued cards in the field

– Programs written in a standard high(er) level language,

not a proprietary instruction set specific to chip vendor

Examples

– MULTOS

• first of these "modern" smartcard OSs

– JavaCard

• popular as GSM sims, used in Dutch passport & ID cards

– Windows for Smartcards †

• since abandoned

21

Page 22: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Modern multi-application cards

Pros

• vendor-independence

• old cards have proprietary OSs and instruction sets

• fast development & quick time-to-market

• esp. important in telecom market

Cons

• overhead – more memory & CPU power needed

• more expensive card needed

• complexity

• which brings security concerns

Open question: do security advantages of a higher level platform, with built-in standard security mechanisms, outweigh the additional security risks this complexity brings?

Financial sector much more conservative than telecom sector in

adopting modern platforms.

22

Page 23: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Multi-application cards

• Multi-application vision: everyone carrying one card, with

all their smartcard applications

• This is not going to happen. Problems include:

– trust

bank won't allow untrusted applet code on their cards, despite

security guarantees of VM / OS

– marketing

who gets to put their logo on the plastic

• Still, multi-application is useful for development & card

management

– eg adding services to GSM SIM, adding contactless or

internet banking applets to bank card, ...

23

Page 24: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

MULTOS

• Card provides a Virtual Machine interpreting MEL

(MULTOS Executable Language)

• Originally developed for electronic purse system

Mondex

– by BT, Westminster & Midland banks in the UK

• Designed for ITSEC EC6-high evaluation

24

Page 25: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

JavaCard 3.0 Connected Edition

The next-generation smart card OS

• multi-threading

security worries!

• communication with https://

The smartcard is a web-server!

But who will use it??

• intended market: telco

• not all card manufacturers produce JC 3.0 Connected,

or have any intention to

25

Page 26: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Standard ISO7816

functionality & commands

Page 27: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

IS0 7816-4 file system

• MF (Master File) – ie. root directory

• DF (Directory Files)

• EF (Elementary Files) - external or internal

• internal = for use of OS only

• external = for use of applications

– file formats:

• binary

• lineair fixed sized records

• lineair variable sized records

• cyclic fixed sized records (why?...)

– useful for logging

– useful to wear out EEPROM evenly

27

Page 28: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

File attributes

Also includes more baroque things such as

• WORM (Write Once, Read Many time)

– realised in hardware or software

• EDC (Error Detection Code)

• atomic write access

• multiple storage attribute

– for frequently used files, to prolong lifetime of file given

limited EEPROM life

• data transfer selection attribute

– on dual-contact cards, to make file accessible only via

contact or contactless interface

You won’t see these features in your project. The JavaCard VM and OS hides all this.

28

Page 29: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

ISO 7816 commands

• ISO 7816 defines a set of standard commands for

– file system access and management

– PIN codes

– authentication by challenge-response

– crypto

• Knowing the standard commands is useful for reverse-

engineering existing applications

• Related standards, that build on top of this

– EMV for banking cards

– GSM 11.11 and its superset EN 726-3 for SIMS

– United Nations ICAO specs for e-passport

29

Page 30: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

File access commands (ISO 7816)

Standard commands for

• reading & writing

– eg READ BINARY, READ RECORD, ...

– increase & decrease by n

• for cyclic files

• append

• delete

• lock & rehabilitate

• identification / authentication

30

Page 31: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Identification command (ISO 7816)

• VERIFY command

– for PIN code verification

• CHV = Card Holder Verification = PIN

– also used for verification of biometric aspects

ISO 7816-4 defines that the Instruction (INS) byte for

VERIFY is 20, and class (CLA) byte is 00

31

Page 32: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Example Authentication Protocols

• ISO7816 proposes some standard instructions for

authentication using challenge-response

• authentication of card

– INTERNAL AUTHENTICATE

• arguments: random, algorithm , key no

• card returns: enc(key,random)

• authentication of terminal

– GET CHALLENGE

• card returns random number

– EXTERNAL AUTHENTICATE

• arguments: enc(key, random), algorithm, key no

32

Page 33: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Example Authentication Protocols

• mutual authentication

– GET CHIP NUMBER

• card returns chip number

– GET CHALLENGE

• card returns smart card random s_rnd

– MUTUAL AUTHENTICATE

• arguments: enc(key, terminal random, s_rnd, chip

number), algorithm, key no

• card returns: enc(key, terminal random, s_rnd)

33

Page 34: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Example key distributions

• asymmetric crypto, ie. public & private keys

– pro? cons?

• symmetric cryto

– pro? cons?

34

Page 35: Opportunities and challenges for formal specification of ... · –de-activating applications ... –marketing who gets to put ... • not all card manufacturers produce JC 3.0 Connected,

Key Diversification

• Standard technique to reduce hassle of key

manangement with many symmetric keys

• Terminals or central back-end has a master key M

• Card with unique card number x have an individual

diversified key derived from the master key M and x

– eg. Mx = AESM(x)

35


Recommended