31
1 EMV

Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

Embed Size (px)

Citation preview

Page 1: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

1

EMV

Page 2: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

2

EMV

• EMV = Europay-Mastercard-Visa • standard for replacing mag-stripe with chip • interesting standard, as it is all public

– www.emvco.com– 100s of pages

• originally for contact smartcard, but now also for RFIDs

Page 3: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

3

EMV 2004 spec

• Book 1: ICC to Terminal Interface Requirements• Book 2: Security and Key Management• Book 3: Application Specification• Book 4: Cardholder, Attendant and Acquirer Interface Specifications

Page 4: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

4

EMV roll-out

• first version of standard 1996• UK rollout Oct 2003-Feb 2006 (Chip and PIN)

– www.chipandpin.co.uk• continental Europe still migrating for credit cards

– eg see www.vanstripnaarchip.nl– but many national payment schemes use smartcards

• USA sticking to magstripe– and skipping contact cards to move to RFID

Page 5: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

5

Why smartcards?

• preventing skimming/cloning

• also: shift in liability to customer– PIN replacing signatures for non-repudiation

• process of checking and contesting very different– some public debate on this

• eg see http://www.chipandspin.co.uk/spin.pdf

• and to non-complying merchants – eg since jan 2005, UK merchant that cannot conform to

EMV is liable

Page 6: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

6

Does it work?

UK card fraud in millions of £ [Source: apacs.org.uk]

32313730211517141713card ID theft

438439504420425412317188135122Total

15407345372718151213mail intercept

6889115112108114102806666lost/stolen

10097130110149160107502720counterfeit

2131831511221109673291410card not present

2006200520042003200220012000199919981997

Page 7: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

7

EMV security techniques

• card authentication to terminal– Static Data Authentication (SDA)– Dynamic Data Authentication (DDA)

• transaction confidentiality & integrity– encryption and MAC

• PIN encryption at point of entry (optional)

Page 8: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

8

EMV security techniques

• Algorithms used: – 3 DES, RSA, SHA-1– possible new algorithm in future, eg ECDSA

• RSA digital signature and public key certificates• card unique 3-DES key, derived from Master

Derivation Keys (MKDs)• unique session keys for encryption & MAC

Page 9: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

9

EMV Public Key Certificate

Public Key Certificate

EMV formatting

CertificateCore

General information about the user and the application

Public Key Remainder

Public KeyUser’s public key

Signature by a Trusted Third Party

Hash Result

Hash of data

Page 10: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

10

Static Data Authentication (SDA)

• Static authentication data on card is signed with issuer's private key– Static authentication data includes

• Primary Account Number (PAN)• Expiry date

Page 11: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

11

SDA

Page 12: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

12

IC Terminal

IC Card

Card provides to terminal:

Signature OK

Terminal:

• Uses PKCA to retrieve the Issuer’s PKISS which is certified by the CA

• Uses PKISS to verify the digital signature of the card data

• Card data with Issuer’s digital signature

Card static

data

• PKISS certified by Certification Authority (CA)

CERTIFIED

SDA - Authorisation Phase

Page 13: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

13

Weakness of SDA

• does not prevent replay attacks:– skimming still an option!

• UK banks issue SDA cards, which has caused criticisms– still, cloning SDA cards will be harder than magstripe

cards, esp. one that looks convincing

• DDA repairs this by having a terminal-generated nonce

Page 14: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

14

DDA

Page 15: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

15

DDA - Authorisation Phase

IC Terminal

IC Card

Card provides to terminal:

Signature OK

• Uses PKCA to retrieve the Issuer’s PKISS which is certified by the CA

• Uses PKIC to verify the digital signature on the card and terminal data

• PKISS certified by Certification Authority (CA)

CERTIFIED

• PKIC certified by Issuer

CERTIFIED

• Uses PKISS to retrieve the ICC PKIC which is certified by the Issuer

• Digital signature on the UN and the ICC Dynamic Data generated using SKIC

Terminal:

Terminal provides to card:

• Unpredictable Number (UN)

INTERNAL AUTHENTICATE

Page 16: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

16

Dynamic Data Authentication (DDA)

• terminal-generated nonce prevents replays• downside: more expensive card required

Page 17: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

17

PIN encryption

• encryption of PIN code in tamper-evident secure keypad

• card issuers don't want to trust the entire ATM, but only the Hardware Security Module (HSM) and this secure keypad

• PIN encrypted with – card's public key PKIC

– or card's PIN encipherment public key PKPE

Page 18: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

18

Offline PIN Processing

Validate PKIC or PKPE

GET CHALLENGE

Unpredictable Number (UN)

PKIC or PKPE and UN

PIN Pad generates random padding

Create data block to include PIN, UN and random padding and encrypt with PKIC or PKPE

Cardholder enters PIN

Encrypted PIN Data

VERIFY (includes Encrypted PIN

Data)

Decrypt Encrypted PIN Data, using SKIC or SKPE and validate UN and

PIN

IC Terminal

Secure PIN Pad

IC Card

Page 19: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

19

Transaction Security

• card's master key derived from issuer master key– by encrypting PAN and PAN sequence number– different issuers master keys for confidentiality

(encryption) and message/transaction integrity (MACs), resulting in corresponding card's master keys

• session key derived from card's master key – by encrypting card's ATC (Application Transaction

Counter) and terminal-supplied nonce (UN = Unpredictable Number)

Page 20: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

20

ICC Master Key Derivation

Issuer Master Key

PAN + PAN Sequence Number

3-DES Encrypt(Encrypt/Decrypt/Encrypt)

ICC Master Key (left half)

Inverted PAN + PAN Sequence

Number

3-DES Encrypt(Encrypt/Decrypt/Encrypt)

ICC Master Key (right half)

Issuer Master Key

Page 21: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

21

Session Key Derivation

ATC F0 00UN

3-DES Encrypt(Encrypt/Decrypt/Encrypt)

SKAC(left half)

IC Master Key

ATC 0F 00UN

3-DES Encrypt(Encrypt/Decrypt/Encrypt)

SKAC(right half)

IC Master Key

Page 22: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

22

Secure Messaging

• Secure messaging is used between the Issuer’s host system and the smart card, – eg to update card parameters, application unblock, or

change/unblock PIN

• Secure messaging provides data integrity and origin authentication (with MAC) and confidentiality (encryption).– Encryption uses 3-DES Cipher Block Chaining (CBC).– MAC as on next slide

Page 23: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

23

Message Authentication Code (MAC)

• MAC calculated with a 3-DES session key (derived from the ICC Master Key).

• Algorithm defined in ANSI X9.19 and ISO 9797-1

• SK(L) = Session Key (left half)• SK(R) = Session Key (right half)

Block 1

Encrypt

Block 2

Encrypt

Block 3

AC

Encrypt

⊕ ⊕

Decrypt

Encrypt

SK(L) SK(L) SK(L)

SK(L)

SK(R)

Page 24: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

24

Cardholder Verification Methods (CVM)

• range of cardholder verification methods– depending on card and the application

• terminal and smartcard negotiate CVM– given their lists of allowed/supported method (in order of

preference) with conditions• potential for trouble: forcing terminal/card to fall

back to old CVM– problems with this reportedly fixed

Page 25: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

25

CVM codes

Page 26: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

26

CVM condition codes

Page 27: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

27

Hardware Security Modules

• Bank's bank-end has to store issuer's master keys – eg in ATM

• Hardware Security Modules (HSMs)– store these keys – and perform required operations on them

• keys shouldn't leave HSM unencrypted– HSM are tamper-resistant/evident devices

• the complicated APIs of HSM may allow attacks– combination of API calls may produce spoofed encrypted

message or a reveal key

Page 28: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

28

IBM 4758

Page 29: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

29

Example HSM API weakness

• HSM allows external storage of key K in encrypted form{K}KM where KM is master key that never leaves HSM

• Secure_Messaging_for_Keys operation added in CCA (Common Cryptographic Architecture) to support EMV – input: {K1}KM, {K2}KM, template, offset

– output: {template with K1 inserted at offset}K2

• attack:– take template = m ++ '00000000' , offset = |m|– now output is {m ++ K1}K2 = {m}K2 ++ ...– we have an encryption oracle for K2– we can now spoof messages to the EMV smartcard..

Page 30: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

30

Example HSM API weakness (cont)

• we can go to recover K1 • calculate {0000 0000 0000 00yy}K2for 00≤yy≤FF• call Secure_Messaging_for_Keys with template = '0000 0000 0000 0000' , offset = 7

• match result with one of the {0000 0000 0000 00yy}K2 revealing the first byte of K1

• repeat procedure to calculate other bytes

[A Note on EMV Secure Messaging in the IBM 4758 CCA, B. Adida et al., 2005]

Page 31: Opportunities and challenges for formal specification of ...read.pudn.com/downloads157/doc/project/700953/EMV.pdf · • EMV = Europay-Mastercard-Visa ... • Book 1: ICC to Terminal

31

EMV next steps?

• hand-held reader to cut card-not-present fraud– cf. online banking in the Netherlands– weakest link then: browser security

• integration in mobile phone– which has keyboard & display!