Christmas is coming soon! To thank for the support from all our dear customers, Christmas promotional activity is going on in JavaCardOS online store. For more activities details, please check this post.

DES encryption with data length 132 byte

Algorithm School

Moderator: UNKNwYSHSA

RexLi
Posts: 9
Joined: Wed Dec 21, 2016 11:46 pm
Points :82
Contact:

DES encryption with data length 132 byte

Post by RexLi » Thu Mar 09, 2017 11:27 pm

I have to use DES alg in my applet. But the length of Data are 132 bytes. So I wonder if it's feasible to implement DES encryption with data length 132 byte?

Code: Select all

skey = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES3_2KEY, false);
cDES = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M2, false);
     
cDES.init(skey, Cipher.MODE_ENCRYPT);
cDES.doFinal(Data, doffset, dlen, EBuffer, eoffset); // Data and EBuffer are 132 byte length


User avatar
mabel
Posts: 234
Joined: Mon May 18, 2015 3:09 am
Points :1663
Contact:

Re: DES encryption with data length 132 byte

Post by mabel » Fri Mar 10, 2017 6:21 am

DES requires the data to be block-aligned to an 8 byte boundary. You can have different length input as long as the cipher instance pads the data. Then the output would be block-aligned.

Neqikoo
Posts: 7
Joined: Thu Feb 25, 2016 3:48 am
Points :74
Contact:

Re: DES encryption with data length 132 byte

Post by Neqikoo » Fri Mar 10, 2017 8:46 am

Under javacard implementation, the padding is done transparently so it can be block-aligned automatically. You don't need to worry about data length.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 2 guests

JavaCard OS : Disclaimer