EMV Perso Summary

Summary

Work on EMV perso scripts recently, summarize a few points include Initialize Update, External Authenticate, Store Data.
For some detail data, can refer to my another blog entry GP(Global Platform) External authentication and MAC sending APDU.

INITIALIZE UPDATE

Initialize Update is used to begin the authentication with the applet or Card Manager. Data in will be the host challenge.

CLAINSP1P2LcData inLe
80h50hKer Set Version00h08hHost Challenge00h

Response data is as below,

FieldLength(bytes)
Key Diversification Data10
Key Set Version (01-7Fh) or FFh1
SCP ID (02h)1
Sequence Counter2
Card Challenge6
Card Cryptogram8

example as below,

<< 80500000080000000000000000
>> 611C
<< 00C000001C
>> 0000507101046E6C8B70FF0200072503683B31FAB7F4E8D8857D0CB4

The host challenge data and response data will be used for external authentication.

EXTERNAL AUTHENTICATE

The External Authentication command authenticates the host to the current applet and open a secure channel to communicate to card. The command will include the security level.

FieldContentLength
CLA‘84’1
INS‘82’1
P1Security Level(see below table)1
CLA‘00’1
CLA‘10’1
CLAHost Cryptogram8
CLAC-MAC8

Security level P1,

b8b7b6b5b4b3b2b1Description
00000011Encryption and MAC
00000001MAC
00000000No Security

Session Keys

Session KeyIC Card KeyDerivation Data
SKUENC KENC ‘0182’|| sequence counter || ‘000000000000000000000000’
SKUMAC KMAC ‘0101’|| sequence counter || ‘000000000000000000000000’
SKUDEK KDEK ‘0181’|| sequence counter || ‘000000000000000000000000’

Continue with the first example, External Authentication command,

Random Data: 0000000000000000
ENC: 404142434445464748494A4B4C4D4E4F
MAC: 404142434445464748494A4B4C4D4E4F
DEK: 404142434445464748494A4B4C4D4E4F
Session ENC: A2268F71917EFE0F33CC6166E1154E27
Session MAC: 7A227D376A9DBE23AB50B7DCB45B2093
Session DEK: F39FCFB2383B09578723B8C2E03B2729
<< 848201001080F1BB4686D30DF9A0B8829AF3E87A16
>> 9000

STORE DATA

The STORE DATA command is used to personalize the EMV applications. Multiple DGI(Data Grouping Identifier) may be sent in one STORE DATA command.
STORE DATA Command Coding

FieldContentLength
CLA‘84’ or ‘84’1
INS‘E2’1
P1See below table1
P2Sequence Number1
LcLength of Command data1 or 3
DGI1 Identifier of first data grouping2
Length1 Length of first data grouping1 or 3
Data1 First data to be storedvar.
DGIn Identifier of n’th data to be stored2
Lengthn Length of n’th data grouping1 or 3
Datan n’th data to be storedvar.
C-MACPresent if CLS = ‘84’0 or 8

Coding of P1 in STORE DATA COMMAND

b8b7b6b5-b1Meaning
xLast STORE DATA command indicator
1Last STORE DATA command
0Not the last STORE DATA command
xxEncryption indicators:
11All DGI encrypted under SKUDEK , session DEK, DES ECB algorithm
00No DGI is encrypted
00Application dependent
10RFU
xxxxxRFU
DGI: 8201
Length: 48 
Original Data: 588C13E98E5294BE0161E432F8B0E77A208D8AAC95A7D8091099AFEC687A72A59C0CB179A327DFB044F0BFAA21D6232E0C29C99BBAD8A735B3952007F49DF43C8000000000000000 
Session DEK: 33C1D105492068CD86923711B29E6475
Encrypted: 6CF8E1732DE31C85318AB1549978C5D9D67C2CDE8668A4AEBFB36D2C766874B09D968A3DE64E0CE5C53A10F56B2818F4097804BCE8C27C4F9A6993B09C86D4FCC5D7FA98C3AEB6BE
<< 80E2600D4B8201486CF8E1732DE31C85318AB1549978C5D9D67C2CDE8668A4AEBFB36D2C766874B09D968A3DE64E0CE5C53A10F56B2818F4097804BCE8C27C4F9A6993B09C86D4FCC5D7FA98C3AEB6BE
>> 9000

C-MAC Command

If CLA = ‘84’, it will require to calculate the C-MAC and append to the end of the APDU command. The calculation will be using the session MAC key generated at the External Authentication step, and the IV will be using the C-MAC value generated in last C-MAC computing. Refer to my another blog entry for detail, GP(Global Platform) External authentication and MAC sending APDU.
Example:

Session MAC Key: 7A227D376A9DBE23AB50B7DCB45B2093
IV: A0B8829AF3E87A16 
<< 84E60C002C06A0000000031607A00000000316500E315041592E5359532E4444463031011002C900007CC1FECDA12AA91E
>> 6101
<< 00C0000001
>> 00
>> 9000 

Reference

1,Blog Entry: GP(Global Platform) External authentication and MAC sending APDU
2, EMV Card Personalization Specification
3, GlobalPlatform Card Specification Version 2.2 March 2006


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值