将GPO命令定义为APDU命令:
CLA INS P1 P2 Lc Data Le
80 A8 00 00 Lc Data 00
因此缺少的部分是 Lc 和数据,我们必须根据 PDOL (如果已提供)进行计算。如果没有给出,我们可以使用:
80 A8 00 00 02 8300 00
这适用于万事达卡,但对于VISA,我得到了PDOL并试图构造缺少的APDU部分(Lc和数据)。
步骤1-我从我的EMV卡中获得了此PDOL:
9F66049F02069F03069F1A0295055F2A029A039C019F3704
第2步-通过命令将其拆分:
9F6604 9F0206 9F0306 9F1A02 9505 5F2A02 9A03 9C01 9F3704
第3步-按字节长度再次拆分:
9F66 04 | 9F02 06 | 9F03 06 | 9F1A 02 | 95 05 | 5F2A 02 | 9A 03 | 9C 01 | 9F37 04
步骤4-给出以下命令(删除长度):
描述“要插入的内容”
9F66 | 9F02 | 9F03 | 9F1A | 95 | 5F2A | 9A | 9C | 9F37
第5步-命令的长度(删除命令)如下:
描述“每个命令的长度”
04 | 06 | 06 | 02 | 05 | 02 | 03 | 01 | 04
第6步-假定长度为2位,这会使我们加倍:
8 | 12 | 12 | 4 | 10 | 4 | 6 | 2 | 8
第7步-预期的输出现在应如下所示:
aaaaaaaa bbbbbbbbbbbb cccccccccccc dddd eeeeeeeeee ffff gggggg hh iiiiiiii
步骤8-查找命令以查找值:
9F66 | 9F02 | 9F03 | 9F1A | 95 | 5F2A | 9A | 9C | 9F37
https://www.emvlab.org/emvtags/show/t9F66/ =未知(我在Google上搜索了它,发现它是:“终端交易限定符” = TTQ)
https://www.emvlab.org/emvtags/show/t9F02/ =授权金额
https://www.emvlab.org/emvtags/show/t9F03/ =次要/现金返还金额
https://www.emvlab.org/emvtags/show/t9F1A/ = ISO 3166终端国家代码(TCC)
https://www.emvlab.org/emvtags/show/t95/ =终端验证结果(TVR)
https://www.emvlab.org/emvtags/show/t5F2A/ = ISO 4217货币代码(CC)
https://www.emvlab.org/emvtags/show/t9A/ =交易日期YYMMDD
https://www.emvlab.org/emvtags/show/t9C/ = ISO 8583:1987的前2位数字(交易类型-TT)
https://www.emvlab.org/emvtags/show/t9F37/ =不可预测的数字(密码的随机数-UN)
步骤9-插入obvios数据:
9F66 aaaaaaaa TTQ
9F02 bbbbbbbbbbbb Amount 000000001000
9F03 cccccccccccc Cashback 000000000000
9F1A dddd TCC
95 eeeeeeeeee TVR
5F2A ffff CC
9A gggggg YYMMDD 190325
9C hh TT
9F37 iiiiiiii UN 12121212
第10步-终端交易资格(TTQ):
(支持的终端功能设置)
9F66 a1 a2 a3 a4
A. a1 - Hex to binary -> 00000000
B. a2 - Hex to binary -> 00000000
C. a3 - Hex to binary -> 00000000
D. a4 - Hex to binary -> 00000000 - RFU (Reserved Future Use)
每个零都可以打开或关闭。
A. a1 (hex to binary gives 8 numbers)
8. 0 - Contactless MSD - Example: 0 - false
7. 0 - Contactless VSDC - Example: 1 - true
6. 0 - Contactless qVSDC - Example: 0 - false
5. 0 - EMV contact chip - Example: 1 - true
4. 0 - Offline-only reader - Example: 0 - false
3. 0 - Online PIN - Example: 0 - false
2. 0 - Signature - Example: 0 - false
1. 0 - Offline data auth (ODA) - Example: 1 - true
示例给出:01010001。十六进制二进制-> 51
B. a2 (hex to binary gives 8 numbers)
8. 0 - Require Online Crypt - Example: 0 - false
7. 0 - CVM required . - Example: 0 - false
6. 0 - Offline PIN support - Example: 0 - false
5. 0 - RFU(Reserved Future Use) - Example: 0 - false
4. 0 - RFU(Reserved Future Use) - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
C. a3 (hex to binary gives 8 numbers)
8. 0 - Issuer update process - Example: 0 - false
7. 0 - Mobile functionality - Example: 1 - true
6. 0 - RFU(Reserved Future Use) - Example: 0 - false
5. 0 - RFU(Reserved Future Use) - Example: 0 - false
4. 0 - RFU(Reserved Future Use) - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:01000000。二进制转换为十六进制-> 40
D. a4 = RFU(Reserved Future Use) = 00000000 = 00
给出:00000000。二进制转换为十六进制-> 00
将十六进制值放在一起将返回:TTQ = 51004000
第11步-更新ISO值(Google对其进行更新)并插入TTQ:
参考:https://en.wikipedia.org/wiki/ISO_8583
TT
Authorization: 00
Balance inquiry: 31
Sale: 00
Cash: 01
Void: 02
Mobile topup: 57
9F66 aaaaaaaa TTQ 51004000 TTQ
9F02 bbbbbbbbbbbb Amount 000000001000
9F03 cccccccccccc Cashback 000000000000
9F1A dddd TCC 0578 ISO 3166 Norway (not same as phone)
95 eeeeeeeeee TVR
5F2A ffff CC 0978 ISO 4217 Euro
9A gggggg YYMMDD 190325
9C hh TT 00 ISO 8583:1987 first 2 digits
9F37 iiiiiiii UN 12121212
第12步-终端验证结果(TVR):
https://en.wikipedia.org/wiki/Terminal_verification_results
9F66 e1 e2 e3 e4 e5
A. e1 - Hex to binary -> 00000000
B. e2 - Hex to binary -> 00000000
C. e3 - Hex to binary -> 00000000
D. e4 - Hex to binary -> 00000000
E. e5 - Hex to binary -> 00000000
每个零都可以打开或关闭。
A. e1 (hex to binary gives 8 numbers)
8. 0 - Offline process not performed - Example: 0 - false
7. 0 - SDA failed - Example: 0 - false
6. 0 - ICC data missing - Example: 0 - false
5. 0 - Card number on hotlist - Example: 0 - false
4. 0 - DDA failed - Example: 0 - false
3. 0 - CDA failed - Example: 0 - false
2. 0 - RFU (SDA was selected) - Example: 0 - false
1. 0 - RFU - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
B. e2 (hex to binary gives 8 numbers)
8. 0 - Card/terminal version differ. - Example: 0 - false
7. 0 - Expired app - Example: 0 - false
6. 0 - App not yet effective - Example: 0 - false
5. 0 - Service not allowed for card - Example: 0 - false
4. 0 - New card - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
C. e3 (hex to binary gives 8 numbers)
8. 0 - Cardholder verification fail - Example: 0 - false
7. 0 - Unrecognised CVM - Example: 0 - false
6. 0 - PIN try limit exceeded - Example: 0 - false
5. 0 - PIN required, but no pinpad - Example: 0 - false
4. 0 - PIN req. & present & missing - Example: 0 - false
3. 0 - On-line PIN entered - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
D. e4 (hex to binary gives 8 numbers)
8. 0 - Transact. exceeds floor limit - Example: 0 - false
7. 0 - Lower offline limit exceeded - Example: 0 - false
6. 0 - Upper offline limit exceeded - Example: 0 - false
5. 0 - Transa. randomly sele. online - Example: 0 - false
4. 0 - Merch. forced online transac. - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
E. e5 (hex to binary gives 8 numbers)
8. 0 - Default TDOL Used - Example: 0 - false
7. 0 - Issuer authentication failed - Example: 0 - false
6. 0 - Script fail before final GAC - Example: 0 - false
5. 0 - Script fail after final GAC - Example: 0 - false
4. 0 - RFU(Reserved Future Use) - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00000000。二进制到十六进制-> 00
将所有十六进制值放在一起可得出:TVR = 0000000000
步骤13-最终命令:
9F66 aaaaaaaa TTQ 51004000
9F02 bbbbbbbbbbbb Amount 000000001000
9F03 cccccccccccc Cashback 000000000000
9F1A dddd TCC 0578
95 eeeeeeeeee TVR 0000000000
5F2A ffff CC 0978
9A gggggg YYMMDD 190325
9C hh TT 00
9F37 iiiiiiii UN 12121212
结果:
51004000 000000001000 000000000000 0578 0000000000 0978 190325 00 12121212
步骤14-获取标签长度值:
获取结果长度: 510040000000000010000000000000000000000578000000000009781903250012121212 = 66个数字 它是2位,所以: 66/2 = 33个字符
Convert 33 to HEX = 21
tlv = 21
tlv应该在步骤13的结果之前应用:
21 510040000000000010000000000000000578000000000009781903250012121212
第15步-添加GPO标签“ 83”:
83 21 510040000000000010000000000000000578000000000009781903250012121212
因此,数据 = 8321510040000000000010000000000010000578000000000009781903250012121212
步骤16-获取整个命令(Lc)的标签长度值:
获取结果长度:
8321510040000000000010000000000000000578000000000009781903250012121212
= 70 numbers
It is 2-bits, so:
70 / 2 = 35 characters
Convert 35 to HEX = 23
Lc = 23
STEP 17-全部放在一起:
请记住,缺少的部分是 Lc 和 Data
CLA INS P1 P2 Lc Data Le
80 A8 00 00 Lc Data 00
80 A8 00 00 23 Data 00
添加数据:
APDU =
80A8000023832151004000000000001000000000000000057800000000000978190325001212121200
问题
我生成的最终apdu命令返回无值。 有人知道我跌倒了哪一步,还是可以看到我做错了什么?
资源:
https://www.emvlab.org/emvtags/
https://en.wikipedia.org/wiki/Terminal_verification_results
https://www.rapidtables.com/convert/number/decimal-to-hex.html
https://tvr-decoder.appspot.com/t/home
Parsing PDOL for GET PROCESSING OPTIONS command in EMV transaction
Getting Parser error on request for GPO command for EMV card
https://www.iban.com/currency-codes
答案 0 :(得分:2)
我发现了错误。问题在于在 STEP 10 中设置正确的交易功能。
由于我的处理器仅是NFC读取器,因此我不得不将STEP 10修改为以下内容:
第10步-终端交易资格(TTQ):
(支持的终端功能设置)
9F66 a1 a2 a3 a4
A. a1 - Hex to binary -> 00000000
B. a2 - Hex to binary -> 00000000
C. a3 - Hex to binary -> 00000000
D. a4 - Hex to binary -> 00000000 - RFU (Reserved Future Use)
每个零都可以打开或关闭。
A. a1 (hex to binary gives 8 numbers)
8. 0 - Contactless MSD - Example: 1 - true
7. 0 - Contactless VSDC - Example: 1 - true
6. 0 - Contactless qVSDC - Example: 1 - true
5. 0 - EMV contact chip - Example: 1 - true
4. 0 - Offline-only reader - Example: 0 - false
3. 0 - Online PIN - Example: 0 - false
2. 0 - Signature - Example: 0 - false
1. 0 - Offline data auth (ODA) - Example: 0 - false
示例给出:11110000。二进制到十六进制-> F0
B. a2 (hex to binary gives 8 numbers)
8. 0 - Require Online Crypt - Example: 0 - false
7. 0 - CVM required . - Example: 0 - false
6. 0 - Offline PIN support - Example: 1 - true
5. 0 - RFU(Reserved Future Use) - Example: 0 - false
4. 0 - RFU(Reserved Future Use) - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:00100000。二进制到十六进制-> 20
C. a3 (hex to binary gives 8 numbers)
8. 0 - Issuer update process - Example: 0 - false
7. 0 - Mobile functionality - Example: 1 - true
6. 0 - RFU(Reserved Future Use) - Example: 0 - false
5. 0 - RFU(Reserved Future Use) - Example: 0 - false
4. 0 - RFU(Reserved Future Use) - Example: 0 - false
3. 0 - RFU(Reserved Future Use) - Example: 0 - false
2. 0 - RFU(Reserved Future Use) - Example: 0 - false
1. 0 - RFU(Reserved Future Use) - Example: 0 - false
示例给出:01000000。二进制转换为十六进制-> 40
D. a4 = RFU(Reserved Future Use) = 00000000 = 00
给出:00000000。二进制转换为十六进制-> 00
将十六进制值放在一起将返回:TTQ = F0204000
因此将 TTQ 值更改为 F0204000 可使卡响应GPO命令。 :)