首页 > 解决方案 > OPSystem.setATRHistBytes 如何在 GlobalPlatform 兼容卡中工作?

问题描述

引用自 GP2.1.1 API 文档:

setATRHistBytes
public static boolean setATRHistBytes(byte[] baBuffer,
                                      short sOffset,
                                      byte bLength)
This method sets the historical bytes of the ATR (Answer To Reset) string. The sequence of bytes will be visible on a subsequent power-up or reset.

Notes:

    This method shall not be invoked from the Applet.install() method.
    
The OPEN locates the entry of the current applet context in the Open Platform Registry and verifies that the application has the "default selected" privilege.
    The OPEN is responsible for updating the length of historical bytes in Format Character T0 of the ATR.

    Parameters:

    baBuffer - the source byte array containing the ATR historical bytes. Must be a global array.
    sOffset - offset of the ATR historical bytes within source byte array.
    bLength - the number of historical bytes.

    Returns:
    true if ATR bytes set, false otherwise.

问题 1:GP 是否强制默认选择小程序来更改 ATR Hist 字节?

问题 2:GP 是否仅更改 Cold Reset ATR?还是暖重置 ATR 也发生了变化?

问题 3:我如何才能收到我的卡的热重置 ATR?有什么命令吗?它是特定于读者的吗?

标签: smartcardjavacardglobalplatform

解决方案


关于1:我以前从未使用过此命令,但是在阅读时:

OPEN 在 GlobalPlatform Registry 中定位当前小应用程序上下文的条目,并验证应用程序是否具有默认选定权限。

我会假设任何兼容的实现都必须以这种方式处理它。是否有理由不相信这一点,或者您是否问大多数供应商是否忽略了这一点?由于历史部分包含与默认选择的应用程序相关的信息(例如,卡有 MF、如何读取 EF.DR、默认应用程序的 AID、发行人所在的国家/地区……),因此检查此权限是有意义的。这在今天可能不适用于多应用智能卡世界。

关于 2:正如名称“历史字节”所示,仅更改了ATR的这一部分。时钟速度等其他部分在冷 ATR 和暖 ATR 之间可能有所不同。

关于 3:查看 PC/SC 命令SCardConnect。见SCARD_RESET_CARDSCARD_UNPOWER_CARD


推荐阅读