我有一张没有融合的智能卡(我的意思是它没有预先个性化)。它有一个 ATR= 3B F9 13 00 00 81 31 FE 45 4A 43 4F 50 32 34 32 52 33 A2
。
Q1:我卡的历史字节是什么/在哪里?我如何分析它们?
Q2:我在哪里可以找到我的卡的型号?我在网上搜索了它的ATR,但一无所获!
当您尝试使用GPJ等工具列出真正空白卡(我的意思是未融合的卡)的小程序时,您会收到以下输出:
>> gpj -list
>> java -jar gpj.jar -list
Found terminals: [PC/SC terminal ACS CCID USB Reader 0]
Found card in terminal: ACS CCID USB Reader 0
ATR: 3B F9 13 00 00 81 31 FE 45 4A 43 4F 50 32 34 32 52 33 A2
DEBUG: Command APDU: 00 A4 04 00 07 A0 00 00 01 51 00 00
DEBUG: Response APDU: 6A 82
Failed to select Security Domain GP211 A0 00 00 01 51 00 00 , SW: 6A 82
DEBUG: Command APDU: 00 A4 04 00 08 A0 00 00 00 18 43 4D 00
DEBUG: Response APDU: 6A 82
Failed to select Security Domain GemaltoXpressPro A0 00 00 00 18 43 4D 00 , SW:6A 82
DEBUG: Command APDU: 00 A4 04 00 08 A0 00 00 00 03 00 00 00
DEBUG: Response APDU: 6A 82
Failed to select Security Domain OP201a A0 00 00 00 03 00 00 00 , SW: 6A 82
DEBUG: Command APDU: 00 A4 04 00 07 A0 00 00 00 03 00 00
DEBUG: Response APDU: 6A 82
Failed to select Security Domain OP201b A0 00 00 00 03 00 00 , SW: 6A 82
net.sourceforge.gpj.cardservices.exceptions.GPSecurityDomainSelectionException:Could not select any of the known Security Domains!
at net.sourceforge.gpj.cardservices.GlobalPlatformService.open(Unknown Source)
at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown Source)
上面的输出意味着工具找不到任何可供选择的 SC。
我在互联网上搜索了很多,最后发现我需要一个密钥(Transport-Key)来进行Pre-Personalization过程。
让我分享一些知识!
预个性化程序如下(针对 JCOP):
- ATR 请求
- 选择命令来选择根小程序(Transport-Key 是这个小程序的 AID)
- 引导命令
- 可以根据需要使用尽可能多的 Read、WRITE、ADMINEXEC、SB_NAT_APPLET_INSTRUCTION 和 AUTH 命令
- 保护命令
- 熔断命令
- 重置卡。
在第 4 步中,我们使用默认设置初始化 IC(配置 IC 所需的生命周期、定义通信行为、ATR 和/或 ATS 参数或预加载小程序)。
顺便说一句,我做了前两个步骤(1和2),然后我重置了卡,我试图再次列出小程序:
>> gpj -list
>> java -jar gpj.jar -list
Found terminals: [PC/SC terminal ACS CCID USB Reader 0]
Found card in terminal: ACS CCID USB Reader 0
ATR: 3B F9 13 00 00 81 31 FE 45 4A 43 4F 50 32 34 32 52 33 A2
DEBUG: Command APDU: 00 A4 04 00 07 A0 00 00 01 51 00 00
DEBUG: Response APDU: 6F 64 84 08 A0 00 00 01 51 00 00 00 A5 58 9F 65 01 FF 9F 6E 06 47 91 23 47 41 00 73 49 06 07 2A 86 48 86 FC 6B 01 60 0B 06 09 2A 86 48 86 FC 6B 02 02 02 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 55 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 90 00
Successfully selected Security Domain GP211 A0 00 00 01 51 00 00
DEBUG: Command APDU: 80 50 00 00 08 E7 41 23 4E F5 3B EB E3
DEBUG: Response APDU: 00 00 41 98 00 17 14 97 42 48 FF 02 00 00 BA FF B1 51 C8 BD F1 69 59 8D 80 D6 72 66 90 00
javax.smartcardio.CardException: Card cryptogram invalid.at net.sourceforge.gpj.cardservices.GlobalPlatformService.openSecureChannel(Unknown Source)
at net.sourceforge.gpj.cardservices.GlobalPlatformService.main
(Unknown Source)
如您所见,出现了一个带有 AID= 的小程序A0 00 00 01 51 00 00
。但我无法成功执行EXTERNAL AUTHENTCAT命令!
Q3:为什么外部认证失败?因为我没有设置 SD 密钥?
我尝试使用OpenSC Tool选择这个小程序:
>> opensc-tool -s 00A4040007A0000001510000
Using reader with a card: ACS CCID USB Reader 0
Sending: 00 A4 04 00 07 A0 00 00 01 51 00 00
Received (SW1=0x90, SW2=0x00):
6F 64 84 08 A0 00 00 01 51 00 00 00 A5 58 9F 65 od......Q....X.e
01 FF 9F 6E 06 47 91 23 47 41 00 73 49 06 07 2A ...n.G.#GA.sI..*
86 48 86 FC 6B 01 60 0B 06 09 2A 86 48 86 FC 6B .H..k.`...*.H..k
02 02 02 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B ...c...*.H..k.d.
06 09 2A 86 48 86 FC 6B 04 02 55 65 0B 06 09 2B ..*.H..k..Ue...+
85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 ...Hd...f...+...
01 2A 02 6E 01 02 .*.n..
Q4:这个输出是什么意思?
在下面,您还可以在get-data脚本之后看到GP Shell的输出:
.:: gpshell get_data.txt
establish_context
enable_trace
enable_timer
card_connect
command time: 281 ms
get_data -identifier 9F7F
Command --> 80CA9F7F00
Wrapped command --> 80CA9F7F00
Response <-- 9F7F2A4790507547912347410041980017149742484812420500000000143E24303
137313400000000000000009000
9F7F2A4790507547912347410041980017149742484812420500000000143E243031373134000000
0000000000
command time: 62 ms
get_data -identifier 66
Command --> 80CA006600
Wrapped command --> 80CA006600
Response <-- 664B734906072A864886FC6B01600B06092A864886FC6B020202630906072A86488
6FC6B03640B06092A864886FC6B040255650B06092B8510864864020103660C060A2B060104012A0
26E01029000
664B734906072A864886FC6B01600B06092A864886FC6B020202630906072A864886FC6B03640B06
092A864886FC6B040255650B06092B8510864864020103660C060A2B060104012A026E0102
command time: 47 ms
card_disconnect
command time: 141 ms
release_context
command time: 0 ms
.::
Q5:这个输出是什么意思?我该如何分析它?