Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

RandomData Encryption Using RSA 2048

JavaCard Applet Development Related Questions and Answers.
morva14
Posts: 11
Joined: Thu Feb 25, 2016 5:16 pm
Points :188
Contact:

RandomData Encryption Using RSA 2048

Post by morva14 » Tue Jun 21, 2016 6:08 am

hi
i encrypt randomdata by using cipher ALG_RSA_NOPAD but some times its result is correct or not.
its Exeption throw is 0005.
i am comfeuzed i dont no what shoud i do

asymCipher = Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);
rsaPubKey = (RSAPublicKey) KeyBuilder.buildKey(KeyBuilder.TYPE_RSA_PUBLIC,

KeyBuilder.LENGTH_RSA_2048,false);
random = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);

randomData = JCSystem.makeTransientByteArray((short)10,JCSystem.CLEAR_ON_RESET);
byte[] temp = new byte[256];
byte[] outBuff= new byte[256];

random.generateData(randomData, (short)0,(short)randomData.length);
Util.arrayCopy(randomData,(short)0,temp,(short)0,(short)randomData.length);
short bLength = (short)(temp.length - randomData.length);
Util.arrayFillNonAtomic(temp,(short)randomData.length,bLength,(byte)0x00);

asymCipher.init(rsaPubKey, Cipher.MODE_ENCRYPT);
asymCipher.doFinal(temp,(short)0,(short)temp.length, outBuff, (short)0);

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: RandomData Encryption Using RSA 2048

Post by mabel » Tue Jun 21, 2016 8:54 am

Pls show us public key and the temp data when you caught exception.

Could you also tell us whether the following code will be executed everytime you run your code?

Code: Select all

randomData = JCSystem.makeTransientByteArray((short)10,JCSystem.CLEAR_ON_RESET);
byte[] temp = new byte[256];
byte[] outBuff= new byte[256];

morva14
Posts: 11
Joined: Thu Feb 25, 2016 5:16 pm
Points :188
Contact:

Re: RandomData Encryption Using RSA 2048

Post by morva14 » Tue Jun 21, 2016 10:24 am

randomData = JCSystem.makeTransientByteArray((short)10,JCSystem.CLEAR_ON_RESET);
byte[] temp = new byte[256];
byte[] outBuff= new byte[256];

they are in to constractor class.

the result of random data encryption some time is correct and its sw is 9000 and some time it is throw cipherexception 0005

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: RandomData Encryption Using RSA 2048

Post by mabel » Wed Jun 22, 2016 1:59 am

Could you tell me the card type you are using?

morva14
Posts: 11
Joined: Thu Feb 25, 2016 5:16 pm
Points :188
Contact:

Re: RandomData Encryption Using RSA 2048

Post by morva14 » Wed Jun 22, 2016 2:18 pm

I dont know what is type of my card. How can i underestand?

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: RandomData Encryption Using RSA 2048

Post by mabel » Wed Jun 22, 2016 10:23 pm

I mean the card model, for instance, J3D081, A22CR, A40CR ..

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 42 guests

JavaCard OS : Disclaimer