3DES with 2 Key. Help me...

Hi all...

Maybe my question has been answered in this forum, but i haven't found yet.

i will using 3DES_2Key for 3DES and ALG_DES_CBC_ISO9797_M2 for Cipher in my applet. In the sample code (CryptoTest.java), 3DES_2Key will using 16 byte arrays. But in J2SE, it only has 8 byte (for DES) and 24 byte (for DESede). How can i using 16 byte arrays to make the encryption in host app?

Some people said it just simple. U can add the the first 8 byte to end the 24 byte --> xxxxxxxxyyyyyyyyxxxxxxxx. When i'm using it, it can do the encryption and the decryption but the result is different.

Ex : i encrypt the string "06402010" and it will sent to applet to do the descryption and will be saved in var nim. when i send apdu to read var nim, it give me response 撙:餓? (PS : i convert it to string). Am i wrong?

Can u gave me sample code for using 3DES_2Key in host application and applet?

Thanks...

[940 byte] By [DeeYaha] at [2007-10-3 7:27:29]
# 1

3DES is like DES only it has three steps instead of one and uses 2 keys of Eight bytes instead of one.

3DES encryption:

Encrypt data using Key1 and DES==>result

Decrypt the result using Key2 and DES==>result2

Encypt the result2 using Key 1 and DES==>cypher

3DES decryption:

Decrypt Cypher using Key1 and DES==>result

Encrypt result using Key2 and DES==>result2

Decrypt result2 using Key1 and DES==> data

hope it helps

razzaj1a at 2007-7-15 2:26:29 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

Hi razzaz, thanks for the reply...

I think i understand what u've told. but i still confused...

in my case, i will using ALG_DES_CBC_ISO9797_M2 for cipher in my applet. But, when i read the J2SE API docs, there's no padding like that. How can i using the cipher to get same result? Sorry if my question is really annoying. Bcause i'm still newbie in javacard and java security

Thankks...

DeeYaha at 2007-7-15 2:26:29 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3
It's maybe helpful that uploading your code!When u use ALG_DES_CBC_ISO9797_M2, the cipher will padding data to multipl of 8 bytes then process cryption with mode CBC.
reona at 2007-7-15 2:26:30 > top of Java-index,Java Mobility Forums,Consumer and Commerce...