Page 1 of 1

DES decryption implementation in java and java card

Posted: Thu Feb 09, 2017 11:01 pm
by mose05
Recently, I found a difference between DES decryption implementation in java and java card.

In UPDATE method, DES CBC (M1, M2, or, PK5)
- In java, it need to have at least 16 bytes input to have output data.
- In java card, you should have at least 8 byte to have output data.

Why does this difference there? Could anybody explain it to me? Thanks.

Re: DES decryption implementation in java and java card

Posted: Fri Feb 10, 2017 3:15 am
by Crawford
mose05 wrote:- In java, it need to have at least 16 bytes input to have output data.


Have you got 8 bytes in the response? If you have 8 bytes only, you should call doFinal().

Re: DES decryption implementation in java and java card

Posted: Fri Feb 10, 2017 5:12 am
by mose05
I know that calling doFinal will give me final result.
The problem is that in Java, if input data is less than 16 bytes,there will be no output after calling update .
But in javacard it will give output of update method if the input data is more than 8 bytes length.
Is there any advantage between them?

Re: DES decryption implementation in java and java card

Posted: Fri Feb 10, 2017 6:17 am
by Crawford
IMO, there is no advantage or dis-advantage in this case. You should not rely on intermediate results of update anyway because the operation is not completed until doFinal(...) method is called.