java - 将 applet 安装到 java 卡的 APDU 命令顺序是什么?

标签 java smartcard javacard globalplatform

我有一个 .CAP 文件 (applet),我想将它安装到我的 java 卡上。 我知道我可以使用 GPSshell 或 apdutool(来自 JCDK)等工具来执行此操作,但我想自己复制安装过程。

令人困惑的是,在 GP 标准中,安装过程是:APDU 命令 INSTALL[for load] 后跟多个 LOAD 命令,然后是 INSTALL[for install] 命令。

虽然 oracle 文档建议使用不同的 APDU 命令序列来安装 .CAP 文件:选择(发行者安全域?)、CAP 开始、组件 ## Begin+Data+End(对于每个组件)、CAP 结束、创建小程序。

这两种安装小程序的方法是否等同?

LOAD 命令的 DATA 字段包含什么? GP 标准没有具体说明,我知道从 .CAP 文件发送原始字节是错误的。 我使用 GPSshell 成功安装了小程序,但 LOAD 命令的 DATA 字段对我来说毫无意义。 GPShell output

对于 oracle 方法,我使用 Java Card Developement Kit 中的 scriptgen 来生成 APDU 命令,但是这些命令(B0、B2、B4、BC、BA)中的 INS 字节没有 GP 引用。 scriptgen output

最佳答案

While the oracle documentation proposes a different sequence of APDU commands for installing the .CAP file: Select( Issuer Security Domain? ) , CAP begin, Component ## Begin+Data+End ( for each component ), CAP End, Create Applet.

在安装 applet 之前需要选择卡管理器(发行者安全域 - Root),因为它负责在卡上加载和安装 applet。另请注意,您需要通过建立安全通道(最好是 SCP02)向卡管理器进行身份验证。

执行以下 APDU 序列来安装小程序:-

  1. 选择颁发者安全域 (ISD)。 00 a4 04 00 Lc AID_ISD

  2. 使用 ISD 进行身份验证。

    设置 SCP02(引用命令初始化更新,外部验证)。 在这里,您将需要卡的 3DES key 。引用文档 随卡提供。

  3. 发送 apdu,安装 [for Load]。

The confusing thing is that in the GP standard the installation process is : APDU command INSTALL[for load] followed by multiple LOAD commands followed by INSTALL[for install] command.

  1. 发送 apdu,加载 block 。

    .cap 您将拥有的小程序文件是其组成 CAP 的 zip 文件(http://pfa12.free.fr/doc_java/javacard_specifications/specs/jcvm/html/JCVM06cap.html)。因此,您需要将每个 CAP 文件一个一个地发送到卡中。

    加载(Header.cap)、加载(Directory.cap)...等

  2. 发送 apdu,安装 [for Install]。安装完成。

关于java - 将 applet 安装到 java 卡的 APDU 命令顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46296789/

相关文章:

java - 浏览器中的 PIV 智能卡如何在没有小程序的情况下进行身份验证

Java 卡 检测到与智能卡的通信错误

cryptography - Java Card 中没有 AES 密码的填充

java - ArrayList/ObservableList/List 与一般类和接口(interface)之间的关系

java - RabbitMQ 服务器 bundle 分发 : Maven pom configuration

java - 如何有效地批量更新 SQLite 中项目的标签列表?

java - Hibernate,使用createNativeQuery方法时出现错误

linux - 关于智能卡安装

java - 如何从 Java Card 2.2.2 SIM 卡小程序启动具有特定 URL 的浏览器?

android - 在 Android 手机中使用 SIM 卡槽作为智能卡读卡器