简体   繁体   English

Java卡小程序大小

[英]Java card applet size

How much of eeprom does JC applet installation use? JC applet安装会使用多少eeprom? Is it the size of CAP file, or how do I find out? 它是CAP文件的大小,还是如何查找? Maybe I could use JCsystem method get available memory, but is there some direct method like some command in JC development tools from oracle? 也许我可以使用JCsystem方法获取可用内存,但是是否有一些直接方法,例如oracle JC开发工具中的某些命令? (I don't have JCOP) (我没有JCOP)

Haven't found direct method to get size of an applet yet. 尚未找到获取小程序大小的直接方法。 Here's two ways that I used to get size of an applet 这是我用来获取小程序大小的两种方法


Standard Javacard 标准Java卡

In development environment, create an applet that uses JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT) and send APDU to call it before and after install (load) to get the EEP for class, and call again before and after install (install) to get EEP for applet instance. 在开发环境中,创建一个使用JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT)的applet,并在安装(加载)之前和之后发送APDU进行调用以获取该类的EEP,并在安装(install)之前和之后再次调用以获取EEP。对于applet实例。

The limitation is that this method only supports short , which means maximum free memory is 0x7FFF (32767) bytes. 限制是此方法仅支持short ,这意味着最大可用内存为0x7FFF (32767)字节。 You cannot use this method if your applet is bigger than 32767 bytes, and you need to reduce your free memory using dummy applet so that the free memory before install (load) is less than 32767 bytes. 如果您的小程序大于32767字节,则不能使用此方法,并且需要使用虚拟小程序减少可用内存,以使安装(装入)之前的可用内存小于32767字节。


Javacard with GP 2.2 + ETSI support 具有GP 2.2 + ETSI支持的Java卡

If your card supports Global Platform 2.2 and ETSI, you can use GET DATA command. 如果您的卡支持Global Platform 2.2和ETSI,则可以使用GET DATA命令。

GP card spec 2.2 section 11.3 states that GP卡规范2.2第11.3节指出:

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: 在ETSI 102.226第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]. 成功执行命令后,应按照GlobalPlatform [4]中的定义对GET DATA响应数据字段进行编码。 The value of the TLV coded data object referred to in reference control parameters P1 and P2 of the command message is: 命令消息的参考控制参数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

Use the same steps as in standard Javacard above, but instead of selecting the applet to get free memory and send its command, we directly send the GET DATA commmand. 使用与上述标准Javacard中相同的步骤,但是我们没有选择小应用程序来获取可用内存并发送其命令,而是直接发送GET DATA命令。 This means one step easier... Also, the response of this command is not restricted to short value, which means you can check applet size that is more than 32767 bytes 这意味着更容易一步...而且,此命令的响应不限于short值,这意味着您可以检查大于32767字节的applet大小

The size of some objects depend on the Java Card operating system, so there is not a direct link. 一些对象的大小取决于Java Card操作系统,因此没有直接链接。 Don't forget that the OS may also need to use memory to support your application. 不要忘记,操作系统可能还需要使用内存来支持您的应用程序。 Some operating systems also align the data, making it more complex. 一些操作系统还会对齐数据,从而使数据更加复杂。

So unless you have been provided with tools from your manufacturer, it is hard to be sure. 因此,除非为您提供了制造商提供的工具,否则很难确定。 The byte code size could probably be determined, given a byte or two, but I don't know any specific tools for that from the top of my head. 给定一个或两个字节,可以确定字节码的大小,但是从我的头上我不知道有什么具体的工具。

Without tools, JCSystem may be your best bet. 没有工具,JCSystem可能是您最好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM