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!

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

Postby 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: 219
Joined: Mon May 18, 2015 3:09 am
Points: 1513
Contact:

Re: DES encryption with data length 132 byte

Postby 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

Postby 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.


Return to “Algorithm School”

Who is online

Users browsing this forum: No registered users and 1 guest

JavaCard OS : Disclaimer