1

我在 JavaCard 上加载样本(JavaPurse、HelloWorld)的 CAP 文件时遇到了一些问题,响应 APDU:69 85。我同时使用了 GPJ 和 jcManager,但没有运气。

这是 GPJ 的踪迹:

C:\java_card_kit-2_2_2\gpj-20120310>"..\..\Program Files\Java\jre6\bin\java.exe" -jar gpj.jar -load ..\samples\classes\com\sun\javacard\samples\JavaPurse\javacard\JavaPurse.cap -install -list
Found terminals: [PC/SC terminal Gemplus USB SmartCard Reader 0]
Found card in terminal: Gemplus USB SmartCard Reader 0
ATR: 3B 68 00 00 00 73 C8 40 12 00 90 00
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: 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 0
0
Successfully selected Security Domain OP201a A0 00 00 00 03 00 00 00
DEBUG: Command  APDU: 80 50 00 00 08 26 5F FC 46 75 E5 13 62
DEBUG: Response APDU: 00 00 02 52 01 00 93 6E 1C 88 FF 02 00 2C BE 39 5E A5 07 5
5 53 1D 65 EB A7 49 56 87 90 00
DEBUG: Command  APDU: 84 82 00 00 10 6C B2 42 6D 2D 6C D2 34 45 F0 8C 8F A5 7B D
4 14
DEBUG: Response APDU: 90 00
DEBUG: Command  APDU: 84 82 00 00 08 6C B2 42 6D 2D 6C D2 34
DEBUG: Response APDU: 90 00
DEBUG: packagePath: com/sun/javacard/samples/JavaPurse/javacard/
DEBUG: package: com.sun.javacard.samples.JavaPurse
DEBUG: package AID: A0 00 00 00 62 03 01 0C 02
DEBUG: applet AIDs: [A0 00 00 00 62 03 01 0C 02 01 ]
DEBUG: Command  APDU: 80 E6 02 00 16 09 A0 00 00 00 62 03 01 0C 02 08 A0 00 00 0
0 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E6 02 00 16 09 A0 00 00 00 62 03 01 0C 02 08 A0 00 00 0
0 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 0E 20 01 00 13 DE CA FF ED 01 02 04 0
0 01 09 A0 00 00 00 62 03 01 0C 02 02 00 1F 00 13 00 1F 00 0E 00 21 01 72 00 40
0A 6E 00 10 01 74 00 00 03 84 00 02 00 01 00 03 03 01 00 04 00 21 03 00 01 07 A0
 00 00 00 62 00 01 03 01 07 A0 00 00 00 62 01 01 00 01 09 A0 00 00 00 62 03 01 0
C 04 03 00 0E 01 0A A0 00 00 00 62 03 01 0C 02 01 00 CA 06 00 40 00 80 00 04 00
01 01 00 00 04 00 37 00 63 00 95 00 A1 00 81 03 10 00 0D 04 04 00 00 01 94 FF FF
 FF FF 01 A1 00 80 00 02 00 01 01 04 00 00 09 E7 09 EC 0A 12 0A 27 00 80 00 01 0
0 01 01 00 00 00 07 0A 6E 00 05 31 18 8C 00 20 18 02 88 00 18 1D 04 41 5B 30 1D
88 01 18 AE 01 91 00 1B 87 02 03 32 1F AE 01 6D 15 AD 02 1F 8F 00 1B 3D 1E 8C 00
 17 37 1F 04 41 5B 32 70 EA 7A 03 20 1D 04 6C 0A 1D AE 01 04 43 5B 6F 08 11 6A 8
3
DEBUG: Response APDU: 69 85
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 0E 20 01 00 13 DE CA FF ED 01 02 04 0
0 01 09 A0 00 00 00 62 03 01 0C 02 02 00 1F 00 13 00 1F 00 0E 00 21 01 72 00 40
0A 6E 00 10 01 74 00 00 03 84 00 02 00 01 00 03 03 01 00 04 00 21 03 00 01 07 A0
 00 00 00 62 00 01 03 01 07 A0 00 00 00 62 01 01 00 01 09 A0 00 00 00 62 03 01 0
C 04 03 00 0E 01 0A A0 00 00 00 62 03 01 0C 02 01 00 CA 06 00 40 00 80 00 04 00
01 01 00 00 04 00 37 00 63 00 95 00 A1 00 81 03 10 00 0D 04 04 00 00 01 94 FF FF
 FF FF 01 A1 00 80 00 02 00 01 01 04 00 00 09 E7 09 EC 0A 12 0A 27 00 80 00 01 0
0 01 01 00 00 00 07 0A 6E 00 05 31 18 8C 00 20 18 02 88 00 18 1D 04 41 5B 30 1D
88 01 18 AE 01 91 00 1B 87 02 03 32 1F AE 01 6D 15 AD 02 1F 8F 00 1B 3D 1E 8C 00
 17 37 1F 04 41 5B 32 70 EA 7A 03 20 1D 04 6C 0A 1D AE 01 04 43 5B 6F 08 11 6A 8
3
DEBUG: Response APDU: 69 85
net.sourceforge.gpj.cardservices.exceptions.GPLoadException: Load failed, SW: 69     85
        at net.sourceforge.gpj.cardservices.GlobalPlatformService.loadCapFile(Un    known Source)
        at net.sourceforge.gpj.cardservices.GlobalPlatformService.main(Unknown S    ource)

来自 jcManager 的跟踪:

Open terminal ...
EstablishContext(): ...
Wait for card in a certain reader ...
Pick reader ...
**********************
Selecting Card Manager
***********************
-> 00 A4 04 00 08 A0 00 00 00 03 00 00 00
<- 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 00
************
Init Update
*************
-> 80 50 00 00 08 21 0E BF 30 95 AD B3 31
<- 00 00 02 52 01 00 93 6E 1C 88 FF 02 00 29 44 06 FE 6A F1 4F 45 24 65 22 CB D6 88 F8 90 00
HostChallenge: 21 0E BF 30 95 AD B3 31
CardChallenge: 44 06 FE 6A F1 4F
Card Calculated Card Cryptogram: 45 24 65 22 CB D6 88 F8
Derivation Data is 01 82 00 29 00 00 00 00 00 00 00 00 00 00 00 00
Host Cryptogram Data (to encrypt) 00 29 44 06 FE 6A F1 4F 21 0E BF 30 95 AD B3 31 80 00 00 00 00 00 00 00
Card Cryptogram Data (to encrypt for verification) 21 0E BF 30 95 AD B3 31 00 29 44 06 FE 6A F1 4F 80 00 00 00 00 00 00 00
S_ENC: A6 A3 71 6D C7 49 BD 71 7E 4D E9 A4 19 B6 D9 42 A6 A3 71 6D C7 49 BD 71
The Current session MAC key is FC FB E2 6E 84 98 E6 C4 C3 8E 91 87 D6 E5 EB C9
The Current session DEK key is EA 3E AF C5 2A 29 6D 41 7B D1 85 5B F1 05 06 11
Encrypted CardCryptoGram is 48 C6 AA EA 70 9E BE F2 14 F5 1C D9 9A 37 AE 57 45 24 65 22 CB D6 88 F8
Encrypted HostCryptoGram is 80 40 92 C0 B7 6A 6E E0 9B D4 79 7D 95 62 36 15 45 31 AE 05 91 86 9B CE
-> 84 82 03 00 10 45 31 AE 05 91 86 9B CE 3B EA 06 63 1C 2E E7 CF
<- 90 00
Authenticated
SCP: 02
Installed applets: 
-> 84 F2 40 00 10 11 43 31 AA 2D DA 03 A8 4D E7 6A 35 3D 27 C8 B0
<- 6A 88
Installed packages: 
-> 84 F2 20 00 10 11 43 31 AA 2D DA 03 A8 A5 D2 14 32 03 20 DE D9
<- 6A 88

...

+==========================+
set JC_HOME=C:\java_card_kit-2_2_2;
set JAVA_HOME=C:\jdk1.5.0;
set ANT_HOME=C:\ant-1.6.2;
set PATH=.;%JC_HOME%\bin;%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%
+==========================+
4

1 回答 1

1

事实证明,Java Card 平台与卡 API 不兼容。在我使用 JC Kit 2.1.2 之后,一切都运行成功。

这是 2.1.2 的输出:

C:\java_card_kit-2_2_2\gpj-20120310>"..\..\Program Files\Java\jre6\bin\java.exe"
 -jar gpj.jar -load ..\..\java_card_kit-2_1_2\samples\classes\com\sun\javacard\s
amples\HelloWorld\javacard\HelloWorld.cap -install -list
Found terminals: [PC/SC terminal Gemplus USB SmartCard Reader 0]
Found card in terminal: Gemplus USB SmartCard Reader 0
ATR: 3B 68 00 00 00 73 C8 40 12 00 90 00
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: 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 0
0
Successfully selected Security Domain OP201a A0 00 00 00 03 00 00 00
DEBUG: Command  APDU: 80 50 00 00 08 ED EE 43 71 00 3E 3E 05
DEBUG: Response APDU: 00 00 02 52 01 00 93 6E 1C 88 FF 02 00 2F A8 4D 11 9E 3A 4
0 ED 82 60 B0 FF 7B 3A 08 90 00
DEBUG: Command  APDU: 84 82 00 00 10 08 16 C4 F5 58 F2 46 73 FE 9F C5 2C 35 C1 3
C E0
DEBUG: Response APDU: 90 00
DEBUG: Command  APDU: 84 82 00 00 08 08 16 C4 F5 58 F2 46 73
DEBUG: Response APDU: 90 00
DEBUG: packagePath: com/sun/javacard/samples/HelloWorld/javacard/
DEBUG: package: com.sun.javacard.samples.HelloWorld
DEBUG: package AID: A0 00 00 00 62 03 01 0C 01
DEBUG: applet AIDs: [A0 00 00 00 62 03 01 0C 01 01 ]
DEBUG: Command  APDU: 80 E6 02 00 16 09 A0 00 00 00 62 03 01 0C 01 08 A0 00 00 0
0 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E6 02 00 16 09 A0 00 00 00 62 03 01 0C 01 08 A0 00 00 0
0 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 01 2C 01 00 13 DE CA FF ED 01 02 04 0
0 01 09 A0 00 00 00 62 03 01 0C 01 02 00 1F 00 13 00 1F 00 0E 00 0B 00 36 00 0C
00 67 00 0A 00 13 00 00 00 6C 00 00 00 00 00 00 01 01 00 04 00 0B 01 00 01 07 A0
 00 00 00 62 01 01 03 00 0E 01 0A A0 00 00 00 62 03 01 0C 01 01 00 14 06 00 0C 0
0 80 03 01 00 01 07 01 00 00 00 1F 07 00 67 00 02 10 18 8C 00 01 18 11 01 00 90
0B 87 00 18 8B 00 02 7A 02 30 8F 00 03 3D 8C 00 04 3B 7A 05 23 19 8B 00 05 2D 19
 8B 00 06 32 03 29 04 70 19 1A 08 AD 00 16 04 1F 8D 00 0B 3B 16 04 1F 41 29 04 1
9 08 8B 00 0C 32 1F 64 E8 19 8B 00 07 3B 19 16 04 08 41 8B 00 08 19 03 08 8B 00
09 19 AD 00 03 16 04 8B 00 0A 7A 08 00 0A 00 00 00 00 00 00 00 00 00 00 05 00 36
 00 0D 02 00 00 00 06 80 03 00 03 80 03 01 01 00 00 00 06 00 00 01 03 80 0A 01 0
3
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 01 2C 01 00 13 DE CA FF ED 01 02 04 0
0 01 09 A0 00 00 00 62 03 01 0C 01 02 00 1F 00 13 00 1F 00 0E 00 0B 00 36 00 0C
00 67 00 0A 00 13 00 00 00 6C 00 00 00 00 00 00 01 01 00 04 00 0B 01 00 01 07 A0
 00 00 00 62 01 01 03 00 0E 01 0A A0 00 00 00 62 03 01 0C 01 01 00 14 06 00 0C 0
0 80 03 01 00 01 07 01 00 00 00 1F 07 00 67 00 02 10 18 8C 00 01 18 11 01 00 90
0B 87 00 18 8B 00 02 7A 02 30 8F 00 03 3D 8C 00 04 3B 7A 05 23 19 8B 00 05 2D 19
 8B 00 06 32 03 29 04 70 19 1A 08 AD 00 16 04 1F 8D 00 0B 3B 16 04 1F 41 29 04 1
9 08 8B 00 0C 32 1F 64 E8 19 8B 00 07 3B 19 16 04 08 41 8B 00 08 19 03 08 8B 00
09 19 AD 00 03 16 04 8B 00 0A 7A 08 00 0A 00 00 00 00 00 00 00 00 00 00 05 00 36
 00 0D 02 00 00 00 06 80 03 00 03 80 03 01 01 00 00 00 06 00 00 01 03 80 0A 01 0
3
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 80 01 31 80 0A 06 03 80 0A 07 03 80 0A 09 03 80 0A 0
4 03 80 0A 05 06 80 10 02 03 80 0A 03 09 00 13 00 03 0E 25 2C 00 0C 05 0C 06 04
08 05 10 0C 08 09 06 09
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 80 01 31 80 0A 06 03 80 0A 07 03 80 0A 09 03 80 0A 0
4 03 80 0A 05 06 80 10 02 03 80 0A 03 09 00 13 00 03 0E 25 2C 00 0C 05 0C 06 04
08 05 10 0C 08 09 06 09
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E6 0C 00 26 09 A0 00 00 00 62 03 01 0C 01 0A A0 00 00 0
0 62 03 01 0C 01 01 0A A0 00 00 00 62 03 01 0C 01 01 01 00 02 C9 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E6 0C 00 26 09 A0 00 00 00 62 03 01 0C 01 0A A0 00 00 0
0 62 03 01 0C 01 01 0A A0 00 00 00 62 03 01 0C 01 01 01 00 02 C9 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 F2 80 00 02 4F 00
DEBUG: Response APDU: 08 A0 00 00 00 03 00 00 00 01 9E 90 00
DEBUG: Command  APDU: 80 F2 80 00 02 4F 00
DEBUG: Response APDU: 08 A0 00 00 00 03 00 00 00 01 9E 90 00
DEBUG: Command  APDU: 80 F2 40 00 02 4F 00
DEBUG: Response APDU: 0A A0 00 00 00 62 03 01 0C 01 01 07 00 90 00
DEBUG: Command  APDU: 80 F2 40 00 02 4F 00
DEBUG: Response APDU: 0A A0 00 00 00 62 03 01 0C 01 01 07 00 90 00
DEBUG: Command  APDU: 80 F2 10 00 02 4F 00
DEBUG: Response APDU: 6A 81
DEBUG: Command  APDU: 80 F2 10 00 02 4F 00
DEBUG: Response APDU: 6A 81
DEBUG: Command  APDU: 80 F2 20 00 02 4F 00
DEBUG: Response APDU: 09 A0 00 00 00 62 03 01 0C 01 01 00 90 00
DEBUG: Command  APDU: 80 F2 20 00 02 4F 00
DEBUG: Response APDU: 09 A0 00 00 00 62 03 01 0C 01 01 00 90 00
AID: A0 00 00 00 03 00 00 00                       |........|        ISD LC: 1 P
R: 0x9E

AID: A0 00 00 00 62 03 01 0C 01 01                 |....b.....|      App LC: 7 P
R: 0x00

AID: A0 00 00 00 62 03 01 0C 01                    |....b....|       Exe LC: 1 P
R: 0x00
于 2014-11-07T14:19:37.373 回答