简体   繁体   中英

Java card applet size

How much of eeprom does JC applet installation use? Is it the size of CAP file, or how do I find out? Maybe I could use JCsystem method get available memory, but is there some direct method like some command in JC development tools from oracle? (I don't have 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

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.

The limitation is that this method only supports short , which means maximum free memory is 0x7FFF (32767) bytes. 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.


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

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. 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

The size of some objects depend on the Java Card operating system, so there is not a direct link. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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