为什么我不能从我的 JavaCard 中删除未使用的包?

Why I can't delete unused packages from my JavaCard?

我有一张 Gemalto Top DL v2 java 卡。当我list内容的时候,卡里加载了很多包:

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -list
AID: A000000018434D00 (|.....CM.|)
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management

AID: A0000000620001 (|....b..|)
     ExM LOADED: (none)

AID: A0000000620002 (|....b..|)
     ExM LOADED: (none)

AID: A0000000620003 (|....b..|)
     ExM LOADED: (none)

AID: A0000000620101 (|....b..|)
     ExM LOADED: (none)

AID: A000000062010101 (|....b...|)
     ExM LOADED: (none)

AID: A0000000620102 (|....b..|)
     ExM LOADED: (none)

AID: A0000000620201 (|....b..|)
     ExM LOADED: (none)

AID: A0000000030000 (|.......|)
     ExM LOADED: (none)

AID: A000000018100201 (|........|)
     ExM LOADED: (none)

AID: A000000018100101 (|........|)
     ExM LOADED: (none)
     A000000018534441 (|.....SDA|)

AID: A00000015100 (|....Q.|)
     ExM LOADED: (none)

现在,我想删除不用的包:

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A0000000620001 -deletedeps
Could not delete AID: A0000000620001
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A0000000620002 -deletedeps
Could not delete AID: A0000000620002
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A0000000620003 -deletedeps
Could not delete AID: A0000000620003
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A0000000620101 -deletedeps
Could not delete AID: A0000000620101
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A000000062010101 -deletedeps
Could not delete AID: A000000062010101
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete A0000000620102 -deletedeps
Could not delete AID: A0000000620102
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete  A0000000620201 -deletedeps
Could not delete AID: A0000000620201
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete  A0000000030000 -deletedeps
Could not delete AID: A0000000030000
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete  A000000018100201 -deletedeps
Could not delete AID: A000000018100201
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete  A000000018100101 -deletedeps
Could not delete AID: A000000018100101
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

GlobalPlatformPro:> gp -visa2 -key 47454D5850524553534F53414D504C45 -delete  A00000015100 -deletedeps
Could not delete AID: A00000015100
TIP: Maybe try with --deletedeps
openkms.gp.GPException: Deletion failed SW: 6985
        at openkms.gp.GlobalPlatform.check(GlobalPlatform.java:1039)
        at openkms.gp.GlobalPlatform.deleteAID(GlobalPlatform.java:814)
        at openkms.gp.GPTool.main(GPTool.java:367)

问题是为什么我不能删除它们并释放我的卡内存?

回答

您如何确定这些软件包未被使用? applet 可以设计为使用单独的库和/或服务。这些库/服务在 GP 中有自己的 AID,但您首先需要删除所有小程序实例和小程序模块(按此顺序),然​​后才能删除它们。

很多卡的ROM中都包含pre-installed软件。 ROM 掩码中的 space 不能再用于其他用途。删除这些模块不会释放很多资源。如果删除成功,您基本上只是从注册表中删除了 AID。如果您想上传同一库的新版本,这会很有用,否则不会有太大区别。

AID 和 RID 的解释

AID 由两部分组成:一个 5 字节的 RID 和一个可变大小的扩展 - 称为 PIX - 用于识别实体的 RID。该实体仅在应用程序 DF 中,但对于 Java 卡模块也由 AID 标识。

现在我已经获得了一份 RID 列表:

  • A000000018434D00 安全域来自 Gemplus(现为 Gemalto);
  • A0000000620001A0000000620002A0000000620003A0000000620101A000000062010101A0000000620102A0000000620201均为太阳(现在是甲骨文)模块;他们 contain extensions to the basic Java Card runtime;
  • A0000000030000是旧VISA RID下的卡管家;
  • A000000018100201A000000018100101 是来自 Gemalto 的扩展模块或小程序;
  • A00000015100为全球平台AID下的卡片管理员;

A0000000030000 AID 正在逐步淘汰 - VISA 是开放平台(现为全球平台)的创始人。 GP 现在应该使用他们自己的 RID。

备注:

  • 库只是代码和常量,服务包含可以通过对象共享机制使用的状态;
  • 有点明显:对于特定的卡,您可能需要联系您的供应商以了解其配置方式。