如何使用 Visual C++/PCSC 以编程方式加载 Java 卡小程序(.cap 文件)

发布于 2024-09-25 06:40:26 字数 151 浏览 3 评论 0原文

我目前正在进行的一个项目需要我将 JavaCard 应用程序 Applet(.cap)文件加载到 JavaCard。我们的框架基于Visual C++和PCSC,因此我们需要将相同的applet加载到一系列JavaCard上。有谁知道如何处理这个问题?我的意思是,我应该从哪里开始。谢谢!

I am currentlly on a project that requires me to load a JavaCard application Applet ( a .cap ) file to a JavaCard. Our framework is based on Visual C++ and PCSC, so we need to load the same applet to a series of JavaCards. Does anyone know how this can be processed? I mean, where should I start. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初吻给了烟 2024-10-02 06:40:26

你是对的,这不是一项微不足道的工作。

不同的 javacard 之间存在差异,但通常您需要做 4 件事:

  • 初始化与卡的安全通信(因为许多 javacard 是“全球平台”卡,它们需要安全通道)
  • 发送一条命令说“我想安装一个小程序”
  • 发送要安装的小程序的二进制数据
  • 在发送二进制数据后发送一个命令来“实例化”小程序

我建议最初使用 eclipse 插件安装小程序,因为您可以看到插件生成的 APDU上述步骤。一旦您知道安装小程序必须发送的 APDU 命令,您就可以使用 C++ 代码中的 PCSC 接口直接发送这些命令,以在大量卡上自动安装。

我的公司制作了一个名为 Card Boss 的网络浏览器插件,用于从浏览器执行此类操作(通过 pcsc 进行卡通信) - 您可以使用一个网页,在其中输入您自己的 APDU 并将其发送到位于以下 URL 的卡上:

https://cardboss.cometway.com/content.agent?page_name=Card+Boss+Lab

如果您使用我们的工具,您的小程序安装脚本应如下所示(请注意,这是使用默认 jcop 密钥的 JCOP 卡的脚本)

    MESSAGE BOX Installing applets...

    INIT CHANNEL 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f, 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

    // INSTALL CAP: 
    SEND 80 E6 02 00 1D 10 A0 00 00 00 09 00 03 FF FF FF FF 89 10 71 00 01 08 A0 00 00 00 03 00 00 00 00 00 00 

    // LOADING CAP: 
    SEND 80 E8 00 00 FA C4 82 01 03 01 00 25 DE CA FF (snip, I removed a bunch 
of binary data representing the cap file to shorten this post, and you might
need multiple SEND commands because of limits on the size of APDUS)

    // INSTANTIATING Applet
    SEND 80 E6 0C 00 1E 05 63 6F 6D 65 74 07 63 6F 6D 65 74 00 01 05 00 00 00 00 00 01 00 06 C9 04 68 2C 00 03 00 00 

You are correct that this is not a trivial job.

There are differences between different javacards, but generally you need to do 4 things:

  • initialize secure communications with the card (because many javacards are "global platform" cards they require a secure channel)
  • send a command saying "i wanna install an applet"
  • send the binary data for the applet to be installed
  • send a command to "instantiate" the applet after the binary data is sent

I'd recommend using the eclipse plugin to install the applet initially, because you can see the APDUs generated by the plugin to do the steps above. Once you know the APDU commands you must send to install your applet, you can directly send these commands using the PCSC interface from your C++ code to automate installation on a large number of cards.

My company makes a web browser plugin called Card Boss for doing this kind of thing (card communications via pcsc) from a browser - there's a web page you can use where you can type your own APDUs and send them to the card at the follwing URL:

https://cardboss.cometway.com/content.agent?page_name=Card+Boss+Lab

If you use our tool, your applet installation script should look something like this (note that this is a script for a JCOP card using the default jcop keys)

    MESSAGE BOX Installing applets...

    INIT CHANNEL 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f, 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f

    // INSTALL CAP: 
    SEND 80 E6 02 00 1D 10 A0 00 00 00 09 00 03 FF FF FF FF 89 10 71 00 01 08 A0 00 00 00 03 00 00 00 00 00 00 

    // LOADING CAP: 
    SEND 80 E8 00 00 FA C4 82 01 03 01 00 25 DE CA FF (snip, I removed a bunch 
of binary data representing the cap file to shorten this post, and you might
need multiple SEND commands because of limits on the size of APDUS)

    // INSTANTIATING Applet
    SEND 80 E6 0C 00 1E 05 63 6F 6D 65 74 07 63 6F 6D 65 74 00 01 05 00 00 00 00 00 01 00 06 C9 04 68 2C 00 03 00 00 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文