为什么我在尝试更改JavaCard密钥时收到6A80,6A84和6A88?

时间:2014-05-31 04:46:21

标签: smartcard javacard

我有一张没有applet的java卡。当我尝试通过 JCManager 添加/修改其密钥时,我收到6A846A88 APDU-Response。

注意事项1:我在GP卡Spec2.2上搜索了这两个回复,最后我发现了它们的含义!

注意2:当我将密钥集编号更改为2时,并在添加时设置单选按钮,我收到6A80 [命令数据字段中的参数不正确] !!!

注意3:然后,我可以成功添加和修改密钥。此外,在从读卡器中取出卡并将其再次放入其中后,卡片钥匙也发生了任何变化!但经过一些尝试添加和修改后,我收到6A80 / 6A84 / 6A88

这是jcmanager的输出,而我把单选按钮放在"添加"给我6A84 [文件中的内存空间不足]

enter image description here

当我看到"修改"单选按钮,我收到6A88 [未找到参考数据或参考数据] enter image description here

更新:我使用GPSHELL替换/回收密钥,但我收到此输出:

C:\Users\ghasemi\Desktop\GPShell-1.4.4>gpshell recyclekey-cosmo-gp211.txt
mode_211
enable_trace
establish_context
card_connect
select -AID a0000000030000
Command --> 00A4040007A0000000030000
Wrapped command --> 00A4040007A0000000030000
Response <-- 6F108408A000000003000000A5049F6501FF9000
open_sc -security 1 -keyind 0 -keyver 0 -mac_key 505152535455565758595a5b5c5d5e5
f -enc_key 505152535455565758595a5b5c5d5e5f -kek_key 505152535455565758595a5b5c5
d5e5f // Open secure channel
Command --> 80CA006600
Wrapped command --> 80CA006600
Response <-- 664C734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864
886FC6B03640B06092A864886FC6B040215650B06092B8510864864020103660C060A2B060104012
A026E01029000
Command --> 8050000008EFBC3082C086980800
Wrapped command --> 8050000008EFBC3082C086980800
Response <-- 0000116001007F8B0AF9020201CE4DA5AC97B74B861FCDC3513F4E279000
mutual_authentication() returns 0x80302000 (The verification of the card cryptog
ram failed.)

C:\Users\ghasemi\Desktop\GPShell-1.4.4>gpshell replacekey-cosmo-gp211.txt
mode_211
enable_trace
establish_context
card_connect
select -AID a0000000030000
Command --> 00A4040007A0000000030000
Wrapped command --> 00A4040007A0000000030000
Response <-- 6F108408A000000003000000A5049F6501FF9000
open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4
f -enc_key 404142434445464748494a4b4c4d4e4f -kek_key 404142434445464748494a4b4c4
d4e4f // Open secure channel
Command --> 80CA006600
Wrapped command --> 80CA006600
Response <-- 664C734A06072A864886FC6B01600C060A2A864886FC6B02020101630906072A864
886FC6B03640B06092A864886FC6B040215650B06092B8510864864020103660C060A2B060104012
A026E01029000
Command --> 8050000008265AB6AEA30BA66700
Wrapped command --> 8050000008265AB6AEA30BA66700
Response <-- 0000116001007F8B0AF9020201CE4DA5AC97B74BC8B179AE19AE9C799000
Command --> 848201001038FCE51496D47D400D437EC5F7D51EFE
Wrapped command --> 848201001038FCE51496D47D400D437EC5F7D51EFE
Response <-- 9000
put_sc_key -keyver 1 -newkeyver 1 -mac_key 505152535455565758595a5b5c5d5e5f -enc
_key 505152535455565758595a5b5c5d5e5f -kek_key 505152535455565758595a5b5c5d5e5f
// Put secure channel keys
Command --> 80D8018143018010AA3EB3DDC7861B08DA195E1CA04A8BDF03A4B7D68010AA3EB3DD
C7861B08DA195E1CA04A8BDF03A4B7D68010AA3EB3DDC7861B08DA195E1CA04A8BDF03A4B7D600
Wrapped command --> 84D801814B018010AA3EB3DDC7861B08DA195E1CA04A8BDF03A4B7D68010
AA3EB3DDC7861B08DA195E1CA04A8BDF03A4B7D68010AA3EB3DDC7861B08DA195E1CA04A8BDF03A4
B7D602CA7DE4B07AD3DE00
Response <-- 6A88
put_secure_channel_keys() returns 0x80206A88 (6A88: Referenced data not found.)

C:\Users\ghasemi\Desktop\GPShell-1.4.4>

这是recyclekey-cosmo-gp211.txt的内容[gpshell的脚本]:

mode_211
enable_trace
establish_context
card_connect
# -readerNumber 3
select -AID a0000000030000
open_sc -security 1 -keyind 0 -keyver 0 -mac_key 505152535455565758595a5b5c5d5e5f -enc_key 505152535455565758595a5b5c5d5e5f -kek_key 505152535455565758595a5b5c5d5e5f // Open secure channel
put_sc_key -keyver 1 -newkeyver 1 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f -kek_key 404142434445464748494a4b4c4d4e4f // Put secure channel keys
card_disconnect
release_context

这是replacekey-cosmo-gp211.txt的内容[gpshell的脚本]:

mode_211
enable_trace
establish_context
card_connect
# -readerNumber 3
select -AID a0000000030000
open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f -kek_key 404142434445464748494a4b4c4d4e4f // Open secure channel
put_sc_key -keyver 1 -newkeyver 1 -mac_key 505152535455565758595a5b5c5d5e5f -enc_key 505152535455565758595a5b5c5d5e5f -kek_key 505152535455565758595a5b5c5d5e5f // Put secure channel keys
#put_sc_key -keyver 1 -newkeyver 1 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f -kek_key 404142434445464748494a4b4c4d4e4f // Put secure channel keys
card_disconnect
release_context

更新2: enter image description here

我该如何处理这个问题?

1 个答案:

答案 0 :(得分:0)

我从未使用过JCManager,因此我不确定它如何将表单中的字段映射到APDU中的参数,但它可以将Keyset映射到P1(密钥版本号)。 在许多配置中,SCP02的密钥版本号从0x20开始 - 密钥版本号1不存在,因此6A88响应代码。

所以我的建议是:尝试将Keyset设置为0x20(32)并查看会发生什么。祝你好运!

我想引用一些规范,其中说SCP02密钥版本号从0x20开始,但除了UICC配置之外我找不到,而且那个版本没有免费提供 - 抱歉。

尝试使用标记为“E0”的GET DATA读取卡中已有的键的ID和版本。原始APDU应为:80CA00E000。 该命令将使用E0数据结构进行响应,该结构包含有关安全域中所有密钥的信息(您之前将选择该密钥)。请参阅GP CardSpec中的表11-27。