Page 1 of 1

Time duration on RSA Encryption

Posted: Tue May 02, 2017 3:43 am
by AmigoJack
I am testing RSA Encryption with keys length 768 and 1024.

In debugging window, about 4000 us for 768 key length, about 3000 us for 1024 key length.

For other keys, the time duration increases from 512 to 1984.

Does anyone have any idea about time duration?


Code: Select all

private final static short RSA_KEY_SIZ = KeyBuilder.LENGTH_RSA_768;

rsa_KeyPair =  new KeyPair(KeyPair.ALG_RSA_CRT, RSA_KEY_SIZE);

cipherRSA  =  Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);

cipherRSA.init(rsa_PrivateCrtKey, Cipher.MODE_ENCRYPT);

 short cyphertext = cipherRSA.doFinal(inpBuffer,(short) 0, (short) (RSA_KEY_SIZE/8), buf, ISO7816.OFFSET_CDATA);
 
 

Re: Time duration on RSA Encryption

Posted: Tue May 02, 2017 4:30 am
by UNKNwYSHSA
The data length maybe causes this problem.
If the data length is greater than 768 bits (96 bytes) and less than 1024 bits(128 bytes), the encryption with RSA length 768 needs twice calculation for the data block, but encryption with RSA length 1024 needs once only.

Re: Time duration on RSA Encryption

Posted: Wed May 03, 2017 11:23 pm
by AmigoJack
Thank you UNKNwYSHSA. It helps.

In fact, my goal is to find difference of duration on card for different length of key. So that I can evaluate the RSA performance on real card. Do you have any conclusion or experience on this?