是否可以查询 GlobalPlatform 智能卡的剩余持久内存?

发布于 2024-11-26 23:54:23 字数 116 浏览 1 评论 0原文

我有一个 JavaCard,可以调用 JCSystem.getAvailableMemory(MEMORY_TYPE_PERSISTENT) 并从我的小程序返回该值,但如果它超过 32767 字节,我想要一个准确的值。

I have a JavaCard and can call JCSystem.getAvailableMemory(MEMORY_TYPE_PERSISTENT) and return that from my applet, but I want an exact value if its over 32767 bytes.

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

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

发布评论

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

评论(2

若言繁花未落 2024-12-03 23:54:23

支持 GP 2.2 + ETSI 的 Javacard

如果您的卡支持 Global Platform 2.2 和 ETSI,您可以使用 GET DATA 命令。

GP 卡规范 2.2 第 11.3 节规定,

Tag ‘FF21’: Extended Card Resources Information available for Card Content Management, as defined in ETSI TS 102 226.

并且在 ETSI 102.226 第 8.2.1.7.2 节中:

成功执行命令后,GET DATA 响应数据字段应按照 GlobalPlatform [4] 中的定义进行编码。命令消息的参考控制参数P1和P2中引用的TLV编码数据对象的值为:

Length Description                            Value
  1    Number of installed application tag    '81'
  1    Number of installed application length  X
  X    Number of installed application
  1    Free non volatile memory tag           '82'
  1    Free non volatile memory length         Y
  Y    Free non volatile memory
  1    Free volatile memory tag               '83'
  1    Free volatile memory length             Z
  Z    Free volatile memory

该命令的响应不限于short值,因为它使用TLV格式,这意味着您可以检查超过 32767 字节的可用内存

Javacard with GP 2.2 + ETSI support

If your card supports Global Platform 2.2 and ETSI, you can use GET DATA command.

GP card spec 2.2 section 11.3 states that

Tag ‘FF21’: Extended Card Resources Information available for Card Content Management, as defined in ETSI TS 102 226.

And in ETSI 102.226 section 8.2.1.7.2:

After the successful execution of the command, the GET DATA response data field shall be coded as defined in GlobalPlatform [4]. The value of the TLV coded data object referred to in reference control parameters P1 and P2 of the command message is:

Length Description                            Value
  1    Number of installed application tag    '81'
  1    Number of installed application length  X
  X    Number of installed application
  1    Free non volatile memory tag           '82'
  1    Free non volatile memory length         Y
  Y    Free non volatile memory
  1    Free volatile memory tag               '83'
  1    Free volatile memory length             Z
  Z    Free volatile memory

The response of this command is not restricted to short value because it is using TLV format, which means you can check free memory that is more than 32767 bytes

浅忆流年 2024-12-03 23:54:23

一般来说,使用标准 Java Card API 不可能从卡中获取准确的可用内存量。由于大多数 Java 卡甚至不支持整数,因此您可以从 API 方法获取的最大值为 32767(有符号短整型的上限)。

如果幸运的话,卡/操作系统制造商可能会提供一些专有的 API 方法。我见过一些来自 NXP JCOP 卡的专有 API,但如果空闲内存量超过了签名短路的上限,那么它们都无法获得可用内存量。

In general there is no possibility to get the exact amount of free memory from the card using the standard Java Card API. Because most Java Cards don't even have integer support, the maximum value you can get from the APIs method is 32767 (upper bound of signed short).

If you're lucky, there might be some proprietary API method from the card/OS manufacturer. I've seen some proprietary APIs from NXP JCOP cards but none of them is capable of getting the amount of free memory if it exceeds the upper bound of a signed short.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文