Page 1 of 1

decrypt DES in javacard vs java

Posted: Wed Jan 20, 2016 10:30 pm
by leogen
Hi all!
I tested DES decryption on java card and I also did comparison between java card and java.
I got the following result:
In update method, DES CBC (M1, M2, or, PK5);
- If implementing in java, I need to have at least 16 bytes input to have output data.
- If implementing in java card, I need to have at least 8 byte to have output data.

So what reason results in this difference?

If anyone can share your knowledge with me, I would be greatly appreciated.

Re: decrypt DES in javacard vs java

Posted: Thu Jan 21, 2016 9:44 pm
by Tarantino
For Java implementation, Do you get 8 bytes in the response? If you have 8 bytes only, you should call doFinal(...).

Re: decrypt DES in javacard vs java

Posted: Thu Jan 21, 2016 9:49 pm
by leogen
Tarantino wrote:For Java implementation, Do you get 8 bytes in the response? If you have 8 bytes only, you should call doFinal(...).


@Tarantino, Thanks for your answer!

I do understand that calling doFinal will give me final result.
The problem is that in Java, there will be no output after calling update if input data is less than 16 bytes
However, javacard will give output of update method if the input data is more than 8 bytes length.

Re: decrypt DES in javacard vs java

Posted: Thu Jan 21, 2016 9:51 pm
by Tarantino
Just keep in mind that you should not rely on intermediate results of update anyway since the operation is not complete until doFinal is called.