问题
I am trying to install applets on my JavaCard (Gemalto IDCore3010). I succeeded with the GlobalPlatform helloworld.cap file, but when it was me generating the .cap file in Eclipse (4.4.2) using the very same sourcecode (with different package name though, but that shouldn't matter) I got error messages both with GlobalPlatformShell and GlobalPlatformProShell. I was using the same command and script as in case of the original file. I also tried other .cap files that had been working on emulators, so the code itself should be fine. I uploaded the original GlobalPlatform helloworld.cap file, my helloworld2.cap file generated in eclipse, and also another jctest.cap file that was working in the emulator in this zip.
Do you have any idea what could possibly cause this problem? Thank you!
This is the GPShell script:
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
Output in case of 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.)
Output in case of 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)
回答1:
It seems that your .cap file is not compatible with your card. You should check the following items :
1 : The version of Java Card Development Kit that you use for generating cap files must be lower than/equal with the version of Java Card that your card is compatible with.
2 : The Eclipse Compiler Compatible Level must be equal to 1.3
(I think this is mandatory for JC 2.2.1 and JC 2.2.2 only and not for the newer versions)
3 : Some features of Java Card APIs are optional. In cases that you use some optional features that your card not support them, applet uploading fails also. (Although the card JC version is equal to the JCDK you use) * BTW, this is not your problem,because your applet is not using any optional feature.
You can check the Compiler Compatible Level as follow :
Notes:
1- Please check section 2 first!
2- As you use Eclipse with Eclipse-JCDE plugin, and this plugin support JCDK 2.2.2 only, you may need this trick to check the JCDK 2.2.1 also.
回答2:
Use javacos software. It can generate cap file with both version 2.2.2. and 2.2.1
来源:https://stackoverflow.com/questions/29307756/eclipse-generated-cap-file-cannot-be-installed-on-javacard