Mchip Card Application Cryptographic Algorithms
Mchip Card Application Cryptographic Algorithms
Cryptographic
Algorithms
March 2010
Notices
Proprietary Rights The information contained in this document is proprietary and
confidential to MasterCard International Incorporated, one or more of its
affiliated entities (collectively "MasterCard"), or both.
This material may not be duplicated, published, or disclosed, in
whole or in part, without the prior written permission of MasterCard.
MasterCard provides the information in this document (or in any
translated document) to its customers for internal use only, “AS IS,” and
makes no representations or warranties of any kind with respect to such
information, including, but not limited to, its accuracy or reliability.
Trademarks Trademark notices and symbols used in this document reflect the
registration status of MasterCard trademarks in the United States. Please
consult with the Customer Operations Services team or the MasterCard
Law Department for registration status of particular product, program, or
service names outside the United States.
All third-party product and service names are trademarks or registered
trademarks of their respective owners.
Information MasterCard provides details about the standards used for this
Available Online document—including times expressed, language use, excerpted text,
and contact information—on the Member Publications Support page
available on MasterCard OnLine®. Go to Member Publications Support
for centralized information.
©2008–2010 MasterCard
March 2010 • M/Chip Card Application Cryptographic Algorithms
Summary of Changes
This document reflects changes associated with the M/Chip Application Cryptographic Algorithm
manual.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 1
Summary of Changes
Corrections to text and data on ARPC Validation Example 3. ARPC Validation Example 3
Correction to text and data on ARPC Validation Example 4. ARPC Validation Example 4
Updated text under Script MAC Validation Example 1. Script MAC Validation
Example 1
Updated text under Script MAC Validation Example 2. Script MAC Validation
Example 2
Updated text under Script MAC Validation Example 3. Script MAC Validation
Example 3
Updated text under Script MAC Validation Example 4 Script MAC Validation
Example 4
Updated data under Generate AC Command. Generate AC Command
Updated text in Offline Encipherment PIN Decryption Details. PIN Decryption Details
©2008–2010 MasterCard
2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Table of Contents
Part 1 - Dynamic Data Authentication.................................................................1
Chapter 5 Offline Enciphered PIN Decryption for Offline Change PIN ........ 5-i
About Offline Enciphered PIN Decryption for Offline Change PIN ........................................ 5-1
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 i
Table of Contents
©2008–2010 MasterCard
ii March 2010 • M/Chip Card Application Cryptographic Algorithms
Table of Contents
Part 14 - Examples.................................................................................................1
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 iii
Table of Contents
©2008–2010 MasterCard
iv March 2010 • M/Chip Card Application Cryptographic Algorithms
Table of Contents
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 v
Part 1 - Dynamic Data
Authentication
Chapter 1 Standard Dynamic Data Authentication (DDA)
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 1-i
Standard Dynamic Data Authentication (DDA)
Standard DDA
Standard DDA
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 X Select 4 Lite 4 X Select 4 X Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data Storage
1.1a 1.1a 1.1a 1.1a
X 2.2 DDA Lite 4 X Select 4 Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
1-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 2 Combined Dynamic Data Authentication and
AC Generation (CDA)
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 2-i
Combined Dynamic Data Authentication and AC Generation (CDA)
About CDA
About CDA
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 X Select 4 Lite 4 X Select 4 X Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data Storage
1.1a 1.1a 1.1a 1.1a
2.2 DDA Lite 4 X Select 4 Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
Similarly, the issuer public key is present in the ICC in the form of an issuer
Public Key certificate signed the Certification Authority Private Key.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 Lite 4 1.0 X Select 4 X Payment
1.0 1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 X Select 4 Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 2-1
Combined Dynamic Data Authentication and AC Generation (CDA)
CDA Details (Variant 1)
The content of CDOL1, CDOL2 and the value field of PDOL are defined by the
application.
©2008–2010 MasterCard
2-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Combined Dynamic Data Authentication and AC Generation (CDA)
CDA Details (Variant 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 Select 4 Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 2-3
Combined Dynamic Data Authentication and AC Generation (CDA)
CDA Details (Variant 2)
In all other cases, the ICC Dynamic Data shall consist of the concatenation
of the following fields:
The content of CDOL1, CDOL2 and the value field of PDOL are defined by the
application.
Note that when the DS Data is present in the Generate AC command,
CDOL1/CDOL2 Related Data is only part of the First Generate AC/Second
Generate AC command data.
©2008–2010 MasterCard
2-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Combined Dynamic Data Authentication and AC Generation (CDA)
CDA Details (Variant 2)
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 2-5
Part 2 - Recover AC
Chapter 3 Recover AC
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 3-i
Recover AC
Recover AC With CDA (Variant 1)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 Select 4 X Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 3-1
Recover AC
Recover AC With CDA (Variant 2)
Signature
The signature of the dynamic application data for Recover AC with CDA is
performed using the same method and input as defined in EMV, Integrated
Circuit Card Specification for Payment Systems, Book 2 — Security and Key
Management to sign for Dynamic Application Data for CDA.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 Select 4 Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
3-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Recover AC
Recover AC With CDA (Variant 2)
In all other cases, the ICC Dynamic Data shall consist of the concatenation
of the following fields:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 3-3
Recover AC
Recover AC With CDA (Variant 2)
Signature
The signature of the dynamic application data for Recover AC with CDA is
performed using the same method and input as defined in EMV, Integrated
Circuit Card Specification for Payment Systems, Book 2 — Security and Key
Management to sign for Dynamic Application Data for CDA.
©2008–2010 MasterCard
3-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Part 3 - Offline Enciphered
PIN Decryption for Verify
Chapter 4 Offline Enciphered PIN Decryption for Verify
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 4-i
Offline Enciphered PIN Decryption for Verify
About Offline Enciphered PIN Decryption for Verify
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment
1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 4-1
Part 4 - Offline Enciphered
PIN Decryption for Offline
Change PIN
Chapter 5 Offline Enciphered PIN Decryption for Offline
Change PIN
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 5-i
Offline Enciphered PIN Decryption for Offline Change PIN
About Offline Enciphered PIN Decryption for Offline Change PIN
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 5-1
Part 5 - Application
Cryptograms Generation
Chapter 6 Application Cryptograms Generation
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-i
Application Cryptograms Generation
About Application Cryptograms
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Transaction Date 3 9A
Transaction Type 1 9C
ATC 2 9F36
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-1
Application Cryptograms Generation
Data Objects for Generating Application Cryptograms (Variant 2)
Variant 1 什么时候使用 Variant 1 ?
M/Chip
Variant 2
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
option 1
option 2 Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
Variant 3(不适用于M/Chip Advance) 1.0
option 1
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
option 2
1.1a 1.1a 1.1a 1.1a Storage
option 3a
option 3b 2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
option 3c 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
6-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Application Cryptograms Generation
Data Objects for Generating Application Cryptograms (Variant 3)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-3
Application Cryptograms Generation
Data Objects for Generating Application Cryptograms (Variant 3)
*The mapping of the 6–byte internal CVR to the four bytes used for the
cryptogram generation is detailed in the card application specifications.
©2008–2010 MasterCard
6-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Application Cryptograms Generation
Data Objects for Generating Application Cryptograms (Variant 3)
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-5
Application Cryptograms Generation
Application Cryptogram Generation Process (Variant 1)
1. The ICC concatenates the previously listed Data Elements in the order
specified, to create a block of data.
2. The ICC pads this block of data according to method 2 of ISO/IEC
9797-1 Standard, Information technology – Security techniques – Message
Authentication Codes - Part 1: Mechanisms using a block cipher.
It first adds a mandatory byte with hexadecimal ‘80’ to the right,
and then adds the smallest number of hexadecimal ‘00’ bytes
to the right, so that the length of the resulting message M :=
(M||‘80’||‘00’||‘00’||...||‘00’) is a multiple of eight bytes.
3. The ICC formats the padded data into 8-byte data blocks, labeled D1, D2,
… , Dn.
4. The ICC derives the 16-byte MasterCard proprietary session key SKAC as
specified in Encrypted Counters Encryption Variant 1.
见 Chapter 14 Encrypted Counters
5. The ICC computes the MAC on the message M as detailed in Cryptographic
Primitives to generate the AC using the session key SKAC. The AC is the
eight-byte final result.
©2008–2010 MasterCard
6-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Application Cryptograms Generation
Application Cryptogram Generation Process (Variant 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
1. The ICC concatenates the previously listed Data Elements in the order
specified, to create a block of data.
2. The ICC pads this block of data according to method 2 of ISO/IEC
9797-1 Standard, Information technology – Security techniques – Message
Authentication Codes - Part 1: Mechanisms using a block cipher.
It first adds a mandatory byte with hexadecimal ‘80’ to the right,
and then adds the smallest number of hexadecimal ‘00’ bytes
to the right, so that the length of the resulting message M :=
(M||‘80’||‘00’||‘00’||...||‘00’) is a multiple of eight bytes.
3. The ICC formats the padded data into 8-byte data blocks, labeled D1, D2,
… , Dn.
4. The ICC derives the 16-byte session key SKAC as specified in ICC Session
Key Derivation.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-7
Application Cryptograms Generation
Application Cryptogram Generation Process (Variant 4)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 Select 4 X Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
1. The ICC concatenates the previously listed Data Elements in the order
specified, to create a block of data.
2. The ICC pads this block of data according to method 2 of ISO/IEC
9797-1 Standard, Information technology – Security techniques – Message
Authentication Codes - Part 1: Mechanisms using a block cipher.
It first adds a mandatory byte with hexadecimal ‘80’ to the right,
and then adds the smallest number of hexadecimal ‘00’ bytes
to the right, so that the length of the resulting message M :=
(M||‘80’||‘00’||‘00’||...||‘00’) is a multiple of eight bytes.
3. The ICC formats the padded data into 8-byte data blocks, labeled D1, D2,
… , Dn.
4. The AC Session key is as follows: .
• For first GENERATE AC, the ICC derives the 16-byte session key SKAC as
specified in ICC Session Key Derivation
©2008–2010 MasterCard
6-8 March 2010 • M/Chip Card Application Cryptographic Algorithms
Application Cryptograms Generation
Application Cryptogram Generation Process (Variant 4)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 X Select 4 Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
1. The ICC concatenates the previously listed Data Elements in the order
specified, to create a block of data.
2. The ICC pads this block of data according to method 2 of ISO/IEC
9797-1 Standard, Information technology – Security techniques – Message
Authentication Codes - Part 1: Mechanisms using a block cipher.
It first adds a mandatory byte with hexadecimal ‘80’ to the right,
and then adds the smallest number of hexadecimal ‘00’ bytes
to the right, so that the length of the resulting message M :=
(M||‘80’||‘00’||‘00’||...||‘00’) is a multiple of eight bytes.
3. The ICC formats the padded data into 8-byte data blocks, labeled D1, D2,
… , Dn.
4. The AC Session key is as follows: .
• For first GENERATE AC, the ICC derives the 16-byte session key SKAC as
specified in About ICC Session Key Derivation.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 6-9
Part 6 - Issuer Authentication
Chapter 7 Issuer Authentication
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 7-i
Issuer Authentication
About Issuer Authentication
ARPC Response Code Tag:– Length:2 【ARC】
About Issuer Authentication Authorisation Response Code(ARC) Tag: '8A'
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0 1.0
X 2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 7-1
Issuer Authentication
ARPC Validation Process (Variant 3)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
1. The MasterCard Proprietary SKD method was referred to in previous versions of this manual as "M/Chip 2.1
Session Key Derivation".
©2008–2010 MasterCard
7-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Issuer Authentication
ARPC Validation Process (Variant 3)
2. The MasterCard Proprietary SKD method was referred to in previous versions of this manual as "M/Chip 2.1
Session Key Derivation".
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 7-3
Part 7 - Secure Messaging
Chapter 8 Secure Messaging
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 8-i
Secure Messaging
About Secure Messaging
Objectives
The objectives of secure messaging are to ensure the following:
Objectives Description
Message integrity Message integrity is achieved using a Message
Authentication Code (MAC).
Data confidentiality Data confidentiality is achieved by enciphering the plain
text command data.
Issuer authentication Issuer authentication is achieved using a Message
Authentication Code (MAC).
Input: RAND
对于第1个发卡行脚本命令, Secure Messaging for Integrity (SMI) uses an eight-byte data value RAND as
RAND是GAC1响应的密文。 input to the SMI MAC computation. In the case of MasterCard proprietary
对于第2个命令,RAND+1 SKD the RAND is also used for the session key derivation. For the first script
command processed in the transaction, RAND is the AC provided by the card
MC SKD和 EMV CSK 方式都使用 in response to the first GENERATE AC command. For subsequent commands,
RAND计算MAC, RAND is obtained by incrementing the RAND used for the previous command
by 1.
但是MC SKD 还使用RAND计算
过程密钥(RAND每次+1)。 Specifically, RAND, as a multi-byte counter, is incremented in the same way
EMV CSK 使用 GAC1 AC密文计算 as the two-byte ATC. Therefore, incrementing RAND when its least significant
过程密钥(AC每次不变)。 byte is 0xFF results in the next least significant byte being incremented and the
least significant byte being set to 0x00. In the unlikely event that all the bytes of
RAND equal 0xFF, the RAND is incremented by setting all its bytes to 0x00 (that
is, the RAND counter wraps around).
RAND超上限,则清零。
In the case of MasterCard proprietary SKD, the RAND value used in a script
command for the session key derivation is identical to the one used for the
Secure Messaging for Integrity MAC computation.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 8-1
Secure Messaging
Secure Messaging for Integrity (SMI) Validation Process (Variant 1)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
X 2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
8-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Secure Messaging
Secure Messaging for Integrity (SMI) Validation Process (Variant 3)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 8-3
Secure Messaging
PIN CHANGE Command Decryption Process (Variant 1)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
8-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Secure Messaging
PIN CHANGE Command Decryption Process (Variant 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
X 2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Introduction
The PIN CHANGE command is protected by combining Secure Messaging
for Integrity with the privacy of the data provided by Secure Messaging for
Confidentiality.
The ICC must perform the following steps to decrypt the command:
M := DES3-1 (SKSMC)[X]
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 8-5
Secure Messaging
PIN CHANGE Command Decryption Process (Variant 3)
Introduction
The PIN CHANGE command is protected by combining Secure Messaging
for Integrity with the privacy of the data provided by Secure Messaging for
Confidentiality.
The ICC must perform the following steps to decrypt the command:
• the EMV2000 SKD session key derivation is used (as indicated in the
Application Control) and
• the EMV2000 session key SKSMC has already been derived for the
current value of the ATC, and is still present in the key container.
Otherwise, a session key SKSMC session key must be derived as specified
in About ICC Session Key Derivation.
M:=DES3-1 (SKSMC)[X]
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
8-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Secure Messaging
PIN CHANGE Command Decryption Process (Variant 3)
Introduction
The PIN CHANGE command is protected by combining Secure Messaging
for Integrity with the privacy of the data provided by Secure Messaging for
Confidentiality.
The ICC must perform the following steps to decrypt the command:
M:=DES3-1 (SKSMC)[X]
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 8-7
Part 8 - ICC Session Key
Derivation
Chapter 9 ICC Session Key Derivation
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 9-i
ICC Session Key Derivation
About ICC Session Key Derivation
1. The MasterCard Proprietary SKD method was referred to in previous versions of this manual as "M/Chip 2.1
Session Key Derivation".
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 9-1
Chapter 10 MasterCard Proprietary SKD Method
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 10-i
MasterCard Proprietary SKD Method
MasterCard Proprietary SKD Method Key
Left Part
使用双长度密钥加密8字节数据, The left part of the double-length session key is obtained by applying the DES3
当双长度密钥的左右两部分相同时, algorithm with the double-length ICC Master Key to the eight-byte data-block,
加密结果等于只使用左部分密钥加密。 obtained by replacing the third most significant byte R2 of R by the byte ‘F0’.
比如11223344556677881122334455667788作为密钥,
加密0000000000000000的结果, SKL := DES3(MK) [(R0||R1||‘F0’||R3||R4||R5||R6||R7)]
与1122334455667788作为密钥
加密0000000000000000的结果相同。
Right Part
The right part of the double-length session key is obtained by applying the DES3
algorithm with the double-length ICC Master Key to the eight-byte data-block,
obtained by replacing the third most significant byte R2 of R by the byte ‘0F’.
AC Session Key
Derivation
The AC session key SKAC is derived using an eight-byte number R formed with
the ATC and the UN as follows:
Data Elements
The following Data Elements involved in the Application Cryptogram Session
Key Derivation (MasterCard Proprietary SKDMCI):
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 10-1
MasterCard Proprietary SKD Method
Secure Messaging Session Key
RAND
For the first script command processed in the transaction, RAND is the AC
provided by the card in response to the first GENERATE AC command. For
subsequent script commands, RAND is obtained by incrementing the RAND
used for the previous command by 1.
R := RAND
©2008–2010 MasterCard
10-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 11 EMV2000 Method Key
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 11-i
EMV2000 Method Key
EMV2000 Method Key
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
EMV2000
The algorithm for deriving session keys (SKAC, SKSMI, SKSMC) used for
computing application cryptograms, validating scripts received with secure
messaging, and for verifying ARPCs is defined in EMV2000, Integrated Circuit
Card Specification for Payment Systems, Book 2 – Security and Key Management,
Version 4.0, December 31 2000.
SK :=
SKDEMV2000(MK)[(ATC||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’)]
Initializing Value
The initializing value IV of the EMV2000 session key derivation is a 16-byte
string of binary zeros:
IV := (‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||
‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’)
Data Elements
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 11-1
EMV2000 Method Key
EMV2000 Method Key
GP := IKH-2, ATCSK/b2
P := IKH-1, ATCSK/b
where "/" denotes integer division, H is the height of the tree and b is the
branch factor.
For M/Chip implementation, the height of the tree H is 8 and the branch factor b
is 4.
• If ATC > ATCSK then the session key can be derived as described in
EMV2000, Integrated Circuit Card Specification for Payment Systems, Book
2 – Security and Key Management, Version 4.0, December 31 2000. When
this is done, the values of GP and P stored in the ICC must be updated and
ATCSK must be set to ATC.
• If ATC SK = ATCSK then the session key has already been derived and does
not require to be derived again.
• If ATC < ATCSK then session key derivation must fail.
©2008–2010 MasterCard
11-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 12 EMV CSK Method
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 12-i
EMV CSK Method
EMV CSK Method Key
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
EMV
The algorithm for deriving session keys (SKAC, SKSMI, SKSMC) used for computing
application cryptograms, validating scripts received with secure messaging, and
for verifying ARPCs is defined in EMV, Integrated Circuit Card Specification for
Payment Systems, Book 2 – Security and Key Management. Version 4.2, June
2008.
SK := SKDCSK(MK) [R]
SK := (SKL||SKR)
Left Part
The left part of the double-length session key is obtained by applying the DES3
algorithm with the double-length ICC Master Key to the eight-byte data-block,
obtained by replacing the third most significant byte R2 of R by the byte ‘F0’.
Right Part
The right part of the double-length session key is obtained by applying the DES3
algorithm with the double-length ICC Master Key to the eight-byte data-block,
obtained by replacing the third most significant byte R2 of R by the byte ‘0F’.
R可以是RAND或AC
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 12-1
EMV CSK Method
AC Session Key
AC Session Key
Derivation
For AC session key derivation:
R := Application Cryptogram
SKSMI := SKDCSK(MKSMI)[R]
SKSMC := SKDCSK(MKSMC)[R]
©2008–2010 MasterCard
12-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Part 9 - ICC Dynamic Number
Generation
Chapter 13 ICC Dynamic Number Generation
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 13-i
ICC Dynamic Number Generation
ICC Dynamic Number Generation Process
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment
1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 DDA Lite 4 X Select 4 Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
Description
The ICC Dynamic Number (IDN) is generated by the ICC. A DES3 encryption
with the 16-byte DES3 ICC Master Key MKIDN is applied on an 8-byte buffer
formed by the ICC Application Transaction Counter (ATC) right padded with
6 zero-bytes.
IDN :=
DES3(MKIDN)[(ATC||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’)]
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 13-1
Part 10 - Encrypted Counters
Chapter 14 Encrypted Counters
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 14-i
Encrypted Counters
Encrypted Counters
Encrypted Counters
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
Encrypted Counters
• The ICC contains offline counters to protect against a fraudulent use of the
card in offline mode.
• The ICC may be personalized to include these offline counters in the Issuer
Application Data (IAD) in clear or in encrypted form. The IAD is transmitted
to the issuer.
SKAC := (SKL||SKR)
ECKL :=
SKL Å (‘59’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’)
ECKR :=
SKR Å (‘95’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’||‘00’)
ECK := (ECKL||ECKR)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 14-1
Encrypted Counters
Encrypted Counters Encryption (Variant 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 Select 4 X Payment
1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
14-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Part 11 - Dynamic CVC3
Chapter 15 Dynamic CVC3
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 15-i
Dynamic CVC3
Dynamic CVC3 Generation
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
Description
PayPass defines a dynamic CVC3 for the Track 1 Data (CVC3TRACK1) and a
dynamic CVC3 for the Track 2 Data (CVC3TRACK2).
Both cryptograms are generated by the ICC by applying the same secret key
on the same dynamic data (UN and ATC), but with a different initialization
vector (IVCVC3TRACK1 for CVC3TRACK1 and IVCVC3TRACK2 for CVC3TRACK2). The
initialization vectors are static data stored on the IC.
1. Concatenate the data listed in this table in the order specified to obtain an
8-byte data block (D):
2. Calculate O as follows:
O := DES3(KDCVC3) [D]
3. The two least significant bytes of O are the CVC3TRACK1.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 15-1
Part 12 - Data Storage
Chapter 16 Data Storage
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 16-i
Data Storage
Data Storage — OWHF1 Function
OWHF1 Function
This section is only applicable to M/Chip Advance Data Storage:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 1.0 Select 4 Payment
1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 16-1
Data Storage
Data Storage — OWHF2 Function
K3 := DES(K1)[X1] Å X1
R := X1 Å X2 Å DES(K3)[DES-1(K2)[DES(K3)[X2]]
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 1.0 Select 4 Payment
1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
16-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Data Storage
Data Storage — OWHF2 Function
• Set X as follows:
R := DS Input T Å DES(K1)[DES-1(K2)[DES(K1)[X]]
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 16-3
Part 13 - Cryptographic
Primitives
Chapter 17 Cryptographic Primitives
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 17-i
Cryptographic Primitives
About DES and Triple-DES
More precisely, the single-DES and its triple-DES (DES3) version, described
below, are used in the session key derivation and the cryptographic mechanisms
described in parts 3 to 16.
Encryption
The DES algorithm takes as input an eight-byte plain text block X, and an 8-byte
secret key K, and produces an 8-byte ciphertext block Y.
Y:= DES(K)[X]
K = (KL||KR)
as follows:
Decryption
Reversal of the DES function is denoted as:
X:= DES-1(K)[Y]
CBC Mode
Triple DES Encryption in CBC mode of an 8n-byte block X with a secret key K
and an 8–byte initial value IV is denoted as:
Y : = DES3CBC(K)[X}
X = X1 ||...|| Xn
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 17-1
Cryptographic Primitives
MAC
Y1:=DES3(K)[X1 Å IV]
Yi:=DES3(K)[Xi Å Yi-1] (for i = 2, ..., n)
The result is the 8n-byte value Y formed by concatenating Y1, ..., Yn.
Y: = Y1 ||...|| Yn
MAC
The MAC computation is performed by using:
1. Divide the data into a set of eight-byte data blocks labeled X1, X2, … , Xn
2. Compute the intermediate results for i = 1, 2, … , n
Yi := DES(KL)[Xi Å Yi-1]
Where:
Y0 := 0
3. The MAC is:
RSA
EMV
The RSA algorithm is the asymmetric reversible cryptographic algorithm used
in the digital signature scheme described in Part III of EMV, Integrated Circuit
Card Specification for Payment Systems, Book 2 – RSA Algorithm for offline
data authentication.
©2008–2010 MasterCard
17-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Cryptographic Primitives
RSA
Description Length
Certification Authority Public Key 128 £ NCA £ 248
Modulus
Issuer Public Key Modulus 96 £ NI £ NCA
ICC Public Key Modulus 96 £ NIC £ NI
ICC PIN Encipherment Public Key 96 £ NPE £ NI
Modulus
MasterCard determines the lengths and expiry dates of CA keys for M/Chip
products. Issuers must refer to MasterCard Chip Issuer Security Guidelines
which are based on best industry practice to determine appropriate lengths and
expiry dates for their issuer and ICC keys.
Keys
The private key SK of the RSA digital signature scheme, with an odd public key
exponent e, consists of two prime numbers p and q, such that (p – 1) and (q –
1) are co-prime to e and a private exponent d such that:
ed ≡ 1 mod (p – 1)(q – 1)
This document allows for the option to implement RSA private key functions
using the Chinese Remainder Theorem for which some recommendations are
provided in the documents MasterCard Chip Issuer Security Guidelines and
Smart Card Cryptographic Algorithm Implementation Guidelines. However,
specification of this implementation method is beyond the scope of this
document.
Signing Function
The signing function for RSA with an odd public key exponent is defined as:
Recovery Function
The recovery function for RSA with an odd public key exponent is equal to:
X = Recover(PK)[S] := Se mod n
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 17-3
Cryptographic Primitives
SHA-1
The signing function and the recovery function are used in offline data
authentication and in offline PIN Encipherment. SeePart III of EMV, Integrated
Circuit Card Specification for Payment Systems, Book 2 Annex A2.1 (Digital
Signature Scheme Giving Message Recovery) and sections 5,6, and 7 for further
details.
SHA-1
ISO/IEC 10118-3 Standard
The Secure Hash Algorithm (SHA-1), as described in the ISO/IEC 10118-3
Standard, Information technology – Security techniques – Hash-functions – Part
3: Dedicated hash-functions, and FIPS 180-2, Secure Hash Standard, August
2002 publication, is used in the digital signature scheme used for static and
dynamic data authentication. SHA-1 takes as input messages M of arbitrary
length, and produces a 20-byte hash value H:
H := SHA(M)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Principles
The EMV2000 session key derivation function takes as input the 16-byte ICC
Master Key MK and the 2-byte ATC, and produces as output the 16-byte ICC
Session Key SK.
The session key derivation function generates a unique session key for each
ICC application transaction. It does this by generating a "tree" of keys. This tree
has the ICC Master Key at its base and then numerous levels of intermediate
keys above it, each intermediary key being derived from keys beneath it in the
tree. On top of the tree are the session keys, one session key per value of the
Application Transaction Counter (ATC).
©2008–2010 MasterCard
17-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Cryptographic Primitives
EMV 2000 Session Key Derivation
Parameters
The session key derivation function has two parameters:
• H, the height of the tree, that is, the number of levels of intermediary keys
in the tree excluding the base level;
• b, the branch factor, that is, the number of "child" keys that a "parent" key
(which must be one level lower in the tree) derives.
The number of possible session keys is bH and this must exceed the maximum
value of the ATC which is 216 - 1.
Key Derivation
Let Φ be the function that maps two 16-byte numbers X and Y and an integer
j onto a 16-byte number as follows:
Let define IK0,0 as the ICC Master Key, hence IK0,0 := MK. This key is used to
derive b intermediate keys at level 1 of the tree. For j = 0, ..., b-1:
IK1,j := Φ(MK , IV , j)
where IV is a 16-byte initializing value, not necessarily secret.
An intermediate key in a higher level is derived from its parent and grandparent
using the function Φ. Specifically the jth key (0 £ j £ bi-1) in level i (2 £ i £
H) is derived as
Let
X := IKH,ATC Å IKH-2,ATC/b2
The session key SK is defined to be X, with the exception of the least significant
bit of each byte of X which is set to a value that ensures that each of the 16
bytes of SK has an odd number of nonzero bits (this to conform with the odd
parity requirements for DES keys). Note that the forcing of the parity bits of DES
keys only takes place for the session keys, but not for the intermediate keys.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 17-5
Cryptographic Primitives
EMV 2000 Session Key Derivation
Implementation Values
For M/Chip, we have:
• b=4
• H=8
This supports a card limited to perform no more that 216 transactions.
• IV = zero
Implementation in Pseudo-Code
Below a straightforward implementation of the function is given in pseudo-code.
In this implementation (a0, a1, . . . , aH-1) denotes the b-ary representation of
the ATC at the time of the transaction, hence:
The computation of the session key SK from the ICC Master Key MK for the
current value of the ATC takes place as follows:
GP=MK;
P=Φ(MK,IV,a0);
for (i=1;i<H-1;i++){
T=P;
P=Φ(P,GP,ai);
GP=T;
}
SK=PAR(Φ(P,GP,aH-1)ÅGP);
The implementation above uses the MK each time a session key is derived.
However an actual ICC implementation should not reuse the MK for each
session key derivation, but should calculate the session keys from saved
intermediate keys that are changed regularly. This will limit the usage of a
specific key in the cryptographic operations. More details are given below.
In the session key derivation function, the derivation of intermediate level keys
is reversible, that is, given knowledge of an intermediate key and its parent it
is possible to derive its grandparent. This means that a card which stores an
intermediate key IK and its parent can then determine any other key in the tree,
including any session key. Below an example is given in pseudo-code of an
implementation of the session key derivation function using this property and
ensuring that an intermediate key is only used a limited number of times.
GP := IKH-2,0
P := IKH-1,0
©2008–2010 MasterCard
17-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Cryptographic Primitives
EMV 2000 Session Key Derivation
Let (a0, a1, . . . , aH-1) again denote the b-ary representation of the ATC at the
time of the transaction, hence
and let (c0, c1, . . . , cH-1) denote the b-ary representation of the value ATCOLD
of the ATC at the time of the previous session key derivation:
The computation of the session key SK for the current value of the ATC takes
place as follows:
The algorithm above can be made more efficient by storing more than 2
intermediate keys. This however requires more memory.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 17-7
Part 14 - Examples
Chapter 18 Notation Used
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 18-i
Notation Used
Notation Used
Notation Used
Data Input, Intermediate Values
In the following examples, data input and intermediate values are shown as a
succession of byte values against a light gray background. For example:
13 33 90 00 00 61 65
05 01 09 08 56 D3 96 58 A2 EE D9 B1 BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB A0 B1 C2 D3
Data Samples
This document contains data samples to illustrate the cryptographic algorithms
applicable for each version of the chip application. While the computation
is detailed as precisely as possible, data values contained in the samples are
not guaranteed to be correct.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 18-1
Chapter 19 Purchase with Online Authorization
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-i
Purchase with Online Authorization
MasterCard Proprietary Session Key Derivation for AC
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
Input
For AC computation, the input is the concatenation of:
34 56
• Two zero bytes:
00 00
• Terminal Unpredictable Number (UN):
11 11 11 11
Concatenation:
34 56 00 00 11 11 11 11
Output
The concatenation of:
• The Triple-DES Encryption of the input with the third byte replaced by ‘F0’
• The Triple-DES Encryption of the input with the third byte replaced by ‘0F’
SKAC =
DES3(MKAC)[(ATC||‘F0’||‘00’||‘11’||‘11’||‘11’||‘11’)]||
DES3(MKAC)[(ATC||‘0F’||‘00’||‘11’||‘11’||‘11’||‘11’)]
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
The result can be submitted to parity forcing, like the Card Master Keys. This is
not shown here as this is entirely internal to the ICC, and the computation is not
affected. This is not recommended for security reasons.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-1
Purchase with Online Authorization
EMV2000 Session Key Derivation for AC
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Card Master Key MKAC for AC computation:
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
Input
For AC computation, the input is the concatenation of:
34 56
• The b-ary representation (a0, … , a7) of the ATC is:
(0, 3, 1, 0, 1, 1, 1, 2)
Output
Following the algorithm described in Chapter ICC Key Derivation, the
intermediate results P and GP are:
• Round 0 – GP is MKAC, P:
8F 2C 44 84 04 9D 89 5E FC 38 87 39 92 FF 31 C7
• Round 1 – P
:26 72 82 0B C6 44 4F A4 F3 3F 77 C2 29 AC E7 CC
• Round 2 – P:
BD 19 AB 52 5D 14 BF B3 57 69 98 20 7B 98 28 DA
• Round 3 – P:
FC 03 48 6E 7E 78 75 91 5A DE FD 42 8D CA 77 63
• Round 4 – P:
10 A9 BD B3 25 AF CF 3C 26 37 C9 DA 31 7C 74 8D
• Round 5 – P:
A2 54 F0 78 C1 C2 DF 02 1C 5F B4 C8 4B E5 BB E2
• Round 6 – P:
©2008–2010 MasterCard
19-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
Common Session Key Derivation for AC
F3 05 46 84 41 BE A4 5B A2 35 A2 8B CD F7 44 B6
51 16 15 DB 96 C8 52 63 D5 5C 0C 02 A8 A0 54 F9
This is bitwise XOR-combined with the GP from round 6 (equals P from round
5):
F3 42 E5 A3 57 0A 8D 61 C9 03 B8 CA E3 45 EF 1B
F2 43 E5 A2 57 0B 8C 61 C8 02 B9 CB E3 45 EF 1A
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment *
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage *
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
Key
The Card Master Key MKAC for AC computation:
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
Input
For AC computation, the input is the concatenation of:
34 56
• Six zero bytes:
00 00 00 00 00 00
Concatenation:
34 56 00 00 00 00 00 00
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-3
Purchase with Online Authorization
ARQC Generation (Example 1)
Output
The concatenation of:
• The Triple-DES Encryption of the input with the third byte replaced by ‘F0’
• The Triple-DES Encryption of the input with the third byte replaced by ‘0F’
SKAC = DES3(MKAC)[(ATC||‘F0’||‘00’||‘00’||‘00’||‘00’||‘00’)]||
DES3(MKAC)[(ATC||‘0F’||‘00’||‘00’||‘00’||‘00’||‘00’)]
18 20 25 BA 4F 4B 32 F5 A6 3A 1B A5 E6 84 5D 4E
The result can be submitted to parity forcing, like the Card Master Keys. This is
not shown here as this is entirely internal to the ICC, and the computation is not
affected. This is not recommended for security reasons.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.0.5, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control [5][4..2]='001' or if Application
Control [5][4..2]='010'.
Key
The Session Key SKAC as derived above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
©2008–2010 MasterCard
19-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
ARQC Generation (Example 2)
Input
The input is the concatenation of the values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40 08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
03 A4 00 20
Concatenation:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 03 A4 00 20
Output
ARQC = MAC(SKAC)[Input]:
DB C1 E0 B8 20 FF E7 DB
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-5
Purchase with Online Authorization
ARQC Generation (Example 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Key for the ARQC generation depends on the Session Key derivation
algorithm used and is derived as described above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
• For Session Key derivation for EMV 2000 Session Key Derivation
F2 43 E5 A2 57 0B 8C 61 C8 02 B9 CB E3 45 EF 1A
Input
The input is the concatenation of the values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
©2008–2010 MasterCard
19-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
ARQC Generation (Example 3)
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
03 A4 00 20
Concatenation:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 03 A4 00 20
Output
ARQC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
• For Session Key derivation for EMV 2000 Session Key Derivation
0B 8C CD BA F7 80 BA A8
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKAC as derived above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-7
Purchase with Online Authorization
ARQC Generation (Example 3)
Input
The input is the concatenation of the values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
A0 80 03 24 20 00
Concatenation1:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 A0 80 03 24 20 00
Output
ARQC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
1. In this example, the Offline Counters are not included in the generation of the ARQC (Application Control[2][1]
= ‘0b’).
©2008–2010 MasterCard
19-8 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
ARQC Generation (Example 4)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Key for the ARQC generation depends on the Session Key derivation
algorithm used and is derived as described above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
• For Common Session Key derivation
18 20 25 BA 4F AB 32 F5 A6 3A 1B A5 E6 84 5D 4E
Input
The input is the concatenation of the values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-9
Purchase with Online Authorization
ARPC Validation (Example 1)
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
A0 80 03 24 20 00
Concatenation2
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 A0 80 03 24 20 00
Output
ARQC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
• For Common Session Key derivation
F9 F9 12 12 C0 DF 65 BA
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.05, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control[5][4..2]='001' or if Application
Control[5][4..2]='010'.
2. In this example, the Offline Counters are not included in the generation of the ARQC (Application Control[2][1]
= ‘0b’).
©2008–2010 MasterCard
19-10 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
ARPC Validation (Example 2)
Key
The Key for ARPC validation is the MKAC
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
Input
The input is the XOR of:
• The ARQC:
DB C1 E0 B8 20 FF E7 DB
• The ARPC Response Code (ARC):
30 31
EB F0 E0 B8 20 FF E7 DB
Output
ARPC = DES3(MKAC)[Input]
05 F7 C0 50 F0 21 F4 79
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-11
Purchase with Online Authorization
ARPC Validation (Example 2)
Key
The Key for the ARPC validation depends on the Session Key derivation
algorithm used and is derived as described above:
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
• For Session Key derivation for EMV 2000 Session Key Derivation, SKARPC =
SKAC
F2 43 E5 A2 57 0B 8C 61 C8 02 B9 CB E3 45 EF 1A
Input
The input is the XOR of:
• The ARQC:
08 95 B1 A3 BD 0D 6B 20
– For EMV 2000 Session Key Derivation
0B 8C CD BA F7 80 BA A8
00 12
08 87 B1 A3 BD 0D 6B 20
• For Session Key derivation for EMV 2000 Session Key Derivation
0B 9E CD BA F7 80 BA A8
©2008–2010 MasterCard
19-12 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
ARPC Validation (Example 3)
Output
ARPC = DES3(MKAC)[Input]
ED A5 9D 0D 2B 6D 2A DD
F5 C1 10 87 03 63 78 27 *chg*
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Key for ARPC validation is the MKAC
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
Input
The input is the XOR of:
• The ARQC:
08 95 B1 A3 BD 0D 6B 20
00 12
08 87 B1 A3 BD 0D 6B 20
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-13
Purchase with Online Authorization
ARPC Validation (Example 4)
Output
ARPC = DES3(MKAC)[Input]
ED A5 9D 0D 2B 6D 2A DD
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
Key
The Key for the ARPC validation depends on the Session Key derivation
algorithm used and is derived as described above:
08 DF 34 25 32 20 A7 20 EF F2 C1 34 38 52 E6 3D
• For Common Session Key derivation, SKARPC = SKAC
18 20 25 BA 4F AB 32 F5 A6 3A 1B A5 E6 84 5D 4E
Input
The input is the XOR of:
• The ARQC:
08 95 B1 A3 BD 0D 6B 20
– For Common Session Key derivation
F9 F9 12 12 C0 DF 65 BA
• The ARPC Response Code (ARC):
00 12
©2008–2010 MasterCard
19-14 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
TC Generation (Example 1)
08 87 B1 A3 BD 0D 6B 20
• For Common Session Key derivation
F9 EB 12 12 C0 DF 65 BA
Output
ARPC = DES3(MKAC)[Input]
ED A5 9D OD 2B 6D 2A DD
• For Common Session Key derivation
65 12 AA 0F FC 50 57 2C
TC Generation (Example 1)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.05, V.2.1 and V.2.2 Host
Backward Compatibility: If Application Control[5][4..2]='001' or if Application
Control[5][4..2]='010'.
Key
The Session Key SKAC as derived above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-15
Purchase with Online Authorization
TC Generation (Example 2)
Input
The input is the concatenation of the (current, refreshed) values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
03 A4 00 20
Concatenation:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 03 A4 00 20
Output
TC = MAC(SKAC)[Input]:
DB C1 E0 B8 20 FF E7 DB
TC Generation (Example 2)
©2008–2010 MasterCard
19-16 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
TC Generation (Example 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Key for the TC generation depends on the Session Key derivation algorithm
used, and is derived as described above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
• For EMV 2000 Session Key Derivation
F2 43 E5 A2 57 0B 8C 61 C8 02 B9 CB E3 45 EF 1A
Input
The input is the concatenation of the (current, refreshed) values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-17
Purchase with Online Authorization
TC Generation (Example 3)
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
A0 80 03 24 20 00
Concatenation3:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 A0 80 03 24 20 00
Output
TC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
• For EMV 2000 Session Key Derivation
0B 8C CD BA F7 80 BA A8
TC Generation (Example 3)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKAC as derived above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
3. In this example, the Offline Counters are not included in the generation of the TC (Application Control[2][1] =
‘0b’).
©2008–2010 MasterCard
19-18 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
TC Generation (Example 3)
Input
The input is the concatenation of the (current, refreshed) values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
A0 80 03 24 20 00
Concatenation4:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 A0 80 03 24 20 00
Output
TC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
4. In this example, the Offline Counters are not included in the generation of the TC (Application Control[2][1] =
‘0b’).
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-19
Purchase with Online Authorization
TC Generation (Example 4)
TC Generation (Example 4)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 DDA X Lite 4 X Select 4 X Lite 4 X Select 4
1.1b 1.1b 1.1b 1.1b
NOTE
*Variable applicable when the application supports V.1.1 and V.1.3 Host
Backward Compatibility: if Application Control [5][4..2]='011'.
Key
The Key for the TC generation depends on the Session Key derivation algorithm
used and is derived as described above:
F5 8F 02 9D 08 75 4D B6 A3 8B 24 7B F9 3C C2 87
• For Common Session Key derivation
18 20 25 BA 4F AB 32 F5 A6 3A 1B A5 E6 84 5D 4E
Input
The input is the concatenation of the (current, refreshed) values of:
• Amount (Authorized):
00 00 00 01 00 00
• Amount (Other):
00 00 00 00 10 00
• Terminal Country Code:
08 40
• Terminal Verification Results:
00 00 00 10 80
• Transaction Currency Code:
08 40
• Transaction Date:
98 07 04
• Transaction Type:
©2008–2010 MasterCard
19-20 March 2010 • M/Chip Card Application Cryptographic Algorithms
Purchase with Online Authorization
Dynamic CVC3 Generation
00
• Unpredictable Number:
11 11 11 11
• Application Interchange Profile (AIP):
58 00
• Application Transaction Counter:
34 56
• Card Verification Results:
A0 80 03 24 20 00
Concatenation5:
00 00 00 01 00 00 00 00 00 00 10 00 08 40 00 00
00 10 80 08 40 98 07 04 00 11 11 11 11 58 00 34
56 A0 80 03 24 20 00
Output
TC = MAC(SKAC)[Input]:
08 95 B1 A3 BD 0D 6B 20
• For Common Session Key derivation
F9 F9 12 12 C0 DF 65 BA
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 X Lite 4 1.0 X Select 4 1.0 X Payment
2.2 SDA Lite 4 1.1a Select 4 1.1a X Lite 4 X Select 4 X Data Storage
1.1a 1.1a
2.2 DDA Lite 4 1.1b Select 4 1.1b X Lite 4 X Select 4
1.1b 1.1b
5. In this example, the Offline Counters are not included in the generation of the TC (Application Control[2][1] =
‘0b’).
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 19-21
Purchase with Online Authorization
Dynamic CVC3 Generation
Key
The Key KDCVC3:
46 2F C4 16 E0 E9 3D 04 2C D0 B0 07 31 AB 46 37
Input
The IVCVC3TRACK2 is the following:
0D 14
0D 14
• UN:
00 00 08 99
• ATC:
00 5E
The concatenation:
0D 14 00 00 08 99 00 5E
Output
X = DES3(KDCVC3)[Input]:
FB BE E2 25 49 C8 90 89
90 89
©2008–2010 MasterCard
19-22 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 20 PIN Change
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-i
PIN Change
MasterCard Proprietary Session Key Derivation for PIN Change Script Decryption (Example 1)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
X 2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.05, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control [5][4..2]='001' or if Application
Control [5][4..2]='010'.
Key
The Card Master Key MKSMC for Secure Messaging Confidentiality:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
The RAND value depends on the sequence of script commands in a session
• For the first command in a session, the RAND is the last Application
Cryptogram, in this case the ARQC:
DB C1 E0 B8 20 FF E7 DB
• For all the following script commands in a session, the RAND is incremented
by 1 for each command. For the second script command in this session:
DB C1 E0 B8 20 FF E7 DC
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-1
PIN Change
MasterCard Proprietary Session Key Derivation for PIN Change Script Decryption (Example 2)
SKSMC = DES3(MKSMC)[X]||DES3(MKSMC)[Y]:
12 D0 18 C9 BF 81 21 0A 18 4E BA E7 0E 4D D7 A3
• For the second command in a session
CB E7 AB 6E C5 30 A0 37 2C 6E 2C 3C 0E F4 74 94
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment
1.0 1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 X Lite 4 X Select 4 X Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Card Master Key MKSMC for Secure Messaging Confidentiality:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
The RAND value depends on the sequence of script commands in a session
• For the first command in a session, the RAND is the last Application
Cryptogram, in this case the ARQC:
08 95 B1 A3 BD 0D 6B 20
• For all the following script commands in a session, the RAND is incremented
by 1 for each command. For the second script command in this session:
08 95 B1 A3 BD 0D 6B 21
©2008–2010 MasterCard
20-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
EMV2000 Session Key Derivation for PIN Change Script Decryption
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
SKSMC = DES3(MKSMC)[X]||DES3(MKSMC)[Y]:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
• For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Card Master Key MKSMC for Secure Messaging Confidentiality:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-3
PIN Change
EMV2000 Session Key Derivation for PIN Change Script Decryption
Input
For all the script commands of a session, the input is the concatenation of:
34 56
• The b-ary representation (a0, … , a7) of the ATC is:
(0, 3, 1, 0, 1, 1, 1, 2)
Output
Following the algorithm described in Chapter ICC Key Derivation, the
intermediate results P and GP are:
• Round 0 – GP is MKSMC, P:
94 5E A6 23 DD A4 C1 6F 0E 4F 65 0E 74 DD 04 39
• Round 1 – P:
AD 50 A7 49 E4 E0 B4 ED 75 84 1A 5D 92 D2 6B A3
• Round 2 – P:
62 11 4A E9 98 5E DD DD 80 64 97 6E 1D 8C A0 05
• Round 3 – P:
4F 7C 53 61 FC DF 4E 6E BE A8 DA A8 00 51 ED 60
• Round 4 – P:
5B 04 5D 99 65 47 E0 E9 EC 3E 1F 36 DD E2 3D 73
• Round 5 – P:
6A A3 C4 97 50 42 94 CF A2 D0 35 C4 DD 63 B9 71
• Round 6 – P:
AA D3 91 14 D0 B2 A0 FA EA 8A DC 2D 57 0B F6 3E
1E E6 67 BF FC 54 2D B7 3D BF 53 41 82 18 22 1E
This is bitwise XOR-combined with the GP from round 6 (equals P from round
5):
74 45 A3 28 AC 16 B9 78 9F 6F 66 85 5F 7B 9B 6F
75 45 A2 29 AD 16 B9 79 9E 6E 67 85 5E 7A 9B 6E
©2008–2010 MasterCard
20-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Common Session Key Derivation for PIN Change Script Decryption
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment *
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage *
NOTE
*Variant
applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Card Master Key MKSMC for Secure Messaging Confidentiality:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
For all the script commands of a session, the input is the Application Cryptogram
returned by the first GENERATE AC of the session, in this case the ARQC:
F9 F9 12 12 C0 DF 65 BA
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
SKSMC = DES3(MKSMC)[X]||DES3(MKSMC)[Y]:
B6 02 B3 17 49 BE 7F EF 61 4E 74 90 44 23 3D 40
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-5
PIN Change
PIN Change Script Decryption (Example 1)
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.0.5, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control [5][4..2]='001' or if Application
Control [5][4..2]='010'.
Key
The Session Key SKSMC for Secure Messaging Confidentiality as derived above:
12 D0 18 C9 BF 81 21 0A 18 4E BA E7 0E 4D D7 A3
• For the second command in a session
CB E7 AB 6E C5 30 A0 37 2C 6E 2C 3C 0E F4 74 94
Input
The encrypted PIN block:
B5 50 52 CC 98 DE BE E1
• For the second command in a session
AB 53 1A 15 89 EE E4 99
Output
The encrypted PIN block is one block only. The plaintext PIN block is the
Triple-DES decryption of that block:
©2008–2010 MasterCard
20-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
PIN Change Script Decryption (Example 2)
25 12 34 5F FF FF FF FF
The PIN is obtained after removing the padding according to ISO 9564-3:
12345
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKSMC for Secure Messaging Confidentiality as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
– For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
• For EMV2000 Session Key Derivation
75 45 A2 29 AD 16 B9 79 9E 6E 67 85 5E 7A 9B 6E
Input
The encrypted PIN block:
82 1E 64 ED 64 55 9A BA
– For the second command in a session
71 B9 B8 2F 3B B9 73 1A
• For EMV2000 Session Key Derivation
E6 AE 30 C8 2C F4 1F CC
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-7
PIN Change
PIN Change Script Decryption (Example 3)
Output
The encrypted PIN block is one block only. The plaintext PIN block is the
Triple-DES decryption of that block:
25 12 34 5F FF FF FF FF
The PIN is obtained after removing the padding according to ISO 9564-3:
12345
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment
1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKSMC for Secure Messaging Confidentiality as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
• For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
Input
The encrypted PIN block:
82 1E 64 ED 64 55 9A BA
• For the second command in a session
71 B9 B8 2F 3B B9 73 1A
Output
The encrypted PIN block is one block only. The plaintext PIN block is the
Triple-DES decryption of that block:
©2008–2010 MasterCard
20-8 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
PIN Change Script Decryption (Example 4)
25 12 34 5F FF FF FF FF
The PIN is obtained after removing the padding according to ISO 9564-3:
12345
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 X Lite 4 X Select 4 X Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Session Key SKSMC for Secure Messaging Confidentiality as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
– For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
• For Common Session Key Derivation
B6 02 B3 17 49 BE 7F EF 61 4E 74 90 44 23 3D 40
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-9
PIN Change
MasterCard Proprietary Session Key Derivation for Script MAC (Example 1)
Input
The encrypted PIN block:
82 1E 64 ED 64 55 9A BA
– For the second command in a session
71 B9 B8 2F 3B B9 73 1A
• For Common Session Key Derivation
66 B2 C2 79 54 4F 38 5F
Output
The encrypted PIN block is one block only. The plaintext PIN block is the
Triple-DES decryption of that block:
25 12 34 5F FF FF FF FF
The PIN is obtained after removing the padding according to ISO 9564-3:
12345
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.2.05, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control [5][4..2]='001' or if Application
Control [5][4..2]='010'.
©2008–2010 MasterCard
20-10 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
MasterCard Proprietary Session Key Derivation for Script MAC (Example 2)
Key
The Card Master Key MKSMI1 for Secure Messaging Integrity:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
The RAND value depends on the sequence of script commands in a session
• For the first command in a session, the RAND is the last Application
Cryptogram, in this case the ARQC:
DB C1 E0 B8 20 FF E7 DB
• For all the following script commands in a session, the RAND is incremented
by 1 for each command. For the second script command in a session:
DB C1 E0 B8 20 FF E7 DC
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
SKSMI = DES3(MKSMI)[X]||DES3(MKSMI)[Y]:
12 D0 18 C9 BF 81 21 0A 18 4E BA E7 0E 4D D7 A3
• For the second command in a session
CB E7 AB 6E C5 30 A0 37 2C 6E 2C 3C 0E F4 74 94
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-11
PIN Change
MasterCard Proprietary Session Key Derivation for Script MAC (Example 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment*
1.0 1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 X Lite 4 X Select 4 X Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant
applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Card Master Key MKSMI2 for Secure Messaging Integrity:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
The RAND value depends on the sequence of script commands in a session
• For the first command in a session, the RAND is the last Application
Cryptogram, in this case the ARQC:
08 95 B1 A3 BD 0D 6B 20
• For all the following script commands in a session, the RAND is incremented
by 1 for each command. For the second script command in a session:
08 95 B1 A3 BD 0D 6B 21
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
©2008–2010 MasterCard
20-12 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
EMV2000 Session Key Derivation for Script MAC
SKSMI = DES3(MKSMI)[X]||DES3(MKSMI)[Y]:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
• For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 1.0 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Card Master Key MKSMI3 for Secure Messaging Integrity:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
For all the script commands of a session, the input is the concatenation of:
34 56
• The b-ary representation (a0, … , a7) of the ATC is:
(0, 3, 1, 0, 1, 1, 1, 2)
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-13
PIN Change
Common Session Key Derivation for Script MAC
Output
Following the algorithm described in Chapter ICC Key Derivation, the
intermediate results P and GP are:
• Round 0 – GP is MKSMI, P:
94 5E A6 23 DD A4 C1 6F 0E 4F 65 0E 74 DD 04 39
• Round 1 – P:
AD 50 A7 49 E4 E0 B4 ED 75 84 1A 5D 92 D2 6B A3
• Round 2 – P:
62 11 4A E9 98 5E DD DD 80 64 97 6E 1D 8C A0 05
• Round 3 – P:
4F 7C 53 61 FC DF 4E 6E BE A8 DA A8 00 51 ED 60
• Round 4 – P:
5B 04 5D 99 65 47 E0 E9 EC 3E 1F 36 DD E2 3D 73
• Round 5 – P:
6A A3 C4 97 50 42 94 CF A2 D0 35 C4 DD 63 B9 71
• Round 6 – P:
AA D3 91 14 D0 B2 A0 FA EA 8A DC 2D 57 0B F6 3E
1E E6 67 BF FC 54 2D B7 3D BF 53 41 82 18 22 1E
This is bitwise XOR-combined with the GP from round 6 (equals P from round
5):
74 45 A3 28 AC 16 B9 78 9F 6F 66 85 5F 7B 9B 6F
75 45 A2 29 AD 16 B9 79 9E 6E 67 85 5E 7A 9B 6E
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment *
1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage *
©2008–2010 MasterCard
20-14 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 1)
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Card Master Key MKSMI for Secure Messaging Integrity:
DA 83 49 40 98 92 F2 31 61 52 BF 80 7F 46 B6 23
Input
For all the script commands of a session, the input is the Application Cryptogram
returned by the first GENERATE AC of the session, in this case the ARQC:
F9 F9 12 12 C0 DF 65 BA
Output
The concatenation of:
• The Triple-DES Encryption of X = “the input with the third byte replaced
by ‘F0’ ”
• The Triple-DES Encryption of Y = “the input with the third byte replaced
by ‘0F’ ”
SKSMI = DES3(MKSMI)[X]||DES3(MKSMI)[Y]:
B6 02 B3 17 49 BE 7F EF 61 4E 74 90 44 23 3D 40
NOTE
The result can be submitted to parity forcing, like the Card Master Keys. This
is not shown here as this is entirely internal to the ICC, and the computation is
not affected.
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
X Lite 2.1 Lite 4 1.0 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0
X 2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
X 2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-15
PIN Change
Script MAC Validation (Example 1)
NOTE
*Variant applicable when the application supports V.2.05, V.2.1 and V.2.2 Host
Backward Compatibility: if Application Control [5][4..2]='001' or if Application
Control [5][4..2]='010'.
Key
The Session Key SKSMI for Secure Messaging Integrity as derived above:
12 D0 18 C9 BF 81 21 0A 18 4E BA E7 0E 4D D7 A3
• For the second command in a session
CB E7 AB 6E C5 30 A0 37 2C 6E 2C 3C 0E F4 74 94
Input
The complete ICC command:
84 24 00 02 10 B5 50 52 CC 98 DE BE E1 E8 1A 60
D2 7A B0 5F AF
• For the second command in a session
84 24 00 02 10 AB 53 1A 15 89 EE E4 99 06 F7 66
E7 35 31 C4 2E
Output
For Secure Messaging Integrity (MAC validation), the ICC command consists of
the concatenation of:
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
B5 50 52 CC 98 DE BE E1
– For the second command in a session
AB 53 1A 15 89 EE E4 99
• The ScriptMAC:
E8 1A 60 D2 7A B0 5F AF
– For the second command in a session
06 F7 66 E7 35 31 C4 2E
©2008–2010 MasterCard
20-16 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 2)
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The last ATC:
34 57
• The RAND value depends on the sequence of script commands in a session
– For the first script command in a session, the RAND is the last
Application Cryptogram, in this case the ARQC
DB C1 E0 B8 20 FF E7 DB
– For all the following script commands in a session, the RAND is
incremented by 1 for each command. For the second script command
in this session:
DB C1 E0 B8 20 FF E7 DC
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
B5 50 52 CC 98 DE BE E1
– For the second command in a session
AB 53 1A 15 89 EE E4 99
The concatenation:
84 24 00 02 10 34 57 DB C1 E0 B8 20 FF E7 DB B5
50 52 CC 98 DE BE E1
• For the second command in a session
84 24 00 02 10 34 57 DB C1 E0 B8 20 FF E7 DC AB
53 1A 15 89 EE E4 99
ScriptMAC = MAC(SKSMI)[Input]:
E8 1A 60 D2 7A B0 5F AF
• For the second command in a session
06 F7 66 E7 35 31 C4 2E
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-17
PIN Change
Script MAC Validation (Example 2)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 X Lite 4 X Select 4 1.0 X Lite 4 1.0 X Select 4 Payment
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKSMI for Secure Messaging Integrity as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
– For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
• For EMV2000 Session Key Derivation
75 45 A2 29 AD 16 B9 79 9E 6E 67 85 5E 7A 9B 6E
Input
The complete ICC command:
84 24 00 02 10 82 1E 64 ED 64 55 9A BA DC 7F BE
36 5D C8 67 80
– For the second command in a session
84 24 00 02 10 71 B9 B8 2F 3B B9 73 1A 5F 59 4E
2A 99 44 AD 5A
• For EMV2000 Session Key Derivation
84 24 00 02 10 E6 AE 30 C8 2C F4 1F CC 47 86 F5
A1 58 00 61 16
– For the second command in a session
84 24 00 02 10 E6 AE 30 C8 2C F4 1F CC 35 DB 83
E1 08 CF 64 6F
©2008–2010 MasterCard
20-18 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 2)
Output
For Secure Messaging Integrity (MAC validation), the ICC command consists of
the concatenation of:
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
82 1E 64 ED 64 55 9A BA
– For the second command in a
session
71 B9 B8 2F 3B B9 73 1A
For EMV2000 Session Key Derivation E6 AE 30 C8 2C F4 1F CC
• The ScriptMAC:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
DC 7F BE 36 5D C8 67 80
– For the second command in a
session
5F 59 4E 2A 99 44 AD 5A
For EMV2000 Session Key Derivation – For the first command in a session
47 86 F5 A1 58 00 61 16
– For the second command in a
session
35 DB 83 E1 08 CF 64 6F
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The last ATC:
34 57
• The RAND value depends on the sequence of script commands in a session
– For the first script command in a session, the RAND is the last
Application Cryptogram, in this case the ARQC
08 95 B1 A3 BD 0D 6B 20
– For all the following script commands in a session, the RAND is
incremented by 1 for each command. For the second script command
in this session:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-19
PIN Change
Script MAC Validation (Example 2)
08 95 B1 A3 BD 0D 6B 21
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
82 1E 64 ED 64 55 9A BA
– For the second command in a
session
71 B9 B8 2F 3B B9 73 1A
For EMV2000 Session Key Derivation E6 AE 30 C8 2C F4 1F CC
The concatenation:
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 20 82
1E 64 ED 64 55 9A BA
– For the second command in a session
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 21 71
B9 B8 2F 3B B9 73 1A
• For EMV2000 Session Key Derivation
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 20 E6
AE 30 C8 2C F4 1F CC
– For the second command in a session
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 21 E6
AE 30 C8 2C F4 1F CC
ScriptMAC = MAC(SKSMI)[Input]:
DC 7F BE 36 5D C8 67 80
– For the second command in a session
5F 59 4E 2A 99 44 AD 5A
• For EMV2000 Session Key Derivation
47 86 F5 A1 58 00 61 16
– For the second command in a session
35 DB 83 E1 08 CF 64 6F
©2008–2010 MasterCard
20-20 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 3)
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 Payment
1.0 1.0
2.2 SDA X Lite 4 X Select 4 X Lite 4 X Select 4 Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 Lite 4 Select 4 Lite 4 Select 4
DDA 1.1b 1.1b 1.1b 1.1b
Key
The Session Key SKSMI for Secure Messaging Integrity as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
• For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
Input
The complete ICC command:
84 24 00 02 10 82 1E 64 ED 64 55 9A BA DC 7F BE
36 5D C8 67 80
• For the second command in a session
84 24 00 02 10 71 B9 B8 2F 3B B9 73 1A 5F 59 4E
2A 99 44 AD 5A
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-21
PIN Change
Script MAC Validation (Example 3)
Output
For Secure Messaging Integrity (MAC validation), the ICC command consists of
the concatenation of:
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
82 1E 64 ED 64 55 9A BA
– For the second command in a session
71 B9 B8 2F 3B B9 73 1A
• The ScriptMAC:
DC 7F BE 36 5D C8 67 80
– For the second command in a session
5F 59 4E 2A 99 44 AD 5A
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The last ATC:
34 57
• The RAND value depends on the sequence of script commands in a session
– For the first script command in a session, the RAND is the last
Application Cryptogram, in this case the ARQC
08 95 B1 A3 BD 0D 6B 20
– For all the following script commands in a session, the RAND is
incremented by 1 for each command. For the second script command
in this session:
08 95 B1 A3 BD 0D 6B 21
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
82 1E 64 ED 64 55 9A BA
– For the second command in a session
71 B9 B8 2F 3B B9 73 1A
©2008–2010 MasterCard
20-22 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 4)
The concatenation:
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 20 82
1E 64 ED 64 55 9A BA
• For the second command in a session
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 21 71
B9 B8 2F 3B B9 73 1A
ScriptMAC = MAC(SKSMI)[Input]:
DC 7F BE 36 5D C8 67 80
• For the second command in a session
5F 59 4E 2A 99 44 AD 5A
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 1.0 Lite 4 1.0 Select 4 X Payment*
1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 X Lite 4 X Select 4 X Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control [5][4..2]='011'.
Key
The Session Key SKSMI for Secure Messaging Integrity as derived above:
6E BB EF 87 8A 8D E9 2E CC DE B1 49 C5 22 15 35
– For the second command in a session
16 CD 6A EE CD 70 12 16 F8 E7 1E B6 DD E9 03 65
• For Common Session Key Derivation
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-23
PIN Change
Script MAC Validation (Example 4)
B6 02 B3 17 49 BE 7F EF 61 4E 74 90 44 23 3D 40
Input
The complete ICC command:
84 24 00 02 10 82 1E 64 ED 64 55 9A BA DC 7F BE
36 5D C8 67 80
– For the second command in a session
84 24 00 02 10 71 B9 B8 2F 3B B9 73 1A 5F 59 4E
2A 99 44 AD 5A
• For Common Session Key Derivation
84 24 00 02 10 66 B2 C2 79 54 4F 38 5F BA 3B 21
A7 86 F9 F0 05
– For the second command in a session
84 24 00 02 10 66 B2 C2 79 54 4F 38 5F 01 15 17
6D 2A D0 9F 5D
Output
For Secure Messaging Integrity (MAC validation), the ICC command consists of
the concatenation of:
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
82 1E 64 ED 64 55 9A BA
– For the second command in a
session
71 B9 B8 2F 3B B9 73 1A
For Common Session Key Derivation 66 B2 C2 79 54 4F 38 5F
• The ScriptMAC:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
DC 7F BE 36 5D C8 67 80
– For the second command in a
session
©2008–2010 MasterCard
20-24 March 2010 • M/Chip Card Application Cryptographic Algorithms
PIN Change
Script MAC Validation (Example 4)
5F 59 4E 2A 99 44 AD 5A
For Common Session Key Derivation – For the first command in a session
BA 3B 21 A7 86 F9 F0 05
– For the second command in a
session
01 15 17 6D 2A D0 9F 5D
• The command header (CLA INS P1 P2). For PIN Change, this is:
84 24 00 02 10
• The last ATC:
34 57
• The RAND value depends on the sequence of script commands in a session
– For the first script command in a session, the RAND is the last
Application Cryptogram, in this case the ARQC
08 95 B1 A3 BD 0D 6B 20
– For all the following script commands in a session, the RAND is
incremented by 1 for each command. For the second script command
in this session:
08 95 B1 A3 BD 0D 6B 21
• The script data. In this case, the encrypted PIN block (EncData) as received
in the command data:
For MasterCard proprietary Session Key – For the first command in a session
Derivation
82 1E 64 ED 64 55 9A BA
– For the second command in a
session
71 B9 B8 2F 3B B9 73 1A
For Common Session Key Derivation 66 B2 C2 79 54 4F 38 5F
The concatenation:
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 20 82
1E 64 ED 64 55 9A BA
– For the second command in a session
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 21 71
B9 B8 2F 3B B9 73 1A
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 20-25
PIN Change
Script MAC Validation (Example 4)
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 20 66
B2 C2 79 54 4F 38 5F
– For the second command in a session
84 24 00 02 10 34 57 08 95 B1 A3 BD 0D 6B 21 66
B2 C2 79 54 4F 38 5F
ScriptMAC = MAC(SKSMI)[Input]:
DC 7F BE 36 5D C8 67 80
– For the second command in a session
5F 59 4E 2A 99 44 AD 5A
• For Common Session Key Derivation
BA 3B 21 A7 86 F9 F0 05
– For the second command in a session
01 15 17 6D 2A D0 9F 5D
©2008–2010 MasterCard
20-26 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 21 Dynamic Data Authentication
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 21-i
Dynamic Data Authentication
Generation of the ICC Dynamic Number
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment*
1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant
applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
Key
The card Master Key MKIDN for ICC Dynamic Number Generation:
08 A1 04 5E 86 2F 1F EF 31 2A 8C AE D5 80 9D AE
Input
The concatenation of:
12 34
• Six zero bytes:
00 00 00 00 00 00
Concatenation:
12 34 00 00 00 00 00 00
Output
The Triple-DES encryption of the input:
IDN = DES3(MKIDN)[Input]
56 D3 96 58 A2 EE D9 B1
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 21-1
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite Lite 4 X Select 4 Lite 4 X Select 4 X Payment*
2.1 1.0 1.0 1.0 1.0
2.2 Lite 4 X Select 4 Lite 4 X Select 4 X Data
SDA 1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
Modulus:
A2 BC C5 CE BA C3 19 6B 7E 93 3B 1A 46 66 A6 7D
ED 64 2B A3 CE 89 5C 31 8A 3D FC 12 65 B3 B9 CF
FC 12 FD E5 16 8E 84 19 06 50 E1 74 17 EC 8B 04
A4 E9 85 E0 D4 E1 AF 4B 76 08 4F 44 A1 F2 7F E8
65 E5 FA B2 07 AA 71 52 37 A6 D1 F7 BA CF 1E 2D
DF FB 5A F2 40 00 93 58 4A FA F0 7D FC 73 F8 6C
94 E6 2C 2C FF 44 3D 90 87 EF C1 90 A8 68 24 5C
06 40 0E 06 A3 D2 0B 1C D5 D0 AB 86 CF 88 1B 81
39 DD 50 BD 06 35 12 41 12 A4 93 37 1C 88 9C 53
51 3C D5 CE 3F E3 7B B7 A2 0A AA 97 90 29 08 10
73 F2 31 1A 0C 0E 1D A9 AC 8E B3 45 AB 81 0D 8B
Private Exponent d:
0A D9 62 85 3F A6 9B 4B 6E D6 9D 8A 48 F5 C6 D5
31 F5 9C 82 63 1A 39 58 A2 D0 EE AB E4 A5 94 EB
BB 78 BB 97 CE 4D C4 8A 33 9E FD F6 AC 42 F8 33
82 75 F7 DB C9 EC E9 8D 90 66 F4 37 C6 87 A2 20
8F 53 99 3F 11 93 E5 6B E1 93 A7 99 0C 74 35 36
42 21 D2 DC F3 33 3D 05 C7 A4 65 30 4C 34 96 96
14 DD 4D C9 7B 2D 8B 70 63 7D A2 C3 DA CD 6F EE
FB 05 13 3B 7F E2 C3 54 FA 75 CF 1C 02 69 A4 73
E2 EB BC CE 4E 9F 4B 1A BF FC 57 75 E6 28 E4 C5
21 94 9C 1D 15 DC AB 95 FF C0 11 64 76 18 C4 6C
06 34 98 31 FD 11 60 8F A5 D8 DD DB 8F 56 0D B3
The same ICC Private Key, given in the commonly used “Chinese Remainder
Theorem” format:
©2008–2010 MasterCard
21-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
The prime p:
C7 0E 73 F0 30 3C C8 83 21 C3 60 AA 7E 57 13 A7
81 B8 80 72 16 16 AA D4 09 A5 5E 7C D8 77 75 F9
52 2C F6 03 51 8B 29 C8 D1 72 6C 2D 1E 00 20 54
98 AA 6C 77 A5 F6 84 70 5D 72 79 BB B4 A5 08 21
8C ED 4F 3D A5 CF 6F 78 AA EE 1D 0E 79 79 00 73
67 CC 99 02 23 A2 C8 25
The exponent used modulo p (this is the private exponent d reduced modulo
p–1):
84 B4 4D 4A CA D3 30 57 6B D7 95 C6 FE E4 B7 C5
01 25 AA F6 B9 64 71 E2 B1 18 E9 A8 90 4F A3 FB
8C 1D F9 57 8B B2 1B DB 36 4C 48 1E 14 00 15 8D
BB 1C 48 4F C3 F9 AD A0 3E 4C 51 27 CD C3 5A C1
08 9E 34 D3 C3 DF 9F A5 C7 49 68 B4 50 FB 55 A2
45 33 10 AC 17 C1 DA C3
The prime q:
D1 4A 8E B9 55 22 5D 1E 3A 2B 3C B4 49 41 FE 53
31 DA B7 A4 C0 47 EA 87 47 4E 8F 0D 4D 11 23 28
D6 BC 92 DF 59 CC 4E EE 1C 9A D4 79 4C DF 8B 5B
3A 31 06 D6 FA 2C B0 55 FC 15 36 5E 43 50 65 CC
18 DC 56 76 FE E6 16 43 6B EF 29 1D BE 90 74 CB
8D 0D 1A 66 21 D3 77 EF
The exponent used modulo q (this is the private exponent d reduced modulo
q–1):
8B 87 09 D0 E3 6C 3E 14 26 C7 7D CD 86 2B FE E2
21 3C 7A 6D D5 85 47 04 DA 34 5F 5E 33 60 C2 1B
39 D3 0C 94 E6 88 34 9E BD BC 8D A6 33 3F B2 3C
D1 76 04 8F 51 73 20 39 52 B8 CE E9 82 35 99 32
BB 3D 8E F9 FF 44 0E D7 9D 4A 1B 69 29 B5 A3 32
5E 08 BC 44 16 8C FA 9F
44 8B EF 26 9A AB 94 68 F9 C2 F5 C2 36 70 11 3E
C0 B7 1A 4D F3 F6 98 BF A4 81 BF 3E C2 C3 6F 1B
41 02 FD 42 B0 EB FD AF FC 29 E4 24 62 35 8B B8
3B A2 E9 73 C2 49 50 37 A7 C3 02 12 05 79 7E 49
9C 15 DF E4 11 91 53 5E D1 7E 23 DF 41 4C 71 C6
60 A5 07 B4 E2 1D 8D E3
89 38 5E C5 94 CE 7E 58 57 DE C3 A8 98 1D B8 B8
C4 FE 69 3F B4 5A 38 49 47 1B 01 EA 20 B1 DB CB
CD 70 D5 34 51 A4 C4 43 FC E1 AA 71 49 42 91 DA
D2 B8 09 59 A9 B9 63 AC B8 64 BF DF 69 31 15 5B
3C 81 F0 C9 72 2E E1 F6 D0 FB 43 FD F8 44 CC 08
85 34 03 1B 03 32 B5 73
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 21-3
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
NOTE
Typically, only one of the inverses given here is used.
Modulus:
A2 BC C5 CE BA C3 19 6B 7E 93 3B 1A 46 66 A6 7D
ED 64 2B A3 CE 89 5C 31 8A 3D FC 12 65 B3 B9 CF
FC 12 FD E5 16 8E 84 19 06 50 E1 74 17 EC 8B 04
A4 E9 85 E0 D4 E1 AF 4B 76 08 4F 44 A1 F2 7F E8
65 E5 FA B2 07 AA 71 52 37 A6 D1 F7 BA CF 1E 2D
DF FB 5A F2 40 00 93 58 4A FA F0 7D FC 73 F8 6C
94 E6 2C 2C FF 44 3D 90 87 EF C1 90 A8 68 24 5C
06 40 0E 06 A3 D2 0B 1C D5 D0 AB 86 CF 88 1B 81
39 DD 50 BD 06 35 12 41 12 A4 93 37 1C 88 9C 53
51 3C D5 CE 3F E3 7B B7 A2 0A AA 97 90 29 08 10
73 F2 31 1A 0C 0E 1D A9 AC 8E B3 45 AB 81 0D 8B
Exponent:
03
NOTE
The ICC Public Key is used only for DDA verification.
©2008–2010 MasterCard
21-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
Input
The Dynamic Application Data to be signed. It is the concatenation of:
05
• Hash Algorithm Indicator (SHA-1):
01
• ICC Dynamic Data Length:
09
• ICC Dynamic Data (the randomly generated ICC Dynamic Number IDN,
preceded by its length on one byte ‘08’):
08 56 D3 96 58 A2 EE D9 B1
• Pad Pattern (176–34 = 142 bytes, as the ICC Public Key Modulus is 176
bytes long):
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB
• Terminal Dynamic Data, which is the concatenation of the values of the
data elements indicated in the DDOL:
Unpredictable Number:
A0 B1 C2 D3
Therefore, the Dynamic Application Data to be Signed (i.e. input to the SHA-1
hash algorithm) equals:
05 01 09 08 56 D3 96 58 A2 EE D9 B1 BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB A0 B1 C2 D3
8E 8A 2B F6 0D E6 B9 A3 19 38 FA 8E F4 A4 11 B4
AB 1A 53 18
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 21-5
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
Signature Generation
First, concatenate:
6A
• The leftmost 80–22 = 58 bytes of the message (the Dynamic Application
Data):
05 01 09 08 56 D3 96 58 A2 EE D9 B1 BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB
(we need 176–22 bytes, as the ICC Public Key Modulus is 176 bytes long).
• The result of application of the Hash Algorithm (SHA-1) to the complete
message:
8E 8A 2B F6 0D E6 B9 A3 19 38 FA 8E F4 A4 11 B4
AB 1A 53 18
• And the trailer byte:
BC
6A 05 01 09 08 56 D3 96 58 A2 EE D9 B1 BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB 8E 8A 2B F6 0D
E6 B9 A3 19 38 FA 8E F4 A4 11 B4 AB 1A 53 18 BC
Apply the RSA private transformation to this, i.e. raise it to the power ‘d’
modulo the ICC Public Key Modulus. This can be done using the standard
representation or CRT representation. This is outside the scope of this
document. The Signed Dynamic Application Data equals:
©2008–2010 MasterCard
21-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Dynamic Data Authentication
Generation of the Signed Dynamic Application Data
0E 3E 5F 59 62 F0 04 74 85 CE 92 B9 6F 52 C9 8B
39 A1 DC F7 28 AE E8 BA D4 6C E5 2E 91 03 FB A7
2D 63 01 50 5F 2D 66 0F E8 78 5B 68 72 02 92 B6
8C 92 0B 50 8C 8D A9 DA 0B E3 52 01 CD BB C9 FA
DF 65 7D E8 98 89 70 2C 87 44 8D 27 2F 66 2B D6
33 75 E1 5D 4A F1 89 99 0B 81 FB E3 8B 40 44 92
99 BB 1C 2E DD 8C E5 C3 EA 18 BC 03 E6 C8 66 41
71 96 1C 0E 75 47 CB 3B 55 3C 66 81 2A 54 4B AA
43 92 C6 AE 23 16 F2 69 1C 7F 6D D3 B6 8E BC A4
FC 77 AB F8 E7 2B CF 85 69 45 7B 83 4C 52 3D A3
EC 56 2E 7B DD 57 8E 21 88 7F D1 72 DB 7D 12 9B
This concludes the ICC computations for Dynamic Data Authentication. The
following sections deal with the terminal verification of the SDAD.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 21-7
Chapter 22 Combined DDA / AC Generation
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 22-i
Combined DDA / AC Generation
GENERATE AC Command
GENERATE AC Command
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment*
1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
SDAD Computation
This topic applies to the following M/Chip Card Applications:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 22-1
Combined DDA / AC Generation
SDAD Computation
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment*
1.0 1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
00 00 00 00 02 99 00 00 00 00 00 00 00 56 00 00
00 00 00 09 78 01 06 07 00 11 22 33 44
– Application Interchange Profile
79 00
– Application Transaction Counter
00 02
– Card Verification Results
90 40 03 23 00 00
The concatenation:
00 00 00 00 02 99 00 00 00 00 00 00 00 56 00 00
00 00 00 09 78 01 06 07 00 11 22 33 44|79 00|00
02|90 40 03 23 00 00
using key SKAC
EF 4F C8 E6 19 2F 91 6B 08 8F 85 C1 85 02 54 49
to obtain the TC = MAC(SKAC)[input]
04 FC BE 25 FE EA BD 0C
NOTE
A session key is derived and an ‘80’ padding byte is appended to the input
data as part of this process.
©2008–2010 MasterCard
22-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Combined DDA / AC Generation
SDAD Computation
00 00 00 00 04 98 00 FF
and using the session key SK constructed by XOR’ing the SKAC with:
59 00 00 00 00 00 00 00 95 00 00 00 00 00 00 00
returning the SK value:
B6 4F C8 E6 19 2F 91 6B 9D 8F 85 C1 85 02 54 49
The encrypted counters are then computed as DES3(SK)[Input] =
84 E3 AC 20 74 2D C3 66
• Construct the IAD from:
• The Transaction Data Hash Code is computed by applying the SHA-1 hash
algorithm to input data consisting of all the values identified in CDOL1 and
the TLV data, contained in the response to the GENERATE AC command,
with the exception of the SDAD (see details in Generate AC Response):
00 00 00 00 02 99 00 00 00 00 00 00 00 56 00 00
00 00 00 09 78 01 06 07 00 11 22 33 44 22 00 00
00 00 00 00 00 00 00 00 01 00 02|9F 27 01 40|9F
36 02 00 02|9F 10 12 01 12 90 40 03 23 00 00 00
00 84 E3 AC 20 74 2D C3 66
The Transaction Data Hash Code is equal to SHA-1[input] =
D1 37 03 30 56 A4 08 8C F4 FF C8 0D C0 44 5A 60
D3 FA 0A D9
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 22-3
Combined DDA / AC Generation
SDAD Computation
Computation of IDN
The ICC must compute the ICC Dynamic Number (IDN) for inclusion in the
recoverable part of the CDA signature. The IDN is the 8-byte quantity derived
by the card using Triple-DES (ECB) encryption as defined in Cryptographic
Algorithms. See the worked example for DDA for an example of IDN
computation (ICC Dynamic Number Generation Process). In this case the IDN
happens to be equal to:
E7 3A C4 64 CA 63 9D 58
NOTE
When the first GENERATE AC command is sent by the terminal during CDA
generation, the IDN has not yet been obtained from the ICC. The IDN data field
therefore displays the default value ’00 00 00 00 00 00 00 00’ when CDOL1
identifies IDN. This default value is then included in the Transaction Data Hash
Code.
©2008–2010 MasterCard
22-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Combined DDA / AC Generation
SDAD Computation
05
• Hash Algorithm Indicator (SHA-1):
01
• ICC Dynamic Data Length:
26
• ICC Dynamic Data:
08 E7 3A C4 64 CA 63 9D 58
– CID:
40
– TC:
04 FC BE 25 FE EA BD 0C
– Transaction Data Hash Code:
D1 37 03 30 56 A4 08 8C F4 FF C8 0D C0 44 5A 60
D3 FA 0A D9
• Pad Pattern (176–63 = 113 bytes, as the example ICC Public Key Modulus is
176 bytes long):
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB
• Terminal Dynamic Data, which is the concatenation of the values of the
data elements indicated in the DDOL:
Unpredictable Number:
11 22 33 44
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 22-5
Combined DDA / AC Generation
SDAD Computation
Thus the Dynamic Data to be signed (i.e. input to hash algorithm) is equal to:
05|01|26|08 E7 3A C4 64 CA 63 9D 58|40|04 FC BE
25 FE EA BD 0C|D1 37 03 30 56 A4 08 8C F4 FF C8
0D C0 44 5A 60 D3 FA 0A D9|BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB|11 22 33 44
B4 4C 05 03 DB 57 8E D6 0A FA 0E 78 26 15 14 6E
F5 59 E7 C5
Signature Generation
All but the Terminal Dynamic Data is recoverable from the signature thus the
input to the Sign() function is constructed as follows.
First, concatenate:
6A
• The leftmost 176–22 = 154 bytes of the message (the Dynamic Application
Data):
05 01 26 08 E7 3A C4 64 CA 63 9D 58 40 04 FC BE
25 FE EA BD 0C D1 37 03 30 56 A4 08 8C F4 FF C8
0D C0 44 5A 60 D3 FA 0A D9 BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB
(we need 176–22 bytes, as the ICC Public Key Modulus is 176 bytes long).
• The result of application of the Hash Algorithm (SHA-1) to the complete
message:
B4 4C 05 03 DB 57 8E D6 0A FA 0E 78 26 15 14 6E
F5 59 E7 C5
• and the trailer byte
BC
©2008–2010 MasterCard
22-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Combined DDA / AC Generation
GENERATE AC Response
6A 05 01 26 08 E7 3A C4 64 CA 63 9D 58 40 04 FC
BE 25 FE EA BD 0C D1 37 03 30 56 A4 08 8C F4 FF
C8 0D C0 44 5A 60 D3 FA 0A D9 BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB BB
BB BB BB BB BB BB BB BB BB BB BB B4 4C 05 03 DB
57 8E D6 0A FA 0E 78 26 15 14 6E F5 59 E7 C5 BC
Apply the RSA private transformation Sign() to this result, i.e. raise it to the
power ‘d’ modulo the ICC Public Key Modulus. This can be done using the
standard representation or CRT representation. This is outside the scope of this
manual. Using the ICC Private Key and ICC Public Key Modulus defined in the
previous section, the Signed Dynamic Application Data equals:
79 ED 26 F1 30 58 3C C2 86 63 FD 68 AD 8D F8 D9
CE 36 78 C5 FB AF BE C4 F7 BF A6 63 58 84 B2 E3
6B 72 38 B3 51 D4 95 D2 ED BD D2 F3 EB 00 29 3B
A1 56 86 B2 07 F5 BE 84 56 3F 48 79 2B 25 7B 4C
F9 94 48 92 8A C8 03 16 F7 5D 7A 78 21 46 28 2B
BF B7 20 2C 36 6D 2D ED 1E 48 6A B5 AF E7 D7 E8
43 E4 0E A8 5C 51 5D DB 61 16 34 41 17 10 20 5F
EC 02 E0 11 3F A4 13 98 DC 4E 09 EC 82 BD 38 A0
4A 7E 99 23 9C B1 76 94 6E A8 C6 9C C7 C2 1E 75
B6 E3 CC AA 2F 76 E2 E3 57 CE AF E0 3C CB 2F B0
04 CF EC 97 34 67 4D 6D 3A 22 F5 1F B4 9B 6E 4D
GENERATE AC Response
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 Select 4 1.0 X Lite 4 1.0 X Select 4 X Payment*
1.0
2.2 SDA Lite 4 Select 4 X Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 Select 4 X Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant
applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 22-7
Combined DDA / AC Generation
GENERATE AC Response
where the:
40
• ATC is:
00 02
• SDAD is:
79 ED 26 F1 30 58 3C C2 86 63 FD 68 AD 8D F8 D9
CE 36 78 C5 FB AF BE C4 F7 BF A6 63 58 84 B2 E3
6B 72 38 B3 51 D4 95 D2 ED BD D2 F3 EB 00 29 3B
A1 56 86 B2 07 F5 BE 84 56 3F 48 79 2B 25 7B 4C
F9 94 48 92 8A C8 03 16 F7 5D 7A 78 21 46 28 2B
BF B7 20 2C 36 6D 2D ED 1E 48 6A B5 AF E7 D7 E8
43 E4 0E A8 5C 51 5D DB 61 16 34 41 17 10 20 5F
EC 02 E0 11 3F A4 13 98 DC 4E 09 EC 82 BD 38 A0
4A 7E 99 23 9C B1 76 94 6E A8 C6 9C C7 C2 1E 75
B6 E3 CC AA 2F 76 E2 E3 57 CE AF E0 3C CB 2F B0
04 CF EC 97 34 67 4D 6D 3A 22 F5 1F B4 9B 6E 4D
©2008–2010 MasterCard
22-8 March 2010 • M/Chip Card Application Cryptographic Algorithms
Chapter 23 Offline Enciphered PIN Decription
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 23-i
Offline Enciphered PIN Decription
Offline Enciphered PIN Decryption Details
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 1.0 X Select 4 1.0 Lite 4 1.0 X Select 4 X Payment*
1.0
2.2 SDA Lite 4 X Select 4 Lite 4 X Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage*
2.2 Lite 4 X Select 4 Lite 4 X Select 4
DDA 1.1b 1.1b 1.1b 1.1b
NOTE
*Variant applicable when the application supports V.1.1 and V.1.3 Host Backward
Compatibility: if Application Control[5][4..2]='011'.
1. It is the same key as the ICC Public Key used for Dynamic Data
Authentication. In this case, the same ICC Public Key Certificate is used
as well.
2. It is a specific key, uniquely used for PIN Encipherment. The ICC PIN
Encipherment Public Key Certificate has a slightly different format than the
ICC Public Key Certificate. The Static Data to be authenticated is omitted.
Modulus:
A2 BC C5 CE BA C3 19 6B 7E 93 3B 1A 46 66 A6 7D
ED 64 2B A3 CE 89 5C 31 8A 3D FC 12 65 B3 B9 CF
FC 12 FD E5 16 8E 84 19 06 50 E1 74 17 EC 8B 04
A4 E9 85 E0 D4 E1 AF 4B 76 08 4F 44 A1 F2 7F E8
65 E5 FA B2 07 AA 71 52 37 A6 D1 F7 BA CF 1E 2D
DF FB 5A F2 40 00 93 58 4A FA F0 7D FC 73 F8 6C
94 E6 2C 2C FF 44 3D 90 87 EF C1 90 A8 68 24 5C
06 40 0E 06 A3 D2 0B 1C D5 D0 AB 86 CF 88 1B 81
39 DD 50 BD 06 35 12 41 12 A4 93 37 1C 88 9C 53
51 3C D5 CE 3F E3 7B B7 A2 0A AA 97 90 29 08 10
73 F2 31 1A 0C 0E 1D A9 AC 8E B3 45 AB 81 0D 8B
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 23-1
Offline Enciphered PIN Decription
Offline Enciphered PIN Decryption Details
Private Exponent d:
0A D9 62 85 3F A6 9B 4B 6E D6 9D 8A 48 F5 C6 D5
31 F5 9C 82 63 1A 39 58 A2 D0 EE AB E4 A5 94 EB
BB 78 BB 97 CE 4D C4 8A 33 9E FD F6 AC 42 F8 33
82 75 F7 DB C9 EC E9 8D 90 66 F4 37 C6 87 A2 20
8F 53 99 3F 11 93 E5 6B E1 93 A7 99 0C 74 35 36
42 21 D2 DC F3 33 3D 05 C7 A4 65 30 4C 34 96 96
14 DD 4D C9 7B 2D 8B 70 63 7D A2 C3 DA CD 6F EE
FB 05 13 3B 7F E2 C3 54 FA 75 CF 1C 02 69 A4 73
E2 EB BC CE 4E 9F 4B 1A BF FC 57 75 E6 28 E4 C5
21 94 9C 1D 15 DC AB 95 FF C0 11 64 76 18 C4 6C
06 34 98 31 FD 11 60 8F A5 D8 DD DB 8F 56 0D B3
PIN Decryption
The Encipher PIN Data:
39 97 F6 15 E6 05 20 41 D4 C7 00 96 3B 78 A4 B3
B2 68 53 29 7F A9 D4 93 81 38 86 A9 42 76 12 2C
13 41 DB 19 95 76 32 C7 AA 0A B2 8B D5 BF 89 F7
C9 80 65 BD 7C E0 30 7A 64 1F 7D D5 13 FC 52 ED
1D FB 9D 82 0A B4 F4 F2 43 B9 D5 AF 26 24 61 16
1D 8A 1B 79 CA B8 AC 99 1A F9 09 D8 28 DA 6A CC
A2 40 C3 2A 38 B0 E6 35 83 35 1F 5C A5 0F 39 27
BE 6A ED 9E A0 D5 3F 2C 4A F2 D9 A6 38 B8 DD 28
AF A8 02 7F BD 36 63 26 56 87 81 6A DD 82 C7 81
EF 81 CF B1 2B 30 35 7D FD 31 E5 A0 6C A3 7C FA
29 E2 75 74 AB E2 DC ED 46 9B 87 F0 53 3F 8B B8
7F|25 12 34 5F FF FF FF FF|1A 2B 3C 4D 5E 6F 70
81|FC 02 7D 70 F1 28 4A 48 41 08 48 28 80 20 B8
25 F5 3D F1 54 B7 32 9C B0 24 3A 6E 5A D2 16 F2
E1 02 B5 1D 41 2F 2D 44 43 6C 18 04 7B BC AD CF
C1 96 D9 A8 BC AC 80 9F 1E BF 5C 3F 1A 1D DC E4
6D 37 07 F8 4D F6 76 BE A4 0A FD CE 50 E9 9A 6B
03 F7 7B 32 28 48 3B 25 1A A0 61 54 A6 2A A1 77
03 6B 27 80 AC 95 BC 05 B2 D8 7B A9 81 07 76 93
A9 30 9B D0 06 47 44 8A 77 94 F2 E5 96 39 D6 6C
06 0E B2 3C F8 96 41 F9 40 43 24 87 CD EA 18 B7
10 34 75 75 C4 28 00 8B 52 BF 9F 61 FF C9 F2 49
(Separators ‘|’ are inserted to ease parsing).
7F
1A 2B 3C 4D 5E 6F 70 81
©2008–2010 MasterCard
23-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Offline Enciphered PIN Decription
Offline Enciphered PIN Decryption Details
and is equal to the value provided in answer to the previous GET CHALLENGE.
The PIN is retrieved from the PIN block, which is the second field:
25 12 34 5F FF FF FF FF
12345
This PIN is then compared by the ICC to the Reference PIN value stored in
the ICC.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 23-3
Chapter 24 Data Storage
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 24-i
Data Storage
Data Storage Details
OWHF1 Function
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 1.0 Select 4 Payment
1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
Key
The DSPK key is as follows:
16 18 20 28 2A 2C 2C 2E
30 42 44 46
Input
For the OWHF1 function, the input consists of:
• DS Summary 1:
12 23 34 45 56 67 78 89
• Amount, Authorized (numeric):
00 00 00 00 12 34
• Transaction Currency Code:
08 40
• Reference Control Parameter:
80
• First/Second Generate AC Indicator:
01
• DS Unpredictable Number:
11 22 33 44
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 24-1
Data Storage
Data Storage Details
• Unpredictable Number:
55 66 77 88
Output
For the OWHF1 function, the output is computed as follows:
98 40
• Construct X1 as DS Summary 1 Å (Amount, Authorised (Numeric) || DS
Unpredictable Number [3..4])
12 23 34 45 44 53 4B CD
• Construct X2 as A || Unpredictable Number || DS Unpredictable Number
[1..2]
98 40 11 22 33 44 11 22
• Generate the three temporary DES keys K1, K2 and K3
K1 is Concatenation of the 6 first bytes of DSPK and the first 2 bytes of
DS Unpredictable Number:
16 18 20 28 2A 2C 11 22
K2 is Concatenation of the 6 last bytes of DSPK and the last 2 bytes of DS
Unpredictable Number:
2C 2E 30 42 44 46 33 44
K3 = DES(KL1)[X1] Å X1
90 3C 16 E0 2B 71 5F 95
• The result R = X1 Å X2 Å DES(KL3)[DES-1(K2)[DES(K3)[X2]]
EF AE 11 92 03 64 ED 60
OWHF2 Function
This topic applies to the following M/Chip Card Applications:
M/Chip
M/Chip 2 M/Chip 4 PayPass M/Chip 4 Advance
Lite 2.1 Lite 4 Select 4 Lite 4 Select 4 Payment
1.0 1.0 1.0 1.0
2.2 SDA Lite 4 Select 4 Lite 4 Select 4 X Data
1.1a 1.1a 1.1a 1.1a Storage
2.2 DDA Lite 4 Select 4 Lite 4 Select 4
1.1b 1.1b 1.1b 1.1b
©2008–2010 MasterCard
24-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Data Storage
Data Storage Details
Key
The DSPK key is as follows:
16 18 20 28 2A 2C 2C 2E
30 42 44 46
Input
For the OWHF2 function, the input consists of:
• DS Input T:
12 23 34 45 56 67 78 89
• DS Requested Operator ID:
81 99 82 99 83 99 84 99
Output
For the OWHF2 function, the output is computed as follows:
16 18 20 28 2A 2C 83 99
K2 is Concatenation of the 6 last bytes of DSPK and bytes 7 and 8 of DS
Requested Operator ID:
2C 2E 30 42 44 46 84 99
• Generate X = DS Input T Å DS Requested Operator ID:
93 BA B6 DC D5 FE FC 10
• The result R = DS Input T Å DES(K1)[DES-1(K2)[DES(K1)[X]]
84 7D F9 B8 7A 9D CB DE
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 24-3
Appendix A Reference Information
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-i
Reference Information
Using this Document
Contents
This manual describes how to implement cryptography in order to support
M/Chip specifications for EMV transactions and for post-issuance card
administration. It describes the security features to support the applications
defined in the following manuals:
• M/Chip 4 Version 1.1 Card Application Specifications for Debit and Credit
• M/Chip 4 Version 1.0 Card Application Specifications for Debit and Credit
• M/Chip Lite 2.1, July 2003
• M/Chip 2.2 Card Application Specification
• MasterCard PayPass Magnetic Stripe Technical Specification Version 3.3
December 2007
• MasterCard PayPass M/Chip 4 Technical Specification Version 1.3.1
September 2008
• M/Chip Advance Card Application Specification-Payment, Version 1.0,
November 2009
• M/Chip Advance Card Application Specification-Payment & Data Storage,
Version 1.0, November 2009
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-1
Reference Information
Using this Document
Scope
It is not the purpose of this manual to cover all cryptographic security
requirements for the general management of sensitive application data, keys
and PINs. Security guidelines for M/Chip implementations are provided
in the manual MasterCard Security Guidelines for M/Chip4 Developers.
Recommendations for security parameters settings are given in the manual
MasterCard M/Chip 4 Version 1.1 Issuer Security Guidelines.
Audience
This manual is intended for developers of M/Chip applications.
Times Expressed
MasterCard is a global company with locations in many time zones. The
MasterCard operations and business centers are in the United States. The
operations center is in St. Louis, Missouri, and the business center is in
Purchase, New York.
Excerpted Text
At times, this document may include text excerpted from another document. A
note before the repeated text always identifies the source document. In such
cases, we include the repeated text solely for the reader’s convenience. The
original text in the source document always takes legal precedence.
1. For Central European Time, last Sunday in October to last Sunday in March.
2. For Central European Time, last Sunday in March to last Sunday in October.
©2008–2010 MasterCard
A-2 March 2010 • M/Chip Card Application Cryptographic Algorithms
Reference Information
Using this Document
Language Use
The spelling of English words in this document follows the convention used for
U.S. English as defined in Merriam-Webster’s Collegiate Dictionary. MasterCard
is incorporated in the United States and publishes in the United States.
Therefore, this publication uses U.S. English spelling and grammar rules.
An exception to the above spelling rule concerns the spelling of proper nouns.
In this case, we use the local English spelling.
Revisions
MasterCard periodically may issue revisions to this document to accommodate
enhancements and changes, or as corrections are required. With each revision,
a Summary of Changes describes how the text changed.
Related Information
The following documents and resources provide information related to the
subjects discussed in this manual. For descriptions of these documents, please
refer to the List of Manuals in the Member Publications product on MasterCard
OnLine®:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-3
Reference Information
Sources
Other documents provide useful information but are subject to the signature of
a license agreement to obtain them:
Members that use the Cirrus® service and logo or that process online debit
transactions should refer to the debit processing manuals recommended by the
Customer Operations Services team.
For definitions of key terms used in this document, please refer to the
MasterCard Dictionary on the Member Publications home page (on MasterCard
OnLine® and the MasterCard Electronic Library CD-ROM).
Sources
In addition, when preparing this manual the following publications and
standard documents were consulted.
EMV
• EMV, Integrated Circuit Card Specification for Payment Systems, Book 2 –
Security and Key Management. Version 4.2, June 2008
• EMV, Integrated Circuit Card Specification for Payment Systems, Book 3 –
Application Specification. Version 4.2, June 2008
• EMV, Integrated Circuit Card Specification for Payment Systems, Book 4 –
Cardholder, Attendant and Acquirer Interface Requirements. Version 4.2,
June 2008
• EMV2000, Integrated Circuit Card Specification for Payment Systems, Book
2 – Security and Key Management. Version 4.0, December 31, 2000
• EMV2000, Integrated Circuit Card Specification for Payment Systems, Book
3 – Application Specification. Version 4.0, December 31, 2000
• EMV2000, Integrated Circuit Card Specification for Payment Systems, Book
4 – Cardholder, Attendant and Acquirer Interface Requirements. Version
4.0, December 31, 2000
• EMV ’96, Integrated Circuit Card Specification for Payment Systems - Part 2:
Data Elements and Commands, Version 3.1.1, May 31, 1998
• EMV ’96, Integrated Circuit Card Specification for Payment Systems – Part 3:
Application Selection, Version 3.1.1, May 31, 1998
©2008–2010 MasterCard
A-4 March 2010 • M/Chip Card Application Cryptographic Algorithms
Reference Information
Abbreviations
• EMV ’96, Integrated Circuit Card Specification for Payment Systems – Part
4: Security Aspect, Version 3.1.1, May 31, 1998
• EMV Issuer and Application Security Guidelines. Version 2.2, May 2009
EMV specifications and bulletins are available on www.emvco.com. Consult the
EMVCo Bulletins for up-to-date information.
PayPass
• PayPass – M/Chip, Security Architecture. Version 1.2, November 2007
• PayPass – Mag Stripe, Security Architecture. Version 1.3, November 2007
FIPS
FIPS PUB 180-2, Secure Hash Standard, August 2002
ISO
• ISO/IEC 7813, Information technology - Identification cards – Financial
Transaction Cards
• ISO/IEC 7816-4, Information technology - Identification cards – Integrated
circuit(s) cards with contacts – Part 4: Inter-industry commands for
interchange
• ISO/IEC 9796-2, Information technology - Security techniques - Digital
signature schemes giving message recovery. – Part 2: Integer factorization
based mechanisms
• ISO/IEC 9797-1, Information technology – Security techniques – Message
Authentication Codes - Part 1: Mechanisms using a block cipher
• ISO/IEC 10116, Information technology – Security techniques – Modes of
operation for an n-bit block cipher
• ISO/IEC 10118-3, Information technology – Security techniques –
Hash-functions – Part 3: Dedicated hash-functions
• ISO/IEC 18033-3, Information technology – Security techniques – Encryption
algorithms – Part 3: Block ciphers
• ISO 9564-1, Banking – Personal Identification Number management and
security – Part 1: Basic principles, and requirements for online PIN handling
in ATM & POS systems
• ISO 9564-2, Banking – Personal Identification Number management and
security – Part 2: Approved algorithm(s) for PIN encipherment
• ISO 9564-3, Banking – Personal Identification Number management and
security – Part 3: Requirements for offline PIN handling in ATM & POS
systems
• ISO 11568, Banking - Key Management
Abbreviations
The following abbreviations are used in this document:
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-5
Reference Information
Abbreviations
Abbreviation Description
AAC Application Authentication Cryptogram
AC Application Cryptogram
APDU Application Protocol Data Unit
ARPC Authorization Response Cryptogram
ARQC Authorization Request Cryptogram
ASN Abstract Syntax Notation
ATC Application Transaction Counter
b Binary
CA Certification Authority
CAM Card Authentication Method
CBC Cipher Block Chaining
CDA Combined DDA/Application Cryptogram Generation
CDOL Card Risk Management Data Object List
CLA Class Byte of the Command Message
©2008–2010 MasterCard
A-6 March 2010 • M/Chip Card Application Cryptographic Algorithms
Reference Information
Conventions
Abbreviation Description
P2 Parameter 2
PCA Certification Authority Public Key
PI Issuer Public Key
PIC ICC Public Key
PDOL Processing Options Data Object List
PK Public Key
RSA Rivest, Shamir, Adleman algorithm
SCA Certification Authority Private Key
SDA Static Data Authentication
SHA Secure Hash Algorithm
SI Issuer Private Key
SIC ICC Private Key
SK Session Key (or private key in RSA context)
SKD Session Key Derivation
SMC Secure Messaging for Confidentiality
Conventions
The M/Chip Application Cryptographic Algorithm manual utilizes the following
standard conventions.
Notation Meaning
‘0’ to ‘9’ and ‘A’ to ‘F’ 16 hexadecimal digits.
‘x..y’ Hexadecimal value.
A := B A is assigned the value of B.
A=B Value of A is equal to the value of B.
A º B (mod n) Integers A and B are congruent modulo the integer n, that is,
there exists an integer d such that (A - B) = dn.
A mod n The reduction of the integer A modulo the integer n, that is,
the unique integer 0 £ r < n for which there exists an integer
d such that A = dn + r.
Y := DES(K)[X] Encipherment of a 64-bit data block X with the DES algorithm
using a 56-bit secret key K.
X = DES-1(K)[Y] Decipherment of a 64-bit data block Y with the DES algorithm
using a 56-bit secret key K.
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-7
Reference Information
Contact Us
Notation Meaning
Y := DES3(K)[X] Encipherment of a 64-bit data block X with the Triple-DES
algorithm as specified in About DES and Triple-DES, using
a 112-bit secret key K.
X = DES3-1(K)[Y] Decipherment of a 64-bit data block Y with the Triple-DES
algorithm as specified in About DES and Triple-DES, using
a 112-bit secret key K.
Y := MAC(K)[X] Computation of the 8-byte MAC on the message X using key
K and the MAC algorithm specified in [EMV] Annex A1.2 and
ISO/IEC 9797-1 Algorithm 3 with DES as the block cipher.
Note that padding of X is performed as part of the MAC
algorithm.
Y := Sign (S)[X] The signing of a data block X with the RSA algorithm as
specified in RSA, using the private key S.
X = Recover(P)[Y] The recovery of the data block X with the RSA algorithm as
specified in RSA, using the public key P.
C := (A || B) The concatenation of an n-bit number A and an m-bit number
B, which is defined as C = 2m A + B.
H := SHA[M] Hashing of a message M of arbitrary length using the SHA-1
algorithm as specified in SHA-1.
|n| Length of an integer n in bits.
XÅY The bit-wise exclusive-OR of the data blocks X and Y. If one
data block is shorter than the other then it is first padded to
the left with sufficient binary zeros to make it the same length
as the other.
Contact Us
MasterCard is listening...
Please take a moment to provide MasterCard with your feedback about this
document.
Support
Please address your questions about MasterCard programs and services to the
Customer Operations Services team as follows:
Phone 1-800-999-0363 or 1-636-722-6176
1-636-722-6292 (Spanish language support)
Fax 1-636-722-7192
Telex 434800 answerback: 434800 ITAC UI
©2008–2010 MasterCard
A-8 March 2010 • M/Chip Card Application Cryptographic Algorithms
Reference Information
Contact Us
©2008–2010 MasterCard
M/Chip Card Application Cryptographic Algorithms • March 2010 A-9