Page 1 of 1

Problematic JCSystem.beginTransaction when used with generating RSA keys

Posted: Tue Nov 01, 2016 5:08 am
by tay00000
Anyone have tried to generate RSA2048 bit keys while encapsulating the RSA keygen within the begin and commit transaction statements and returns a
out of memory status word or something along that line when used on an NXP JCOP 2.4.2 card ?

Code: Select all

JCSystem.beginTransaction();
keyPair = new KeyPair(KeyPair.ALG_RSA, (short) KeyBuilder.LENGTH_RSA_2048);
keyPair.genKeyPair();
JCSystem.commitTransaction();

Re: Problematic JCSystem.beginTransaction when used with generating RSA keys

Posted: Tue Nov 01, 2016 5:24 am
by UNKNwYSHSA
Transaction buffer size of jcop242R2 is 512 bytes.
So when generate RSA 2048 keypair, D is length 256, N is length 256, and N is write to private key object and public key object. Then the transaction data size > card transaction buffer size. Then raise the out of memory exception?

Re: Problematic JCSystem.beginTransaction when used with generating RSA keys

Posted: Tue Nov 01, 2016 5:27 am
by tay00000
Oh my ... I forget all about the transaction buffer size. That explains it.

That means, use the genKeyPair() or setKey() unless wanting to incur into the transaction buffer via begin/commit transaction.

Re: Problematic JCSystem.beginTransaction when used with generating RSA keys

Posted: Tue Nov 01, 2016 5:37 am
by UNKNwYSHSA
All NVM wirte operations will be written into transaction buffer between JCSystem.beginTransaction() and JCSystem.commitTransaction/abortTransaction.