Eclipse 生成的 .cap 文件无法安装在 JavaCard 上

Eclipse generated .cap file cannot be installed on JavaCard

我正在尝试在我的 JavaCard (Gemalto IDCore3010) 上安装小程序。我成功地使用了 GlobalPlatform helloworld.cap 文件,但是当我在 Eclipse (4.4.2) 中使用完全相同的源代码(虽然包名称不同,但这无关紧要)生成 .cap 文件时,我得到了GlobalPlatformShell 和 GlobalPlatformProShell 的错误消息。我使用与原始文件相同的命令和脚本。我还尝试了其他在模拟器上运行的 .cap 文件,所以代码本身应该没问题。 我上传了原始的 GlobalPlatform helloworld.cap 文件,我在 eclipse 中生成的 helloworld2.cap 文件,还有另一个在模拟器 in this zip.

中工作的 jctest.cap 文件

你知道什么可能导致这个问题吗?谢谢!

这是 GPSshell 脚本:

mode_201
enable_trace
establish_context
card_connect
select -AID A000000018434D00
open_sc -scp 1 -scpimpl 0x15 -security 3 -keyind 0 -keyver 0 -key 47454d5850524553534f53414d504c45 -keyDerivation visa2
//delete -AID D0D1D2D3D4D50101
//delete -AID D0D1D2D3D4D501
install -file helloworld.cap -nvDataLimit 500 -instParam 00 -priv 2
# getdata
# close_sc // Close secure channel
# putkey // Put key
  // options:
  //          -keyind Key index
  //          -keyver Key version
  //          -key Key value in hex
card_disconnect
release_context

GP情况下的输出:

C:\JavaCard\Shells>GPShell.exe installhelloworld.txt
mode_201
enable_trace
establish_context
card_connect
select -AID A000000018434D00
Command --> 00A4040008A000000018434D00
Wrapped command --> 00A4040008A000000018434D00
Response <-- 6F198408A000000018434D00A50D9F6E061291518101009F6501FF9000
open_sc -scp 1 -scpimpl 0x15 -security 3 -keyind 0 -keyver 0 -key 47454d58505245
53534f53414d504c45 -keyDerivation visa2
Command --> 8050000008ABAF3657F2F2522700
Wrapped command --> 8050000008ABAF3657F2F2522700
Response <-- 4D00927100004DD4C6C0FF014E7B8EBB606E082481D620728C695C779000
Command --> 8482030010ACE530BFF09C56478583FE9A69221530
Wrapped command --> 8482030010ACE530BFF09C56478583FE9A69221530
Response <-- 9000
install -file helloworld.cap -nvDataLimit 500 -instParam 00 -priv 2
Command --> 80E602001906A1A2A3A4A50108A000000018434D000006EF04C60201680000
Wrapped command --> 84E6020028955DC0D94AEEFDF116150C04C39F086D2B605F584F76C2CC76
77DF8D69824AB8EBBB47A7C4936FBD00
Response <-- 009000
Command --> 80E80000EFC482015D010010DECAFFED010204000106A1A2A3A4A50102001F001000
1F000B00150026000C00390019000F0000005D00020001000C02010004001502030107A000000062
0101000107A000000062000103000B0107A1A2A3A4A50101000C06000C00800300FF000701000000
15070039000110188C0000188B00017A01308F00028C00037A0521198B00042D198B00053B7B0006
031A037B0006928D00073B19037B0006928B00087A08001900020001000103000C48656C6C6F2057
6F726C64210000000005002600090680030003800301010000000600000103800A0103800A060500
00000680100203800A08
Wrapped command --> 84E80000F86937B224616C3940252139576B04271DB825D14655DAAE1646
49D3AD978709AFD0574F2C05CD2C621C8603DC425ADCA804B473B791716F6D63830A60F9220E370E
2949FEAA1799E7CD7EF685EAE3BE9B38D1249C2E78C54F1A4EB1BD30CAB08A07CBABC650AAC167B9
AEB29F4D7A89693841F8B5B3169369C05C30C0E3C13ADA46DCFB238999317C24F129507DF1319FF6
2C4682664FF7971CCB00D72B17E25F8D84810FA1DCD48D4505E2726471DAB4E5CD20A9FFF530CF34
3E9A8E10FF1E86081047106BCAD404778190855C5AE4921818048900FE30E5F3264CA0F5E6C0306C
26AE2762BFCEE7A64E5D7A41B2F5CCF619D1ECED4EE4CF
Response <-- 6985
load() returns 0x80206985 (6985: Command not allowed - Conditions of use not sat
isfied.)

GPP 情况下的输出:

C:\JavaCard\Shells\tmp>gp -d -v -visa2 -key 47454D5850524553534F53414D504C45 -in
stall helloworld.cap
# Detected readers from SunPCSC
[*] OMNIKEY CardMan 3x21 0
SCardConnect("OMNIKEY CardMan 3x21 0", T=*) -> T=0, 3B7D96000080318065B0831111AC
83009000
SCardBeginTransaction("OMNIKEY CardMan 3x21 0")
Reader: OMNIKEY CardMan 3x21 0
ATR: 3B7D96000080318065B0831111AC83009000
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B7D96000080318065B0831111AC83009
000

A>> T=0 (4+0000) 00A40400 00
A<< (0027+2) (645ms) 6F198408A000000018434D00A50D9F6E061291518101009F6501FF 9000

Auto-detected ISD AID: A000000018434D00
A>> T=0 (4+0008) 80500000 08 F888243B93B0AEFC 00
A<< (0028+2) (72ms) 4D00927100004DD4C6C0FF01F1AC32CF3E3A139896399AA2549D41EC 900
0
Host challenge: F888243B93B0AEFC
Card challenge: F1AC32CF3E3A1398
Card reports SCP01 with version 255 keys
Master keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:47454D5850524553534F53414D504C45
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:47454D5850524553534F53414D504C45
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:47454D5850524553534F53414D504C45
Diversififed master keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:5B9387DE5E618B12760EBE6037B077AC
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:5454366589B6AE522F58EE7072C101DF
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:72590E8782F97E80406E4B66199B7CB2
Derived session keys:
Version 0
ENC: Ver:0 ID:0 Type:DES3 Len:16 Value:FDA5AC97ED1C755D795C3D19175AF8DC
MAC: Ver:0 ID:0 Type:DES3 Len:16 Value:D9E46A262F4E729952EDAFE7AD6CA3FA
KEK: Ver:0 ID:0 Type:DES3 Len:16 Value:72590E8782F97E80406E4B66199B7CB2
Verified card cryptogram: 96399AA2549D41EC
Calculated host cryptogram: 871DBF6DC2F054DF
A>> T=0 (4+0016) 84820100 10 871DBF6DC2F054DF061ADD256D383068
A<< (0000+2) (37ms) 9000
CAP file (v2.1) generated on Fri Mar 27 16:17:51 CET 2015
By Sun Microsystems Inc. converter 1.3 with JDK 1.8.0_40 (Oracle Corporation)
Package: helloworld v1.0 with AID A1A2A3A4A501
Applet: HelloWorldApplet with AID A1A2A3A4A50101
Import: A0000000620101 v1.3
Import: A0000000620001 v1.0
A>> T=0 (4+0010) 84F28000 0A 4F00DBC4BDEABE26BDFD 00
A<< (0011+2) (14ms) 08A000000018434D00019E 9000
A>> T=0 (4+0010) 84F24000 0A 4F00AA1B69956033DFC8 00
A<< (0030+2) (18ms) 10A0000000183003010000000000000000070008D0D1D2D3D4D501010702
 9000
A>> T=0 (4+0010) 84F22000 0A 4F00FDFB0B960D7A008A 00
A<< (0211+2) (55ms) 07A0000000620001010007A0000000620002010007A00000006200030100
07A0000000620101010008A000000062010101010007A0000000620102010007A000000062020101
0007A0000000030000010007A0000001320001010008A000000018100106010008A0000000181002
01010008A000000018100101010006A00000015100010008A000000018100301010010A000000018
30060100000000000000FF010010A00000001830060200000000000000FF010010A0000000183003
0100000000000000FF010007D0D1D2D3D4D5010100 9000
A>> T=0 (4+0010) 84F21000 0A 4F007B25AA477B85E2B2 00
A<< (0233+2) (59ms) 07A000000062000101000007A000000062000201000007A0000000620003
01000007A000000062010101000008A00000006201010101000007A000000062010201000007A000
000062020101000007A000000003000001000007A000000132000101000008A00000001810010601
000008A00000001810020101000008A00000001810010101000108A00000001853444106A0000001
510001000008A00000001810030101000108A00000001841435410A0000000183006010000000000
0000FF01000010A00000001830060200000000000000FF01000110A0000000183006020000000000
000000 6310
A>> T=0 (4+0010) 84F21001 0A 4F005CC7C8EEACBEF648 00
A<< (0057+2) (20ms) 10A00000001830030100000000000000FF01000110A00000001830030100
0000000000000007D0D1D2D3D4D50101000108D0D1D2D3D4D50101 9000
A>> T=0 (4+0027) 84E60200 1B 06A1A2A3A4A50108A000000018434D00000000896DC5D8DC755
5DC
A<< (0001+2) (71ms) 9000
A>> T=0 (4+0255) 84E80000 FF C481FD010010DECAFFED010204000106A1A2A3A4A50102001F0
010001F000B00150026000C00390019000F0000005D00020001000C02010004001502030107A0000
000620101000107A000000062000103000B0107A1A2A3A4A50101000C06000C00800300FF0007010
0000015070039000110188C0000188B00017A01308F00028C00037A0521198B00042D198B00053B7
B0006031A037B0006928D00073B19037B0006928B00087A08001900020001000103000C48656C6C6
F20576F726C64210000000005002600090680030003800301010000000600000103800A0103800A0
6050000000680100203800A0809000F0000000B0504637BA24469BAECA3
A<< (0000+2) (181ms) 6985
Applet loading failed. Are you sure the CAP file target is compatible with your
card?
CAP loaded
A>> T=0 (4+0037) 84E60C00 25 06A1A2A3A4A50107A1A2A3A4A5010107A1A2A3A4A5010101000
2C9000089985BB5541BF631
A<< (0000+2) (15ms) 6A88
pro.javacard.gp.GPException: Install for Install and make selectable failed SW:
6A88
        at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1092)
        at pro.javacard.gp.GlobalPlatform.installAndMakeSelectable(GlobalPlatfor
m.java:798)
        at pro.javacard.gp.GPTool.main(GPTool.java:478)

您的 .cap 文件似乎与您的卡不兼容。您应该检查以下项目:

1 : 用于生成 cap[的 Java 卡片开发工具包 的版本 文件必须低于 than/equal 与您的卡兼容的 Java 卡 的版本。

2 : Eclipse Compiler Compatible Level 必须等于 1.3(我认为这是强制性的 JC 2.2.1JC 2.2.2 仅适用于新版本)

3 : Java 卡片 API 的某些功能是可选的。如果您使用了一些您的卡不支持的可选功能,小程序上传也会失败。 (虽然卡的JC版本等于你用的JCDK) * 顺便说一句,这不是你的问题,因为你的小程序没有使用任何可选功能。

您可以检查编译器兼容级别如下:

备注:

1- 请先检查第 2 部分!

2- 当您将 Eclipse 与 Eclipse-JCDE 插件一起使用时,此插件仅支持 JCDK 2.2.2,您可能还需要 检查 JCDK 2.2.1。

使用javacos软件。它可以生成两个版本 2.2.2 的 cap 文件。和 2.2.1