-1

I'm using java card 3.0.4. when i create an instance of Cipher (from javacardx.crypto package) like bellow:

Cipher.getInstance(Cipher.ALG_AES_BLOCK_128_CBC_NOPAD, false);

i receive an error. No matter what algorithm I use, same exception happens.

Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false); Cipher.getInstance(Cipher.ALG_AES_BLOCK_128_ECB_NOPAD, false); ...

AHD
  • 21
  • 3

2 Answers2

0

Try and catch the error and match it to all possible exceptions from the documentation. Most probably you might get that it's not implemented

Paul Bastian
  • 2,597
  • 11
  • 26
  • i added try catch blocks and it gave me SystemException with code 2. and it seems this error: public static final short NO_TRANSIENT_SPACE = 2; – AHD Jan 18 '21 at 10:52
  • 1
    Then this means the system has no RAM left to instantiate the object. If you can save some memory somewhere else in your code this is the way to go – Paul Bastian Jan 18 '21 at 10:55
0

The problem was I used lots of instance creation and the memory got full somehow. since java card dont have GC officially, so the instances remains in the memory even after the power of the card disconnected (i'm using card reader for my testing). so I deleted not used variables and made an instance like singleton instead of renewing the instance in each call. thanks Paul Bastian

AHD
  • 21
  • 3