在智能卡上上传 .cap 文件?

Posted

技术标签:

【中文标题】在智能卡上上传 .cap 文件?【英文标题】:Upload a .cap file on Smart Card? 【发布时间】:2014-05-15 06:00:51 【问题描述】:

我有一张新卡,其 ATR 为以下代码。

3B 68 00 00 00 73 C8 40 12 00 90 00

我在谷歌上搜索了这张 ATR,最后我知道这是一张“巴西 e-CPF 卡”。 问题是我如何使用这张卡?我的意思是它支持哪些 APDU?有数据表吗?是javacard吗? [如果是] 我如何在其中上传 .cap 文件?它有任何默认密钥吗? 还有很多这样的问题。

主要的问题是:我可以从 ATR 中获得什么样的数据?

顺便说一句,我使用 ACR38 智能卡读卡器。我在 Eclipse 中创建了一个 .cap javacard 程序。

下一个问题: 我使用 GPJ.bat 在这张卡上部署(上传)一个 .cap 文件。 [流行的HelloWorld程序的Eclipse制作的.cap文件及其源代码在这里:http://umer555.wordpress.com/2012/05/17/java-card-hello-world-applet/]

输出如下。上传有什么问题?以及整个过程!

E:\gpj>gpj -load e:\helloworld.cap -install

E:\gpj>java -jar gpj.jar -load e:\helloworld.cap -install
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 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 34 F8 63 3E E3 BC 64 94
DEBUG: Response APDU: 00 00 11 60 01 00 7F 8B 0A F9 FF 02 00 01 6C 7F FC 11 3F B
9 3F 17 B8 84 02 AA C1 F0 90 00
DEBUG: Command  APDU: 84 82 00 00 10 08 EA 79 CD BA 32 F3 1C 69 1B 83 42 CD AA F
E 42
DEBUG: Response APDU: 90 00
DEBUG: Command  APDU: 84 82 00 00 08 08 EA 79 CD BA 32 F3 1C
DEBUG: Response APDU: 90 00
DEBUG: packagePath: helloWorld/javacard/
DEBUG: package: helloWorld
DEBUG: package AID: 01 02 03 04 05 06 07 08 09 00
DEBUG: applet AIDs: [01 02 03 04 05 06 07 08 09 00 00 ]
DEBUG: Command  APDU: 80 E6 02 00 17 0A 01 02 03 04 05 06 07 08 09 00 08 A0 00 0
0 00 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E6 02 00 17 0A 01 02 03 04 05 06 07 08 09 00 08 A0 00 0
0 00 03 00 00 00 00 00 00
DEBUG: Response APDU: 00 90 00
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 01 63 01 00 1F DE CA FF ED 02 02 06 0
0 01 0A 01 02 03 04 05 06 07 08 09 00 0A 68 65 6C 6C 6F 57 6F 72 6C 64 02 00 21
00 1F 00 21 00 0F 00 2A 00 22 00 5A 00 35 00 0A 00 0C 00 05 00 AA 00 00 00 00 00
 00 00 00 04 01 00 04 00 2A 04 00 01 07 A0 00 00 00 62 00 01 00 01 07 A0 00 00 0
0 62 00 03 03 01 07 A0 00 00 00 62 01 01 00 01 08 A0 00 00 00 62 01 01 01 03 00
0F 01 0B 01 02 03 04 05 06 07 08 09 00 00 00 13 06 00 5A 00 00 A1 81 00 0C 48 65
 6C 6C 6F 57 6F 72 6C 64 52 49 C1 82 02 22 83 05 00 FF 00 01 00 00 00 81 00 00 0
0 02 00 00 00 10 48 65 6C 6C 6F 57 6F 72 6C 64 52 49 49 6D 70 6C 01 00 02 00 82
03 00 FF 00 07 01 00 00 00 1C 42 80 00 00 FF 00 01 01 00 00 00 31 82 02 00 00 12
 01 01 07 00 35 00 01 10 18 8C 00 00 7A 01 10 18 8C 00 01 18 8B 00 02 7A 01 30 8
F
DEBUG: Response APDU: 69 85
DEBUG: Command  APDU: 80 E8 00 00 FF C4 82 01 63 01 00 1F DE CA FF ED 02 02 06 0
0 01 0A 01 02 03 04 05 06 07 08 09 00 0A 68 65 6C 6C 6F 57 6F 72 6C 64 02 00 21
00 1F 00 21 00 0F 00 2A 00 22 00 5A 00 35 00 0A 00 0C 00 05 00 AA 00 00 00 00 00
 00 00 00 04 01 00 04 00 2A 04 00 01 07 A0 00 00 00 62 00 01 00 01 07 A0 00 00 0
0 62 00 03 03 01 07 A0 00 00 00 62 01 01 00 01 08 A0 00 00 00 62 01 01 01 03 00
0F 01 0B 01 02 03 04 05 06 07 08 09 00 00 00 13 06 00 5A 00 00 A1 81 00 0C 48 65
 6C 6C 6F 57 6F 72 6C 64 52 49 C1 82 02 22 83 05 00 FF 00 01 00 00 00 81 00 00 0
0 02 00 00 00 10 48 65 6C 6C 6F 57 6F 72 6C 64 52 49 49 6D 70 6C 01 00 02 00 82
03 00 FF 00 07 01 00 00 00 1C 42 80 00 00 FF 00 01 01 00 00 00 31 82 02 00 00 12
 01 01 07 00 35 00 01 10 18 8C 00 00 7A 01 10 18 8C 00 01 18 8B 00 02 7A 01 30 8
F
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)

【问题讨论】:

【参考方案1】:

ATR 通常不会提供有关卡片的太多有用信息。从 APDU 跟踪您可以看到该卡符合 GlobalPlatform 并且其发行者安全域 OPEN 可通过 AID A0 00 00 00 03 00 00 00 访问(这可能——但不一定如此——表示 JCOP 卡)。

选择 AID 后,GPJ 执行成功的身份验证序列(INITIALIZE UPDATE 后跟 EXTERNAL AUTHENTICATE)。这表明您可以使用您配置 GPJ 的任何密钥集访问该卡(或者它是否使用某些默认密钥?)。

然后,在成功验证后,GPJ 会尝试安装那个 helloworld Java Card 小程序。 INSTALL 命令成功,而加载实际应用程序代码包失败。这可能有几个原因。最常见的一种(假设卡是 Java 卡)是小程序针对卡所支持的不同 Java Card API 进行编译。在这种情况下,您需要为正确的 Java Card 平台版本重新编译小程序。

【讨论】:

以上是关于在智能卡上上传 .cap 文件?的主要内容,如果未能解决你的问题,请参考以下文章

无法将小程序(.cap 文件)下载到智能卡中:SW 6D 00(无效指令)

在智能手机上检测 Caps On

java卡小程序部署详细视图

参加2018之江杯全球人工智能大赛 :视频识别&问答

蓝牙-b

2021-11-04 WPF上位机 72-智能停车场项目专题-文件上传功能实现