gpt4 book ai didi

smartcard - 尝试选择 Applet 时收到 6E00

转载 作者:行者123 更新时间:2023-12-01 12:40:53 25 4
gpt4 key购买 nike

我创建了一个 this.cap 文件示例代码 [一个简单的 Hello World] 并通过 JCManager 成功将其上传到我的 javacard。

  • 包辅助:01 02 01 02 01 02 01

  • 小程序辅助:01 02 01 02 01 02 01 02

这是 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 3C 8A 0C 90 E4 5D 3B D9
<- 00 00 11 60 01 00 8A 79 0A F9 FF 02 00 A3 7F BB 51 31 B4 DE 16 9F 77 9E F7 49 1F EF 90 00
HostChallenge: 3C 8A 0C 90 E4 5D 3B D9
CardChallenge: 7F BB 51 31 B4 DE
Card Calculated Card Cryptogram: 16 9F 77 9E F7 49 1F EF
Derivation Data is 01 82 00 A3 00 00 00 00 00 00 00 00 00 00 00 00
Host Cryptogram Data (to encrypt) 00 A3 7F BB 51 31 B4 DE 3C 8A 0C 90 E4 5D 3B D9 80 00 00 00 00 00 00 00
Card Cryptogram Data (to encrypt for verification) 3C 8A 0C 90 E4 5D 3B D9 00 A3 7F BB 51 31 B4 DE 80 00 00 00 00 00 00 00
S_ENC: 69 1E A3 CB 6A 58 DD 17 BA 88 A8 4F 20 A7 35 30 69 1E A3 CB 6A 58 DD 17
The Current session MAC key is FB 23 0F 31 D7 6C AA 49 25 4C 7E E4 69 7E 1B 5B
The Current session DEK key is 8C C2 98 68 76 9C C1 90 21 CF 6B 42 A0 33 D1 D3
Encrypted CardCryptoGram is 93 24 10 54 22 E4 A0 B9 44 D1 D9 16 27 66 63 91 16 9F 77 9E F7 49 1F EF
Encrypted HostCryptoGram is E1 7D F6 51 0E 45 0F 6D 23 40 F3 E1 92 5F 8D 23 DB A2 05 4E FD 75 DD F0
-> 84 82 03 00 10 DB A2 05 4E FD 75 DD F0 D0 92 13 C0 0B 8C 31 74
<- 90 00
Authenticated
************
UplaodCAP
*************
Get AID from header.cap file
FOR LOAD DATA: EF 04 C6 02 01 B3
AID:01 02 01 02 01 02 01
Applet AID:01 02 01 02 01 02 01 02
Try to delete if existing...
-> 84 E4 00 00 18 A7 A8 54 56 4B 28 4F 80 5E 89 9F 26 61 3D E8 1D 88 D5 63 10 5F 51 ED AA
<- 6A 88
-> 84 E4 00 00 18 8E DD 49 5F EB 3D E7 E5 8B 39 83 9B 8E EA 74 77 69 CF 75 A8 55 C5 D4 BA
<- 6A 88
Loading cap file. Please wait...
Install for Load
-> 84 E6 02 00 20 10 44 CD 0E 2A 30 2C F8 B9 8A B3 6E 3D 01 5A A2 3A 8B 3D 8C 19 0F 09 AB DD 13 2A E5 27 BE 03 88
<- 00 90 00
Load CAP
-> 84 E8 00 00 D8 20 0F 77 44 1A 60 F7 61 57 82 15 9D 7F 19 6E 6C 73 13 6C F7 12 B0 CA FC 8E BF 61 68 F5 CF 74 4A D5 6D 25 B5 DE 70 5E 74 77 0B 16 E3 D9 C5 A4 25 DC 3C C4 07 80 D1 01 F2 12 87 A2 3C A1 FF 41 68 0C A6 70 2E 08 53 86 DF 9F 59 A2 DF 96 1A C9 4F CF F8 B3 15 05 A7 02 30 4C 8C 31 AE E2 B9 1A 98 10 63 0B 32 D7 96 70 2D 85 BD 40 69 9D 76 1A 06 91 39 E8 7D 68 C0 3F D7 45 AD 52 91 AB 16 EF 3D 34 E6 97 DF 54 4B EC A9 F2 2D 41 48 00 BC C7 7E F4 A2 6F 3A 10 38 52 12 16 22 DA D4 50 0F B4 3E 40 B8 CB 48 B1 B4 FE CE B7 A6 83 69 07 40 F3 66 18 08 45 08 CC 21 13 29 35 74 FA 8F 61 8F F0 6C 92 9E 94 5A CE 6A D0 68 95 25 A5 8A 0F 53 69 1E CF FF 86 57 67 DD 02 15
<- 00 90 00
-> 84 E8 00 01 D8 7B 56 34 47 73 D9 9F 19 35 20 5E 52 B6 FD 36 94 C9 E1 FB 69 BA D6 7D 15 65 C1 DB 41 33 04 57 E6 41 76 8B 77 4E DE BD 42 52 94 8F AA 6D 64 43 2B A5 C7 19 D8 F9 19 62 6A 27 40 C9 CF 38 63 D1 F0 CB B7 73 5A 63 F1 49 A1 62 F5 D7 7D 46 06 9D F0 0E 6E FA 44 46 37 EC 2D 17 3D D3 EC 87 C8 8F 8F 00 C7 DD 29 47 80 F7 55 FE A5 C0 02 C8 58 6B 62 E5 0C 15 1F 24 56 2F 64 2F E7 00 D7 0C 05 40 DD 6B 6D AD 14 F7 FA E0 E9 7E BA 11 87 15 0E D7 BD 99 9F 37 AF 38 C7 E2 91 2A 92 C2 12 0B C4 02 A7 BE CE C9 D1 48 E0 9C 1D 51 B0 F9 B1 3C 0F 73 9B DA 84 2B 90 09 1B 94 80 9B D8 76 6A 95 7E 04 90 34 4A C9 C8 F1 5B 16 8D 13 3C 14 DC FC A6 7F 49 B6 6B 81 B2 51 94 23 39
<- 00 90 00
-> 84 E8 80 02 28 2F 42 03 0A FC 19 2E 45 A8 86 73 F7 DA FE CA D0 F5 9A 5D F4 72 3E DF E3 89 31 52 56 C6 F9 29 D3 1C 42 ED 3C 7B 45 5A 51
<- 00 90 00
-> 84 E6 0C 00 30 10 44 CD 0E 2A 30 2C F8 7E D9 A5 69 72 B5 85 54 57 A7 0B 84 42 7F 21 45 69 25 9F 81 CC 96 C0 E8 10 37 64 61 8F 80 8E 29 67 B1 D7 81 D5 F8 EE 31
<- 00 90 00
Applet loaded & registered

这是我列出小程序时 GPJ 的输出:

C:\Users\thegooduser\Desktop\gpj-20120310>GPJ -list

C:\Users\thegooduser\Desktop\gpj-20120310>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 68 00 00 00 73 C8 40 12 00 90 00

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 93 6A 63 09 6D 3D 06 B2
DEBUG: Response APDU: 00 00 11 60 01 00 8A 79 0A F9 FF 02 00 A4 66 04 93 67 B8 9
3 F0 87 EB 95 AD DB 88 68 90 00
DEBUG: Command APDU: 84 82 00 00 10 C2 5A 5C D3 CB F3 DE 73 6E 2E 29 B2 73 DC A
2 06
DEBUG: Response APDU: 90 00
DEBUG: Command APDU: 84 82 00 00 08 C2 5A 5C D3 CB F3 DE 73
DEBUG: Response APDU: 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: 0B 01 02 03 04 05 06 07 08 09 01 01 07 00 07 D2 76 00 00 6
0 41 01 07 00 08 01 02 01 02 01 02 01 02 07 00 90 00
DEBUG: Command APDU: 80 F2 40 00 02 4F 00
DEBUG: Response APDU: 0B 01 02 03 04 05 06 07 08 09 01 01 07 00 07 D2 76 00 00 6
0 41 01 07 00 08 01 02 01 02 01 02 01 02 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: 0A 01 02 03 04 05 06 07 08 09 01 01 00 07 D2 76 00 00 60 5
0 01 01 00 07 01 02 01 02 01 02 01 01 00 90 00
DEBUG: Command APDU: 80 F2 20 00 02 4F 00
DEBUG: Response APDU: 0A 01 02 03 04 05 06 07 08 09 01 01 00 07 D2 76 00 00 60 5
0 01 01 00 07 01 02 01 02 01 02 01 01 00 90 00
AID: A0 00 00 00 03 00 00 00 |........| ISD LC: 1 P
R: 0x9E

AID: 01 02 03 04 05 06 07 08 09 01 01 |...........| App LC: 7 P
R: 0x00

AID: D2 76 00 00 60 41 01 |.v..`A.| App LC: 7 P
R: 0x00

AID: 01 02 01 02 01 02 01 02 |........| App LC: 7 P
R: 0x00

AID: 01 02 03 04 05 06 07 08 09 01 |..........| Exe LC: 1 P
R: 0x00

AID: D2 76 00 00 60 50 01 |.v..`P.| Exe LC: 1 P
R: 0x00

AID: 01 02 01 02 01 02 01 |.......| Exe LC: 1 P
R: 0x00

如您所见,我的小程序已成功上传。但是当我尝试使用 Opensc 工具选择它时,我收到了 6E00。为什么?

更新:当我在字节类中发送带有 8000 的选择命令时,这是 opensc-tool 输出

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 00a404000801
02010201020102
Using reader with a card: ACS CCID USB Reader 0
Sending: 00 A4 04 00 08 01 02 01 02 01 02 01 02
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 00a404000701
020102010201
Using reader with a card: ACS CCID USB Reader 0
Sending: 00 A4 04 00 07 01 02 01 02 01 02 01
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 80a404000801
02010201020102
Using reader with a card: ACS CCID USB Reader 0
Sending: 80 A4 04 00 08 01 02 01 02 01 02 01 02
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 80a404000701
020102010201
Using reader with a card: ACS CCID USB Reader 0
Sending: 80 A4 04 00 07 01 02 01 02 01 02 01
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>

更新2:如下图,我可以成功选择其他小程序:

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 00a404000b01
02030405060708090101
Using reader with a card: ACS CCID USB Reader 0
Sending: 00 A4 04 00 0B 01 02 03 04 05 06 07 08 09 01 01
Received (SW1=0x90, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -s 00a404000a01
020304050607080901
Using reader with a card: ACS CCID USB Reader 0
Sending: 00 A4 04 00 0A 01 02 03 04 05 06 07 08 09 01
Received (SW1=0x90, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>

这是我的智能卡工厂工具的输出:

Answer-to-Reset
3B 68 00 00 00 73 C8 40 12 00 90 00
< 00 A4 04 00 00 00
> 6112

< 00 C0 00 00 00 12
> 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF
> 9000

< 00 A4 04 00 08 00
< 01 02 01 02 01 02 01 02
> 6E00

< 00 A4 04 00 07 00
< 01 02 01 02 01 02 01
> 6E00

更新 3:在 ATR 之后立即发送选择小程序 APDU 命令:

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -a -s 80a404000
80102010201020102
Using reader with a card: ACS CCID USB Reader 0
3b:68:00:00:00:73:c8:40:12:00:90:00
Sending: 80 A4 04 00 08 01 02 01 02 01 02 01 02
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -a -s 80a404000
701020102010201
Using reader with a card: ACS CCID USB Reader 0
3b:68:00:00:00:73:c8:40:12:00:90:00
Sending: 80 A4 04 00 07 01 02 01 02 01 02 01
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -a -s 00a404000
80102010201020102
Using reader with a card: ACS CCID USB Reader 0
3b:68:00:00:00:73:c8:40:12:00:90:00
Sending: 00 A4 04 00 08 01 02 01 02 01 02 01 02
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>opensc-tool -a -s 00a404000
701020102010201
Using reader with a card: ACS CCID USB Reader 0
3b:68:00:00:00:73:c8:40:12:00:90:00
Sending: 00 A4 04 00 07 01 02 01 02 01 02 01
Received (SW1=0x6E, SW2=0x00)

C:\Users\ghasemi\Desktop\OpenSC Project\OpenSC\tools>

最佳答案

您收到错误代码6E00的原因是您的小程序在收到 SELECT (by DF name/AID) 命令时发送了它:

ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);

当您的小程序收到其初始选择命令时,将调用 process() 方法。由于此 SELECT 命令的类是 0x00,分支

if (cmd_apdu[ISO7816.OFFSET_CLA] == CLASS) {
...
}

将不会被执行,而是 else 分支将抛出该异常并因此导致返回错误代码 6E00

请注意 Anurag Sharma将 SELECT 命令的 CLA 字节更改为 0x80 的建议通常不会起作用,因为 Java Card 运行时环境通常不会将带有专有标志集的 SELECT 命令视为小程序选择命令。

因此您应该在您的process() 方法中正确处理小程序选择命令以避免错误响应。例如,您可以通过检查 selectingApplet() 来做到这一点:

public void process(APDU apdu) {
byte[] cmd_apdu = apdu.getBuffer();

if (selectingApplet()) return;

[...]

然而,根据 JCRE 规范,applet 选择导致该错误应该不是问题。即使 SELECT 命令返回了那个错误,applet 也应该被选中并且应该接受 READ 命令:

80 02 00 00 13

关于smartcard - 尝试选择 Applet 时收到 6E00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24904389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com