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.

the length of cipher

JavaCard Applet Development Related Questions and Answers.
tykeal
Posts: 7
Joined: Wed Jul 13, 2016 2:15 am
Points :90
Contact:

the length of cipher

Post by tykeal » Sat Jul 16, 2016 2:26 am

Hey!

I encountered a problem. I am trying to encrypt a byte array with length 8. But the length of cipher I obtained is 16. How can I make this to be 8?

In the following code, temp length is 8, and out's length is 16.

Code: Select all

Cipher cipherinstance = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M2, false);
DESKey deskey = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
deskey.setKey(KEY_8_BYTES, (short)0);
out = cipherinstance.doFinal(temp, (short)0, (short)temp.length, res, (short)0);

chico0609
Posts: 59
Joined: Mon Sep 14, 2015 5:05 am
Points :416
Contact:

Re: the length of cipher

Post by chico0609 » Sat Jul 16, 2016 4:34 am

Use Cipher.ALG_DES_CBC_NOPAD to replace Cipher.ALG_DES_CBC_ISO9797_M2.

wousim
Posts: 14
Joined: Tue Feb 16, 2016 10:12 pm
Points :109
Contact:

Re: the length of cipher

Post by wousim » Sat Jul 16, 2016 5:08 am

That is just due to the cipher padding method. You should be able to safely ignore the last 8 bytes though as CBC mode does not cause the first block to be different even though there is additional padding.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 30 guests

JavaCard OS : Disclaimer