Java memory allocation

I have a Java Card smart card and I want to evaluate the available EEPROM.

To do this, I use the function JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT). Since the return status of this function is short, without highlighting any data, I get a value 0x7FFF. To solve this problem, I create arrays byteas follows: new byte[(short) 0x7FFF]to output the available read-only memory.

If I create two arrays:

arr1 = new byte[(short) 0x7FFF];
arr2 = new byte[(short) 0x7FFF];

It then stores the 0x1144bytes of available memory in accordance with JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT). Therefore, if I summarize, this means that there are 32767 * 2 + 4420 = 69954 bytes.

But when I resize my arrays:

arr1 = new byte[(short) 0x7FFF];
arr2 = new byte[(short) 0x6FFF];

then it stores the 0x2244bytes of available memory. Therefore, if I summarize, this means that 70210 bytes are available.

Another example: C

arr1 = new byte[(short) 0x7FFF];
arr2 = new byte[(short) 0x5FFF];

0x3344 . , , 70466 .

, ? (70210 70466).

, , AESKey . , , AESKey.

, AESKey :

arr = new AESKey[(short) 0x03E8];
for (short i = 0x0000; i < 0x03E8; i++) {
  arr[i] = (AESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_AES,  KeyBuilder.LENGTH_AES_256, false);
}

, 256 AESKey. , 32Ko, JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT) , 0x0022 . ?

(, 500):

arr = new AESKey[(short) 0x01F4];
for (short i = 0x0000; i < 0x01F4; i++) {
   arr[i] = (AESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_AES,  KeyBuilder.LENGTH_AES_256, false);
}

JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT) , 0x55EE (21998) : , 1000 , EEPROM 70Ko, ...

- , Java-, ?

+4
2

:

  • ;
  • ;
  • ;
  • , .

. getAvailableMemory .

, Java-.

+3

, :
Java- / . , x, trashhold 0x7FFF, x , .

JCOP, , UtilX.getAvailableMemory().

: http://ruimtools.com/doc.php?doc=jc_best EEPROM ( )

+2

Source: https://habr.com/ru/post/1608507/


All Articles