Announce two new product: SmartCard Reader Rockey200 and USB2.0 Extension Cable

ROCKEY 200 is a handy and portable USB Smart Card reader that can perform read/write operations on any ISO 7816-1/2/3/4 smart cards which are compatible with protocol T=0 and T=1.

USB2.0 Extension Cable With high speed USB 2.0 devices such as USB token ,USB Card Reader and so on.

Come to try it now!

3DES Key

Algorithm School

Moderator: UNKNwYSHSA

sakkiotto
Posts: 12
Joined: Thu Dec 03, 2015 5:29 am
Points: 86
Contact:

3DES Key

Postby sakkiotto » Wed Jan 18, 2017 11:58 pm

I have to encrypt data with 3DES algo in my applet. I also need to decrypt the data in my host application. And the key for 3DES should be 24 bytes, anyone can figure out how to extend the 16 byte key to 24 byte key?

Here is my code

Code: Select all

cipherDES = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M1, false);
randomData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);

sessionKey = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES3_2KEY, false);
randomData.generateData(sessionKeyBytes, (short) 0, (short) 15);sessionKey.setKey(sessionKeyBytes, (short) 0);
cipherDES.init(sessionKey, Cipher.MODE_ENCRYPT);

JCaberham
Posts: 24
Joined: Mon Nov 30, 2015 3:02 am
Points: 188
Contact:

Re: 3DES Key

Postby JCaberham » Thu Jan 19, 2017 10:36 pm

If you use bouncy castle, you can use a 16 byte 2TDEA key.

User avatar
marjkbadboy
Posts: 29
Joined: Fri Jul 31, 2015 2:47 am
Points: 179
Contact:

Re: 3DES Key

Postby marjkbadboy » Thu Jan 19, 2017 10:40 pm

Usually, the structure of 24 byte key is ABA, where
A: the first 8 bytes of 16 byte key;
B: the next 8 bytes of 16 byte key.
It's hunting season!


Return to “Algorithm School”

Who is online

Users browsing this forum: No registered users and 1 guest

JavaCard OS : Disclaimer