100
MULTI-APPLICATION PAYMENT CHIP OPERATING SYSTEM (MPCOS) By Ata Ebrahimi, 2010

Gemalto MPCOS Version 0.1

Embed Size (px)

DESCRIPTION

MPCOS is a famous Java card applet which developed by Gemalto company to provide a variety of administrative and payment commands; it is also compatible with EMV. In this presentation I've tried to explain all file and data structure details.

Citation preview

Page 1: Gemalto MPCOS Version 0.1

MULTI-APPLICATION PAYMENT CHIP

OPERATING SYSTEM (MPCOS) By Ata Ebrahimi, 2010

Page 2: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 3: Gemalto MPCOS Version 0.1

ABSTRACT

Understanding How the MPCOS Applets works

Developing Terminal Applications for MPCOS cards

Page 4: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 5: Gemalto MPCOS Version 0.1

FEATURES

Multi-Purpose and Payment Applications

JAVA Open Platform Card

Page 6: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 7: Gemalto MPCOS Version 0.1

FILE AND DATA STRUCTURE

Global Level

Local Level

Page 8: Gemalto MPCOS Version 0.1

GLOBAL LEVEL

Master Files (MF)

Elementary Files (EFs)

Page 9: Gemalto MPCOS Version 0.1

LOCAL LEVEL

Dedicated Files (DFs)

Elementary Files (EFs)

Page 10: Gemalto MPCOS Version 0.1

HIERARCHY OF MPCOS FILES

Page 11: Gemalto MPCOS Version 0.1

MASTER FILE

Root of the MPCOS File Structure = Root Directory in MS DOS

Only One Per Card

Storing Up to 63 Dedicated Files and Elementary Files

Unique Identifier = 3F00 h

Page 12: Gemalto MPCOS Version 0.1

DEDICATED FILES

Directory in MS DOS

Storing Up to 63 Elementary Files

Nested DFs Are Not Supported

13-byte File Descriptor and A File Body

File Descriptor = Information Needed by MPCOS to Manage the File

File Body = DF’s Name

Page 13: Gemalto MPCOS Version 0.1

STRUCTURE OF DEDICATED FILE DESCRIPTOR

Page 14: Gemalto MPCOS Version 0.1

IDENTIFIER (FID)

Length = 2 Bytes

Allocated When the File Is Created

Short File Identifier (SFI) = 5 Least Significant Bits of FID

Designating a File From Within a File Operation Command

Page 15: Gemalto MPCOS Version 0.1

FILE DESCRIPTOR BYTE (FDB)

Length = 1 Byte

38 h

Page 16: Gemalto MPCOS Version 0.1

FILE OPTION BYTE (OPT)

Length = 1 Byte

Bit Value Option

1 Reserved for Future (RFU)

2 1 Cancel Debit Command Disabled

0 Cancel Debit Command Enabled

3 1 Current Balance Can Be Used To Compute Sign Certificates

0 Current Balance Can Never Be Used To Compute Sign Certificates

4-7 Reserved for Future (RFU)

8 1 Select Purse & Key and Select File Key Commands Require External Authentication

0 Select Purse & Key and Select File Key commands Do Not Need An External Authentication

Page 17: Gemalto MPCOS Version 0.1

BODY SIZE

Length = 2 Bytes

Specifies the Size of the File Body

Usually Contains the DF Name, Up to 16 Bytes

Page 18: Gemalto MPCOS Version 0.1

ACCESS CONDITION GROUP 1, 2

Length = 2 Bytes

Define the Access Conditions Assigned to the DF

Page 19: Gemalto MPCOS Version 0.1

CHECKSUM

Length = 1 Byte

Computed by the OS When the File Is Created

To Control the Integrity of the Descriptor In Case of Memory Failure

Page 20: Gemalto MPCOS Version 0.1

FILE BODY

Stores An Optional Name in DFs

Name Length = Up to 16 Bytes

Can Be Used By Select File Command to Select a DF

DF Do Not Have A Structure

Page 21: Gemalto MPCOS Version 0.1

SELECTION BY PARTIAL NAME

MPCOS Allows DF To Be Selected By Partial Name

Example_EP = Example

The DF That Was Created First Will Be Selected

Page 22: Gemalto MPCOS Version 0.1

ELEMENTARY FILE

Main Component of the MPCOS File Structure

Contain System and Application Data

13-byte File Descriptor and A File Body

File Descriptor = Information Needed by MPCOS to Manage the File

File Body = Data

Page 23: Gemalto MPCOS Version 0.1

STRUCTURE OF ELEMENTARY FILE DESCRIPTOR

Page 24: Gemalto MPCOS Version 0.1

IDENTIFIER (FID)

Length = 2 Bytes

Allocated When the File Is Created

Short File Identifier (SFI) = 5 Least Significant Bits of FID

Designating a File From Within a File Operation Command

Page 25: Gemalto MPCOS Version 0.1

FILE DESCRIPTOR BYTE (FDB)

Length = 1 Byte

Information About The EF Type and Structure

Page 26: Gemalto MPCOS Version 0.1

FILE DESCRIPTOR BYTE (FDB)

Page 27: Gemalto MPCOS Version 0.1

FILE DESCRIPTOR BYTE (FDB)

When Creating An EF, The OS Does Not Check The Contents Of The FDB, So More Than One of Each Type of File Can Be Created

If More Than One of Unique EFs Like Secret Code and IADF IS Created, Only The First One Is Recognized

Page 28: Gemalto MPCOS Version 0.1

RECLGT

Length = 1 Byte

Contains The Record Length For Linear Fixed and Cyclic Files With A Fixed Record Length

No Value For Other File Types

Page 29: Gemalto MPCOS Version 0.1

BODY SIZE

Length = 2 Bytes

Specifies the Size of the File Body

EF File Body Contains The Data

Page 30: Gemalto MPCOS Version 0.1

ACCESS CONDITION GROUP 1, 2, 3

Length = 2 Bytes

Define the Access Conditions Assigned to the EF

Page 31: Gemalto MPCOS Version 0.1

CHECKSUM

Length = 1 Byte

Computed by the OS When the File Is Created

To Control the Integrity of the Descriptor In Case of Memory Failure

Page 32: Gemalto MPCOS Version 0.1

FILE BODY

Stores Data

Six Types Of EFs

Page 33: Gemalto MPCOS Version 0.1

TYPE OF EFS

Purse Files

Enhanced Purse Files

Key Files

Transaction Manager Files

Secret Code Files

Internal Application Data Files (IADF)

Page 34: Gemalto MPCOS Version 0.1

PURSE FILES

FDB: 0001 1001 b or 19 h

Contain One Purse Only

Each DF Can Hold Up To 32 Purse Files

Must Be Among The First 32 Files Created In A Dedicated File

Page 35: Gemalto MPCOS Version 0.1

PURSE STRUCTURE

Page 36: Gemalto MPCOS Version 0.1

MAXIMUM BALANCE

Length = 3 Bytes

Maximum Balance That The Purse Can Hold

Page 37: Gemalto MPCOS Version 0.1

CREDIT KEY FILE

Length = 5 Bytes

Specifies The Short File Identifier Of The File Holding The Purse Credit Key

Page 38: Gemalto MPCOS Version 0.1

MAXIMUM FREE DEBIT

Length = 3 Bytes

The Maximum Value That Can Be Debited From The Purse When The Debit Access Condition Has Not Been Fulfilled

If This Value Is Set To 0 h, The Debit Access Condition Must Be Fulfilled For All Debits

Page 39: Gemalto MPCOS Version 0.1

DBT

Length = 1 Nibble

Access Condition For Debit

0000 Not Protected By Secret Code

0xxx Protection By Secret Code xxx

1xxx Debiting Not Allowed

Page 40: Gemalto MPCOS Version 0.1

RDB

Length = 1 Nibble

Access Condition To Read The Purse Balance

0000 Not Protected By Secret Code

0xxx Protection By Secret Code xxx

1xxx Debiting Not Allowed

Page 41: Gemalto MPCOS Version 0.1

CURRENT BALANCE

Length = 3 Bytes

The Current Balance Value Of The Purse

Page 42: Gemalto MPCOS Version 0.1

BACKUP BALANCE

Length = 3 Bytes

The Previous Balance Value Of The Purse

Before The Last Transaction Was Carried Out

MPCOS Can Use This Value To Restore The Purse Balance After Any Incorrect Purse Updates

Page 43: Gemalto MPCOS Version 0.1

TERMINAL TRANSACTION COUNTER (TTC)

Length = 2 Bytes

Contains The TTC’s Two Most Significant Bytes While The Debit Operation Is Being Processed

Used To Identify Which Terminal Performed The Last Debit Operation

Checked By MPCOS Before Any Cancel Debit Command Operation

Page 44: Gemalto MPCOS Version 0.1

ENHANCED PURSE FILES

FDB: 0001 1001 b or 19 h

Enhanced Purses Include An Extra Word At The Offset 5 Position

Extra Word Can Be Used To Protect The Credit Operation With a Secret Code

Specify The Hierarchical Level Of The Access Conditions For The Read Balance, Debit and Credit

Page 45: Gemalto MPCOS Version 0.1

EXTRA WORLD FORMAT IN ENHANCED PURSE

The First Three Bytes Are Reserved For The Future

Page 46: Gemalto MPCOS Version 0.1

L

Length = 1 Bit

Defines The Hierarchical Level Of The EF Secret Code Files For The Read Balance, Debit and Credit Access Condition

0 Global, The Secret Codes Are Contained In The EF Secret Code Of The Master File

1 Local, The Secret Codes Are Contained In The EF Secret Code Of The Currently Selected Dedicate

File

Page 47: Gemalto MPCOS Version 0.1

CREDIT ACCESS CONDITION

0000 b No Secret Code Protection For Credit Operations

0xxx b Credit Operations Are Protected By Secret Code Number xxx

1xxx b This Purse Cannot Be Credited

Page 48: Gemalto MPCOS Version 0.1

KEY FILES

FDB: 0010 1001 b or 29 h

Consists Of 12 Bytes

Header = First Four Bytes

The Next Eight Bytes Contain Its Confidential Value

Page 49: Gemalto MPCOS Version 0.1

KEY STRUCTURE

Page 50: Gemalto MPCOS Version 0.1

SYSTEM

Length = 1 Byte

Used To Indicate The Key Type

Page 51: Gemalto MPCOS Version 0.1

KEY VERSION (KV)

Length = 1 Byte

The Key Version May Be Used To Memorize A Key Version Number After A Key Is Updated

Page 52: Gemalto MPCOS Version 0.1

CHECKSUM

Length = 1 Byte

The Checksum Is An Integrity Control Of Data

Page 53: Gemalto MPCOS Version 0.1

K8 TO K1

Length = 1 Byte

Each Secret Key = Over 8 Bytes

A Key File Contains Up to 8 Keys

Page 54: Gemalto MPCOS Version 0.1

KEY FILES

Storing The Cryptographic Keys Used In All MPCOS Cryptographic Functions

The Master File An Each Dedicated File Can Store One Or More Key Files

Each Key File Can Store Up To Four 3DES_16 Keys

Page 55: Gemalto MPCOS Version 0.1

COMMANDS THAT REQUIRE CRYPTOGRAPHIC KEYS

Page 56: Gemalto MPCOS Version 0.1

KEY TYPES

Keys

Administration Keys Used For The Computation of Temporary Administration Keys And Secure Messaging

Payment Keys Used For The Payment Commands Such As Transaction Certificate Generation And

The Computation Of Temporary Certification Keys

Log Keys

(Multi-purpose Keys)

Used For Initiate A Payment Session But Not An Administration Session

Signature Keys Dedicated To The Computation Of Signatures

Authentication Keys Used For Authentication Commands

Page 57: Gemalto MPCOS Version 0.1

COMMANDS THAT REQUIRE CRYPTOGRAPHIC KEYS

Page 58: Gemalto MPCOS Version 0.1

TRANSACTION MANAGER FILES

FDB: 0001 0001 b or 11 h

Each Dedicated File Holding Purse Files Must Also Hold A Transaction Manager File In Order To Recognize Payment Commands

A Transparent EF And Eight Bytes In Length

MF And Each DF Can Hold Only One Transaction Manager File

The Access Condition For Updating And Writing To Transaction Manager Files Must Be Locked

Page 59: Gemalto MPCOS Version 0.1

DATA STRUCTURE OF A TRANSACTION MANAGER FILE

Page 60: Gemalto MPCOS Version 0.1

CURRENT CARD TRANSACTION COUNTER (CURRENT CTC)

A Three Byte Counter That Is Incremented Every Time A Payment Transaction Session Is Established

Used As A Variable Element For Payment-Oriented Cryptographic Processing

Page 61: Gemalto MPCOS Version 0.1

BACKUP CARD TRANSACTION COUNTER (BACKUP CTC)

Stores The Value Of The Card Transaction Counter That Was Current Before The Last Transaction Was Executed

Page 62: Gemalto MPCOS Version 0.1

CKS AND CKS’

Invert(Exclusive-OR(First Three Bytes Of Each Word))

Page 63: Gemalto MPCOS Version 0.1

SECRET CODE FILES

FDB: 0010 0001 b or 21 h

Transparent EF

MF And Each DF Can Sore Up To One EF Secret Code

Only The First Secret Code File Created In The DF or MF Can Be Interpreted

Each Secret Code File Can Store Up To Eight Secret Codes

Secret Codes Are Stored On 8 Bytes

Page 64: Gemalto MPCOS Version 0.1

STRUCTURE OF SECRET CODE

Page 65: Gemalto MPCOS Version 0.1

SYST

Length = 4 Bits

The System Nibble Defines How The Secret Code Is To Be Entered

Page 66: Gemalto MPCOS Version 0.1

MAXIMUM PRESENTATION NUMBER (MPN)

Length = 3 Bits

Defines The Maximum Presentation Number On Nibble

Specifies The Number Of Times That The Secret Code Can Be Incorrectly Entered Consecutively Before MPCOS Locks It

From 2 to 8

Page 67: Gemalto MPCOS Version 0.1

RATIFICATION SECRET CODE (RSC)

Length = 8 Bits

Must Be Initialized With The Value FF h When Creating The Secret Code

The Counter Record The Number Of Consecutive Times That The Secret Code Has Been Presented Incorrectly And Decrements The Counter By One

Counter Value = MPN Value Card Locks The Secret Code

Secret Code Is Correctly Entered The Card Sets This Value To FF h

Page 68: Gemalto MPCOS Version 0.1

UNBLOCKING CODE REFERENCE (UCR)

Length = 4 Bits

Used For Unblocking The Secret Code On Three Least Significant Bits

Page 69: Gemalto MPCOS Version 0.1

UNBLOCKING CODE REFERENCE (UCR)

L = Define The Hierarchical Level Of The Secret Code EF Containing The UCR, 0: MF Level, 1: Local Level

Secret Code Number (SCN) = Defines The Secret Code Sequential Number In The Relevant Secret Code EF

Page 70: Gemalto MPCOS Version 0.1

SECRET CODE

Length = 4 Bytes

Extracts From The Least Significant Nibble Of Each Character Of Eight-Byte Secret Code

Page 71: Gemalto MPCOS Version 0.1

INTERNAL APPLICATION DATA FILE (IADF)

FDB: 0000 1001 b or 09 h

Transparent EF

Interpreted By The MPCOS Applet In Order To Return Information After The Selection Of A DF

Allows The Implementation Of The File Control Information (FCI) To Be Returned After The Selection of A DF

Any Number Of IADFs Can Be Created In A DF, But Only The First One Can Be Interpreted By OS

Page 72: Gemalto MPCOS Version 0.1

IADF STRUCTURE

Page 73: Gemalto MPCOS Version 0.1

BLOCK SIZE OF BLOCK 1 (BS1)

Length = 1 Byte

Defines The Block Size Of Block 1

If Size = 0 h No FCI Will Be Returned By The Card

Page 74: Gemalto MPCOS Version 0.1

BLOCK 1

Codes The Answer To Select FCI

Directly Interpreted By The MPCOS Applet To Build The Response Message When Selecting The DF

Page 75: Gemalto MPCOS Version 0.1

BLOCK 1

TLg Total Length Of The Response In Bytes

Tn, Ln, Vn Represent a proprietary TLV Format And Are Interpreted By The MPCOS Applet

Tn Represent A Proprietary Tag.

Page 76: Gemalto MPCOS Version 0.1

TAG VALUE

Tn = 55 h (Direct Addressing) : Vn Holds The Data To Be Sent And Ln Holds Its Length

Tn = AA h (Logical Addressing) : Vn Holds Logical Information Used By The Card To Access The Data And Ln

Holds Data Length

Page 77: Gemalto MPCOS Version 0.1

TAG VALUE

T Type (0: EF, 1: DF)

L Level (0: Global, 1: Local)

Short ID Short File Identifier (SFI) Of The File

Offset / Rec.nb. The Most Significant Bytes Of The Offset In The Case Of A Transparent File

Rec.nb. In The Case Of A Structured File

Offset Offset in Bytes :

•Logical Addressing In A DF Data Forms Part Of The DF Name

•Logical Addressing And When Addressing An EF The Read Access Conditions Should Be Unrestricted

•The Sum L1+L2+…+Ln Must Be Equal To TLg

Page 78: Gemalto MPCOS Version 0.1

BLOCK SIZE OF BLOCK 2 (BS2)

Length = 1 Byte

Defines The Block Size Of Block 2

Page 79: Gemalto MPCOS Version 0.1

BLOCK 2

Has No Administrative Meaning And May Be Used For Applicative Purpose

Page 80: Gemalto MPCOS Version 0.1

DIRECTORY FILE

Directory EF Is A Record EF Listing DDFs And Application Definitions Files Contained Within The Directory

Must Be Accessible By The Read Record Command

Page 81: Gemalto MPCOS Version 0.1

APPLICATION ELEMENTARY FILE

Application EF Is An Record EF That Contains The Data Element And TLV Format Used By The Application In Its Processing

Must Be Accessible By The Read Record Command

Page 82: Gemalto MPCOS Version 0.1

EF STRUCTURE

Transparent File

Structured File

Page 83: Gemalto MPCOS Version 0.1

TRANSPARENT FILE

FDB: 0000 0001 b or 01 h

Unstructured Sequence Of Bytes That Can Be Accessed By Specifying An Offset Relative To The Start Of EF

Offset Size = 4 Bytes

First Byte Relative Address 00 h

Page 84: Gemalto MPCOS Version 0.1

DATA REFERENCING IN A TRANSPARENT FILE

Page 85: Gemalto MPCOS Version 0.1

STRUCTURED FILE

Linear Fixed Files

Linear Variable Files

Cyclic Files

Page 86: Gemalto MPCOS Version 0.1

LINEAR FIXED FILE

FDB: 0000 0010 b or 02 h – No Further Information

Or FDB : 0000 0011 b or 03 h – Simple TLV (Tag, Length, Value)

Consist Of Sequence Of Individually Identifiable Records Of The Same Size

The Size Is Determined During The File Creation And Is Stored In The File Descriptor

Page 87: Gemalto MPCOS Version 0.1

LINEAR FIXED FILE

Records Are Referenced #1, #2, #3

Updating A Record Does Not Modify The Record Number

The Record Number Assigned To A Linear Fixed File Cannot Be Higher That 255

Page 88: Gemalto MPCOS Version 0.1

LINEAR FIXED FILE

Page 89: Gemalto MPCOS Version 0.1

LINEAR VARIABLE FILE

FDB: 0000 0100 b or 04 h – No Further Information

Or FDB : 0000 0101 b or 05 h – Simple TLV (Tag, Length, Value)

Page 90: Gemalto MPCOS Version 0.1

LINEAR VARIABLE FILE

The Record Selection Is The Same As For Linear Files With Records Of Fixed Size

The Is Handled By The Interface As A Sequence Of Independent Record

Page 91: Gemalto MPCOS Version 0.1

LINEAR VARIABLE FILE

Page 92: Gemalto MPCOS Version 0.1

CYCLIC ELEMENTARY FILE

FDB: 0000 0110 b or 06 h – No Further Information

Or FDB : 0000 0111 b or 06 h – Simple TLV (Tag, Length, Value)

Page 93: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 94: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 95: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 96: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 97: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 98: Gemalto MPCOS Version 0.1

DISCUSSION

Page 99: Gemalto MPCOS Version 0.1

AGENDA

1. Abstract

2. Features

3. File and Data Structure

4. Access Condition

5. Cryptography

6. Command Format

7. Commands

8. Discussion

9. References

Page 100: Gemalto MPCOS Version 0.1

REFERENCES

• MPCOS- Reference Manual, Document Reference: DOC108514B, 2007

• MPCOS-Product Training, 2008