Discussion of New Padding Method in DES Encryption *

DES is a kind of block cipher and before DES encryption the plain text be divided into the same-size blocks. But sometimes the plain text can’t be divided into the exactly size. So padding step is needed to pad the space of the block. The discussion of the block padding is the emphasis of this paper. A new padding method is given and at the last part of the paper the implementation of DES using new padding method is given.


Introduction
DES is the standard of data encryption, and also a kind of block cipher [1].In block cipher the plain text be di-vided into same size block and use private key to encrypt the plain text into cipher text.In blocking when the length of the block is not as long as 64 bits we usually pad them with zero [2].Now we will introduce a new method to pad the lacked bits in this paper.This method is not only pad zeros to them but also add the length of zero padded to the last 1 byte.So we can easy get what we pad in the block and can get rid of them fast.

New Padding Method
The plain text is divided into 64 bits blocks [3].Perhaps there is not enough text to fill the last block.How to do with this?The traditional method is padding zero in the end of the block [4].But it does not distinguish between the padding zero and the original zero.And how can we known where is the beginning of the filling zero?
To solve these problems a new padding method be given.The synopsis of the new padding method is that a "length" part be added to the end of the block.
[step1]: Divided the plain text into 8 bytes(64-bits).If the block size is less than 64 bits then goes to step2.
[step2]: Pad the lacked bits with zero but leave the last 8 bits to memorize the length of padding zeros.
[step3]: Encrypt the plain text with DES algorithm.
[step5]: Delete the padding zeros according to the length field.
In the new Method there is one problem.How can we known if the last 8 bits is the length information or the original message?To solve this problem an explanation to prove the correctness of the method be given below.
For the last block, firstly, we get the last 8 bits and think it as the length data.Then according to the length data we get the whole padding field.Whether the padding field we got is full of zero?There will be two possible results: result1: The field is full of zero.So the field is padding field.Delete it and get the real plain text.
result2: The field is not full of zero.So the last 8 bits is not the length of padding but the plain text.Preserve it and take the whole last block as plain text.
Processing: First, we get the last 8 bits of the block: 00100000.Then we presume the length of padding field is 32 bits.
Second, we get the last 32 bits data from the block.Third, we find the 32-8=24(got rid of the length field) bits data is zero.
Forth, so the last 32 bits is padding field and we can de-lete it.
Ex 2: The information block.
Processing: First, we get the last 8 bits of the block:00100000.Then we presume the length of padding field is 32 bits.
Second, we get the last 32 bits data from the block.Third, we find the 32-8 = 24(got rid of the length field) bits data is not zero.
Processing: First, we get the last 8 bits of the block: 00100000.Then we presume the length of padding field is 32 bits.
Second, we get the last 32 bits data from the block.Third, we find the 32-8=24(got rid of the length field) bits data is zero.
Forth, so the last 32 bits is padding field and we can delete it.We get error result.
If we use the new padding method to do the padding there will be some errors.But we can analyze it and we get a conclusion that it has less error than old method which be used in zero padding.Let us make a math proving.
If: The probability of every kind of block is 1/2 64 .The length of padding field is "L".old: If the last "L" bits are zero the original message may have Then the error probability is 64 64 New: If the last 8 bits are zero the original message may have 2 possibilities.Then the error probability is 64 64 So the new padding method is more exactly.Then the next section will give the implementation of DES and the new padding method is used in it.

Implementation
Implementation of the DES algorithm is given below.We use the java as the programming language.The new padding method is used in it.There are an interface for DES encryption, a class for block processing and a class for implementation of the DES.And we will introduce the definition of them below.
First the Figure 1 show the relation between different class or interface.The test class is used in testing and we will not introduce it here.The user uses the interface IDES to do the encryption.And then the IDES can be implemented in the DES class.And then the method in DES class will call the method in block class to do detailed operation.

Interface IDES 1) encrypt(byte[] src,byte[] dest,DESKey key)
The method is used to encrypt the plain text with the DES key and get the cipher text.
2) decrypt(byte[] src,byte[] dest,DESKey key) The method is used to decrypt the cipher text with the DES key and get the plain text.