Packet Password algorithm

Source: Internet
Author: User
Tags rounds

substitution, s box. Diffusion and confusion, these concepts form the basis of the grouping password.

assuming that the packet length of plaintext and ciphertext is n-bit, then each grouping of plaintext has 2n possible values ;

Substitution:

In order for the cryptographic operation to be reversible (that is, the decryption operation is feasible), each packet of clear text should produce a unique ciphertext grouping (many-to-one), so

The transformation is reversible, and the reversible transformation, which is called the plaintext grouping to the ciphertext group, is substituted.

S Box:

Generally, the substitution structure of n-bits. The size of the key is n*2n bits. such as the grouping of 64 bits. The key size should be 64*264 bits,

Difficult to handle.

In practice, n is often divided into smaller segments. For example, optional N==rn0, where r,n0 are full positive. The substitution of the design n variables into a

Design r A smaller descendant, and each descendant has only n0 input variables. General N0 are not too big. It is said that each descendant is replaced by a substitution box. Referred

S box.

For example, the input is 48 bits in Des. The output is 32-bit substitution with 8 s box, each S-box input is only 6 bits

。 The output is only 4-bit.

Extensions and obfuscation:

It is the two basic methods of designing password system to resist the statistical analysis of password system by opponents.

Diffusion is the dissemination of the statistical characteristics of the plaintext into the ciphertext, the implementation is to make every bit of the ciphertext in the clear text in the generation of multiple bits. In the two-tuple password

, you can run a permutation on the data repeatedly. Again, this substitution acts on a function. will be able to gain diffusion.

The purpose of diffusion is to make clear and ciphertext

The statistical relationship becomes as complex as possible;

Confusion is to make the statistical relationship between ciphertext and key as complex as possible so that the opponent cannot get the key.

Using complex substitution algorithms to get the expected confusion

effect, and the simple linear substitution function results in less than ideal obfuscation.

Diffusion and obfuscation succeeded in realizing the essential attributes of group password. Thus becomes the foundation of the design modern grouping password.


Group Encryption steps
Packet encryption algorithm is a certain size of plaintext or ciphertext to do encryption or decryption action. In the DES encryption system. Each
The packet size for encryption or decryption is 64 bits. So des does not have ciphertext extension problems.

For clear text greater than 64 bits, simply press
Each 64-bit group is split, while clear text with less than 64 bits is only needed to be followed by "0".
The encryption or decryption keys used for DES are also 64-bit sizes, but 8 of them are parity bits, so the real key in 64-bit
Only 56 bits of the action. Des encryption and decryption algorithms used in addition to the sub-key in the order of different, the rest of the same.



For arbitrary-length plaintext, des first groups it so that each group has a length of 64 bits, and then each
The 64-bit plaintext group is encrypted.
The encryption steps for each 64-bit-length plaintext packet are as follows:
1. Initial displacement: The input group is reordered according to the initial permutation table. The initial permutation.
2, 16 cycles: des 16 rounds of similar sub-encryption processes for 64-bit plaintext after initial displacement.

Each round of the child
The encryption process passes through the DES's F function, with steps such as the following:
A, the 64 bits from the middle, divided into 2 parts, each part 32 bits, the left half is recorded as L. Right Half part
Note as r, in the right half:
A1, extended Displacement:
The 32-bit input data is expanded into 48-bit output data based on the extended displacement table.


A2, XOR, or operation:
XOR the 48-bit plaintext data with the 48-bit sub-key (the sub-key generation process is described below)
A3,s Box substitution:
S-box substitution is nonlinear, and the 48-bit input data S-box replacement table is replaced with 32-bit output data.
A4, Direct replacement:
The 32-bit output data after the S-box displacement is directly replaced by the direct substitution table.
A5, the direct displacement of the 32-bit output data with the L part of this round is different or operation, the result as
The r part of the next wheel encryption process. The r part of this round is directly used as the L part of the next wheel encryption process.
Then proceed to the next wheel encryption process until all 16 rounds are complete.


3, end permutation; The 64-bit output is ciphertext, according to the terminating permutation table.



During each round of sub-encryption, the 48-bit plaintext data is to be XOR or operated with the 48-bit sub-key, and the sub-key
The resulting steps are as follows:
A, loop left: C and D are cycled left according to the loop left, and the C and D sections after the left shift are
Enter data for the next wheel key until all 16 rounds are complete.
b, merge the C and D sections into 56-bit data.


C, the compression type transposition 2:56 input data according to the Compression type 2 table output 48-bit sub-key, the 48-bit sub-key
The 48-bit plaintext data will be different or manipulated.


  Initial Displacement:
  grouped 64-bit clear text groupings are initially displaced according to the initial permutation table again, with the substitution method such as the following:
  Initial displacement tables are read from left to right and top to bottom. As the first row, the first column is 58. means that the 58th bit of the original plaintext group is displaced
  to 1th bits, and the next number of the initial permutation table is 50, which means that the 50th bit of the grouping of the original plaintext is displaced to the 2nd bit, and so on. All 64-bit permutations of the
  original plaintext group are complete.
           permutation table
         58 2
        60 (4
 &nbs.). p;      62 6
        64 56 8
        57-9  1
    . ;     59 3
        61 53 45 37 29 21 13 5< br>        63 7
 16 wheel cycle
  The 64-bit plaintext data after the initial permutation is generated in the middle 2 parts, each part 32 bits, the left half L0 and the right half part R0. Then
 ,l0 and RO Enter the encryption process.

Ro through a series of permutations to get 32-bit output, and then L0 with the different or operation. The result becomes
The next round of R1,r0 becomes the L1. So continuous operation 16 rounds.
XOR/--xor
Ri = Li-1 XOR f (ri-1,ki)
Li = Ri-1 (i=1,2,3,4.......16)
In each round of the cycle, the right half needs to pass through a series of sub-encryption process, this sub-encryption process is also called F function, sub-encryption
Process contains
A1, extended displacement
A2, XOR, or operation
A3,s box Substitution
A4, Direct replacement
Extended displacement
The right half of the 32-bit plaintext data is first expanded, and the extended permutation expands the 32-bit input data into 48-bit
of output data. Its purpose: 1, produces data with the same length of the key for XOR operation; 2, which provides a longer
Results in the subsequent sub-encryption process can be compressed. 3. It has an avalanche effect. This is also an extended permutation,
The most basic purpose, so that one of the inputs will affect both replacements, so the output dependence on the input will propagate faster
(Avalanche effect), the displacement method of the extended permutation is the same as the substitution table, which expands the substitution table for example the following
Extended Displacement Table
32 1 2 3 4 5
4 5 6 7 8 9
8 9 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 1

The XOR operation is also 0, the difference is 1

s Box replacement
Is the most important part of the algorithm, because the other operations are linear. Easy to analyze, just the S-box is non-linear and it
Provides better security than any other step.
The 48-bit output data that is different or obtained will be replaced by S-box. The replacement is completed by 8 boxes and is recorded as S box.
Each s box has 6-bit input and 4-bit output.
Each s box is different, each S-box replacement method such as the following table, usage: 48-bit input is divided into 8 groups. No group 6-bit
, enter 8 s boxes respectively, and record the 6-bit input for each group as B0B1B2B3B4B5. Then the row number in the table is determined by B0,B5.
The column number is determined by B1 B2 B3 B4.

Like what. The first group of 111000 is going to enter the first s box S1. Then line number (B0B5)
That is, line 2nd, column number bit 1100 (B1B2B3B4) is the 12th column, 2nd row 12th column corresponding data is 3. So the 4 bits of this s box
The output is 3 binary 0011
S[1])
14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
S[2]
15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
S[3]
10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7
1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
S[4]
7 13 14 3 0 6 9 10 1 2 8 5 11 12 4 15
13 8 11 5 6 15 0 3 4 7 2 12 1 10 14 9
10 6 9 0 12 11 7 13 15 1 3 14 5 2 8 4
3 15 0 6 10 1 13 8 9 4 5 11 12 7 2 14
S[5]
2 12 4 1 7 10 11 6 8 5 3 15 13 0 14 9
14 11 2 12 4 7 13 1 5 0 15 10 3 9 8 6
4 2 1 11 10 13 7 8 15 9 12 5 6 3 0 14
11 8 12 7 1 14 2 13 6 15 0 9 10 4 5 3
S[6]
12 1 10 15 9 2 6 8 0 13 3 4 14 7 5 11
10 15 4 2 7 12 9 5 6 1 13 14 0 11 3 8
9 14 15 5 2 8 12 3 7 0 4 10 1 13 11 6
4 3 2 12 9 5 15 10 11 14 1 7 6 0 8 13
S[7]
4 11 2 14 15 0 8 13 3 12 9 7 5 10 6 1
13 0 11 7 4 9 1 10 14 3 5 12 2 15 8 6
1 4 11 13 12 3 7 14 10 15 6 8 0 5 9 2
6 11 13 8 1 4 10 7 9 5 0 15 14 2 3 12
S[8]
13 2 8 4 6 15 11 1 10 9 3 14 5 0 12 7
1 15 13 8 10 3 7 4 12 5 6 11 0 14 9 2
7 11 4 1 9 12 14 2 0 6 10 13 15 3 5 8
2 1 14 7 4 10 8 13 15 12 9 0 3 5 6 11
Direct displacement
The 32-bit output data after the box replacement is directly displaced, which maps each input bit to the output bit. Random One,
Cannot be mapped two times, nor can it be omitted. The use of the direct substitution table is the same as the initial permutation.
Direct Substitution Table
16 7 20 21
29 12 28 17
1 15 23 26
5 18 31 10
2 8 24 14
32 27 3 9
19 13 30 6
22 11 4 25
End permutation
The terminating permutation corresponds to the initial displacement. None of them affects the security of DES. The main purpose is to make the plaintext
And the cipher data in the F algorithm of the byte size into DES, the use of terminating the substitution table and the initial substitution table is the same.

Terminating a replacement table
40 8 48 16 56 24 64 32
39 7 47 15 55 23 63 31
38 6 46 14 54 22 62 30
37 5 45 13 53 21 61 29
36 4 44 12 52 20 60 28
35 3 43 11 51 19 59 27
34 2 42 10 50 18 58 26
33 1 41 9 49 17 57 25

Child key
C and D are 16 rounds of similar operations to produce 16 sub-keys, each wheel key generation must go through the cycle of left-shift and compression-type transposition 2.
The cyclic left shift requires that parts C and D be left-shifted according to the left-hand side of the loop, and the left-shift table gives each round a loop that needs to be left-shifted.
Number of digits, the C and D sections after the left shift of the yellow are used as input data for the next wheel key until all 16 rounds have been completed.
Number of rotation left shift
1 1
2 1
3 2
4 2
5 2
6 2
7 2
8 2
9 1
10 2
11 2
12 2
13 2
14 2
15 2
16 1
After the loop left shift. The C and D sections are merged into 56-bit data. After that, the 56 bits of data have to be compressed, transposition 2
The resulting 48-bit subkey is generated, and the 48-bit sub-key will be XOR with 48-bit plaintext data.
Compression type Transposition 2 substitution Table
14 17 11 24 1 5
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53
46 42 50 36 29 32

??

Packet Password algorithm

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.