< Introduction to cryptography > Decoding algorithm for DES encryption algorithm and related problems

Source: Internet
Author: User

Off- topic: Personally think DES encryption and decryption is really a lengthy process, s box, p box and a variety of transformations to make people dazzling.

A Feistel Password structure

First of all, the reason for the Feistel cipher structure is that the DES encryption process is exactly the same as the Feistel password structure.

Feistel password structure first to the part to be encrypted into the left and right r0,l0, the next step is to L0 do not do the processing directly to R1,R0 first to go through a round function f (rx,kx) after the processing and L0 each of the half-plus operation, under normal circumstances, In the process of continuous exchange between the left and right parts, the sub-key Kx will also change constantly, essentially making f (rx,kx) function to do the processing because of the change of KX changes. The process of constant exchange also makes the statistical characteristics of clear text scattered in the ciphertext, which is called "confusion diffusion", wherein the wheel function f is the entire encryption process of the unique non-linear part, the complexity of the wheel function determines the degree of encryption.

Algebraic expression Feistel cipher structure is:

Ri = li+1; Li = ri+1⊕f (Li+1,ki)(where a half-plus/or operation makes the encryption process and the decryption process identical to the order of the sub -key)

(ii) DES encryption process

Des algorithm processing the entire process is to encrypt the 64bit plaintext, after the 64BIT key to encrypt, and finally generate the target 64bit ciphertext, the encryption process is as follows:

1. The first step is to get the file pointer or pointer that will be encrypted from the target file or buffer , and the plaintext to be encrypted is set as follows:

01 02 03 04 05 06 07 08

09 10 11 12 13 14 15 16

17 18 19 20 21 22 23 24

25 26 27 28 29 30 31 32

33 34 35 36 37 38 39 40

41 42 43 44 45 46 47 48

49 50 51 52 53 54 55 56

57 58 59 60 61 62 63 64

A new plaintext sequence is formed after the IP permutation: (the following b are omitted)

58 50 42 34 26 18 10 02

60 52 44 36 28 20 12 04

62 54 46 38 30 22 14 06

64 56 48 40 32 24 16 08

57 49 41 33 25 17 09 01

59 51 43 35 27 19 11 03

61 53 45 37 29 21 13 05

63 55 47 39 31 23 15 07

The specific process of IP replacement is really a lot of explanations on the web, but this does not hinder our DES encryption process, because the process of clear-text IP permutation is a process of traversing clear-text by index, we only need to open 64*sizeof (char) space to complete the initial IP replacement process. Ishi at the end of the encryption process we need an inverse permutation of the IP permutation (for matrix paa^ ( -1) =p):

40 08 48 16 56 24 64 32 39 07 47 15 55 23 63 31 38 06 46 14 54 22 62 30 37 05 45 13 53 21 61  29 36 04 44 12 52 20 60 28 35 03 43 11 51 19 59 27 34 02 42 10 50 18 58 26 33 01 41 09 49 17 57 25

2. Sub-key generation process

The so-called sub-key we get first is 64bit, but the only part that really works is the 48-bit sub-key, which is transformed as follows:

(the corresponding subscript matrix of the PC-1 permutation is first stripped of the 8th parity bit of each row and then replaced)

57 49 41 33 25 17 09

01 58 50 42 34 26 18

10 02 59 51 43 35 27

19 11 03 60 52 44 36

-----------------------

63 55 47 39 31 23 15

07 62 54 46 38 30 22

14 06 61 53 45 37 29

21 13 05 28 20 12 04

After the PC-1 replacement, the resulting portion is divided into the first 28bit and after 28bit respectively c0,d0

The c0,d0 is then cycled one or two bits separately, and the exact number of digits is determined by the following sequence.

1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1

During the 16 iterations of DES, the generation process of the sub-key is strictly in the order mentioned above, and if we want to use the data obtained after each cyclic shift as parameters in the wheel function, we need another compression permutation matrix PC-2 subscript matrix as follows:

14 17 11 24 01 05

03 28 15 06 21 10

23 19 12 04 26 08

16 07 27 20 13 02

41 52 31 37 47 55

30 40 51 45 33 48

44 49 39 56 34 53

46 42 50 36 29 32

After the PC-2 compression permutation we get a 48-bit sub-key, as for how to use the input wheel function, the following will be described in detail. In summary, the iterative generation process of the sub-key can be expressed as a table:

3. About Wheel function f (rx,kx) internal

The first round function accepts the parameters of the 32bit string to be encrypted, and the other is the 48-bit current iteration wheel generated by the sub-key, the operation process is as follows:

(1) Expansion process, the 32bit to be encrypted string expansion into a 48bit string, this step is also called extended displacement, the essence of the extended displacement is to repeat some bits of the 32bit string to achieve expansion, the following table is expanded as follows:

32 01 02 03 04 05

04 05 06 07 08 09

08 09 10 11 12 13

12 13 14 15 16 17

16 17 18 19 20 21

20 21 22 23 24 25

24 25 26 27 28 29

28 29 30 31 32 01

This process is also known as the "e box". A new 48bit string will be obtained after the expanded string and the 48-bit sub-key obtained by the E-box or the arithmetic/half-plus operation.

(2) s box, this step is also the most critical step, because the process of this step is completely non-linear, but also the core part of the encryption process. The newly obtained 48bit string is divided into 8 6bit strings in sequence, and each 6bit produces a 4-bit output through a corresponding S-box. The specific process is to take the first and sixth bits from the 6bit string combined together as the line coordinates of the s box, the remaining four bits as the column coordinates, for example, the first bit of the 010111 string is 0 sixth bit is 1, then the line coordinates is 01B column coordinates is 1011B namely 0xB, Each pair of coordinates of the s box can be obtained with 4 bits of data as shown:

Finally, the output from the 8 s box is linked together in order to get a new 32bit string, and then a P-box transformation to produce a new 32bit string, p-box transformation and e-box transformation process is similar, subscript matrix is as follows:

16 07 20 21

29 12 28 17

01 15 23 26

05 18 31 10

02 08 24 14

32 27 03 09

19 13 30 06

22 11 04 25

Such data from the P box is completed the whole process of the wheel function pull, the result of the other half of the merger and then after 16 cycles after the IP inverse permutation to get the ciphertext, the following is the framework of my own drawing of the program:

The DES algorithm is very complex, but the degree of encryption is very high, strictly follow the avalanche effect, so that one of the key changes will lead to the sub-key changes in order to complete the confusion of proliferation purposes.

#################################

Problem1: It is proved that the encryption process of DES algorithm is the inverse of decryption process.

Ans:

The DES algorithm adheres to the Feistel cipher structure and therefore has

Ri+1=li

Li+1=li⊕f (Ri,ki)

The decryption process will ri+1,li+1 into the above formula (decryption left and right order is reversed):

Li+1=ri

Li+1⊕f (Ri,ki) =li⊕f (Ri,ki) ⊕f (Li+1,ki) =li⊕f (Ri,ki) ⊕f (Ri,ki) =li

Therefore, the results obtained from the left and right sides of the surrogate are the left and the last round of the encryption process.

< Introduction to cryptography > Decoding algorithm for DES encryption algorithm and related problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.