技术标签: perso external session 工作 authentica emv
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 is used to begin the authentication with the applet or Card Manager. Data in will be the host challenge.
CLA | INS | P1 | P2 | Lc | Data in | Le |
---|---|---|---|---|---|---|
80h | 50h | Ker Set Version | 00h | 08h | Host Challenge | 00h |
Response data is as below,
Field | Length(bytes) |
---|---|
Key Diversification Data | 10 |
Key Set Version (01-7Fh) or FFh | 1 |
SCP ID (02h) | 1 |
Sequence Counter | 2 |
Card Challenge | 6 |
Card Cryptogram | 8 |
example as below,
<< 80500000080000000000000000
>> 611C
<< 00C000001C
>> 0000507101046E6C8B70FF0200072503683B31FAB7F4E8D8857D0CB4
The host challenge data and response data will be used for external authentication.
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.
Field | Content | Length |
---|---|---|
CLA | ‘84’ | 1 |
INS | ‘82’ | 1 |
P1 | Security Level(see below table) | 1 |
CLA | ‘00’ | 1 |
CLA | ‘10’ | 1 |
CLA | Host Cryptogram | 8 |
CLA | C-MAC | 8 |
Security level P1,
b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | Description |
---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | Encryption and MAC |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | MAC |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | No Security |
Session Key | IC Card Key | Derivation 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
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
Field | Content | Length |
---|---|---|
CLA | ‘84’ or ‘84’ | 1 |
INS | ‘E2’ | 1 |
P1 | See below table | 1 |
P2 | Sequence Number | 1 |
Lc | Length of Command data | 1 or 3 |
DGI1 | Identifier of first data grouping | 2 |
Length1 | Length of first data grouping | 1 or 3 |
Data1 | First data to be stored | var. |
DGIn | Identifier of n’th data to be stored | 2 |
Lengthn | Length of n’th data grouping | 1 or 3 |
Datan | n’th data to be stored | var. |
C-MAC | Present if CLS = ‘84’ | 0 or 8 |
Coding of P1 in STORE DATA COMMAND
b8 | b7 | b6 | b5-b1 | Meaning |
---|---|---|---|---|
x | Last STORE DATA command indicator | |||
1 | Last STORE DATA command | |||
0 | Not the last STORE DATA command | |||
x | x | Encryption indicators: | ||
1 | 1 | All DGI encrypted under SKUDEK , session DEK, DES ECB algorithm | ||
0 | 0 | No DGI is encrypted | ||
0 | 0 | Application dependent | ||
1 | 0 | RFU | ||
xxxxx | RFU |
DGI: 8201
Length: 48
Original Data: 588C13E98E5294BE0161E432F8B0E77A208D8AAC95A7D8091099AFEC687A72A59C0CB179A327DFB044F0BFAA21D6232E0C29C99BBAD8A735B3952007F49DF43C8000000000000000
Session DEK: 33C1D105492068CD86923711B29E6475
Encrypted: 6CF8E1732DE31C85318AB1549978C5D9D67C2CDE8668A4AEBFB36D2C766874B09D968A3DE64E0CE5C53A10F56B2818F4097804BCE8C27C4F9A6993B09C86D4FCC5D7FA98C3AEB6BE
<< 80E2600D4B8201486CF8E1732DE31C85318AB1549978C5D9D67C2CDE8668A4AEBFB36D2C766874B09D968A3DE64E0CE5C53A10F56B2818F4097804BCE8C27C4F9A6993B09C86D4FCC5D7FA98C3AEB6BE
>> 9000
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
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
//继承Junit测试,在当前类开启注解功能@RunWith(SpringJUnit4ClassRunner.class)//构建spring工厂@ContextConfiguration(locations = "classpath:applicationContext.xml")public class SpringTest { @Autowired @Qualifi...
上周五晚九点十分,终于等到《最强大脑》第八季开播啦,88名来自全球各地的大佬们汇聚江苏,点燃了第八季的战火。其中,最让质心姐姐期待的莫过于我们的蔡神参加了第八季的《最强大脑》!!▲快来找找蔡神在哪~蔡子星老师,高中毕业于竞赛强校华师一附中,曾在2004年(第21届)全国中学生物理竞赛重荣获CPhO金牌成功入选国家集训队,并保送至北京大学物理学院。经过激烈的集训角逐之后,成功入选亚洲队,获得银牌。毕业后,蔡子星老师选择成为一名竞赛教练,现任质心教育物理竞赛金牌教练,凭借深厚的数学功底,深入浅出的讲解赢
在CentOS 6.x上重新分区USB驱动器时出现以下错误,请提出解决此问题的建议.Disk /dev/sdb: 31.5 GB, 31466323968 bytes255 heads, 63 sectors/track, 3825 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physi...
题目链接:poj 2104 K-th Number题意:给你n个数,数在[1,n],中,即为[1,n]的不同排列方式,现在给你一个子区间,让你求这个区间第k小的数归并树法:(复杂度o(n*log(n)+m*log^3n))所谓归并树,就是利用归并排序的思想,将两个有序的数列合并为一个新的有序数列。我们先提出一个概念,就是要求第k小的数x,则不超过x的数不少于k个,比如1,2,2,3
除了SCP能够远程传输,Ubuntu还能建立ftp进行远程传输文件
useRef的作用主要有两种1.操作DOM或者获取其他组件的引用操作步骤import { useRef } from 'react'const xxxx = useRef(null) <input ref={xxxx} />xxxx.current2.多次渲染之间共享数据import React, { useEffect, useState } from 'react'import ReactDom from 'react-dom'expo...
原标题:Modbus PLC攻击分析:Python和Mbtget读写PLC前言:如今工业控制系统设计的领域包括交通运输、能源行业、装备制造、机械制造等多个国家关键基础领域。工业控制系统的信息安全问题关系到国家安全和社会稳定。Modbus 协议是一种典型的工业控制系统通信协议,是目前应用最为广泛的工业控制协议之一。由于其设计简单、容易开发的特性,使得Modbus TCP 协议极易被恶意攻击者利用,从...
安装必要的运行环境宝塔面板安装成功后会有一个提示,包括宝塔面板地址和密码,如下图,注意如果宝塔面板地址不能访问,可能的原因是服务器没有打开这端口,需要在服务器打开这个端口。...
工具:1.kettle 6.02.mysql hive前期准备:===最近在尚硅谷看到一个教程是用kettle8 貌似不用导jar包了 >_<这里默认hive已经可以正常使用:一、大数据相关jar包放置路径 :pdi-ce-6.0.1.0-386\data-integration\plugins\pentaho-big-data-plugin\hadoop-configurations\hdp22\lib这里不一定使用hdp 需要根据hadoop安装方式自行选择
spring websocket 和socketjs实现单聊群聊,广播的消息推送详解WebSocket简单介绍随着互联网的发展,传统的HTTP协议已经很难满足Web应用日益复杂的需求了。近年来,随着HTML5的诞生,WebSocket协议被提出,它实现了浏览器与服务器的全双工通信,扩展了浏览器与服务端的通信功能,使服务端也能主动向客户端发送数据。image我们知...
原文:http://www.cnblogs.com/Y4ng/archive/2012/09/06/EnumProcessHandle_EnumMutex.html 相信做过游戏多开的朋友就会发现,很多游戏普遍使用互斥mutex来防止程序多开,说实话这种方式已经非常OUT了。但是由于时间和技术的沉淀关系,留下来的游戏依然会存在这种方式。 最近接触到一款游戏是N前非常火热的对战游戏,可以称...