C(1) | 0000000000000001111111111110 |
C(2) | 0000000000000011111111111100 |
C(3) | 0000000000001111111111110000 |
C(4) | 0000000000111111111111000000 |
C(5) | 0000000011111111111100000000 |
C(6) | 0000001111111111110000000000 |
C(7) | 0000111111111111000000000000 |
C(8) | 0011111111111100000000000000 |
C(9) | 0111111111111000000000000000 |
C(10) | 1111111111100000000000000001 |
C(11) | 1111111110000000000000000111 |
C(12) | 1111111000000000000000011111 |
C(13) | 1111100000000000000001111111 |
C(14) | 1110000000000000000111111111 |
C(15) | 1000000000000000011111111111 |
C(16) | 0000000000000000111111111111 |
По той же таблице сдвигаем биты в последовательностях
D(0) = 0110011001111000100000001111
D(1) | 1100110011110001000000011110 |
D(2) | 1001100111100010000000111101 |
D(3) | 0110011110001000000011110110 |
D(4) | 1001111000100000001111011001 |
D(5) | 0111100010000000111101100110 |
D(6) | 1110001000000011110110011001 |
D(7) | 1000100000001111011001100111 |
D(8) | 0010000000111101100110011110 |
D(9) | 0100000001111011001100111100 |
D(10) | 0000000111101100110011110001 |
D(11) | 0000011110110011001111000100 |
D(12) | 0001111011001100111100010000 |
D(13) | 0111101100110011110001000000 |
D(14) | 1110110011001111000100000001 |
D(15) | 1011001100111100010000000111 |
D(16) | 0110011001111000100000001111 |
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 |
Для получения последовательности K(i) произведём конкатенацию последовательностей C(i) и D(i). В полученной последовательности C(i)D(i) переставим биты согласно таблице.
K(0) = 010100010010110010001100101001110100001111000000
K(1) | 010100000010110010101100010101110010101011000010 |
K(2) | 010100001010110010100100010100001010001101000111 |
K(3) | 110100001010110000100110111101101000010010001100 |
K(4) | 111000001010011000100110010010000011011111001011 |
K(5) | 111000001001011000100110001111101111000000101001 |
K(6) | 111000001001001001110010011000100101110101100010 |
K(7) | 101001001101001001110010100011001010100100111010 |
K(8) | 101001100101001101010010111001010101111001010000 |
K(9) | 001001100101001101010011110010111001101001000000 |
K(10) | 001011110101000101010001110100001100011100111100 |
K(11) | 000011110100000111011001000110010001111010001100 |
K(12) | 000111110100000110011001110110000111000010110001 |
K(13) | 000111110000100110001001001000110110101000101101 |
K(14) | 000110110010100010001101101100100011100110010010 |
K(15) | 000110010010110010001100101001010000001100110111 |
K(16) | 010100010010110010001100101001110100001111000000 |
По таблице преобразовать последовательности R(i)
32 | 1 | 2 | 3 | 4 | 5 | 4 | 5 | 6 | 7 | 8 | 9 |
8 | 9 | 10 | 11 | 12 | 13 | 12 | 13 | 14 | 15 | 16 | 17 |
13 | 17 | 18 | 19 | 20 | 21 | 20 | 21 | 22 | 23 | 24 | 25 |
24 | 25 | 26 | 27 | 28 | 29 | 28 | 29 | 30 | 31 | 32 | 1 |
R(0) = 11111111111111110101001101110000
E(R(0)) = 011111111111111111111110101010100110101110100001
R(0)K(1) xor = 001011111101001101010010111111010100000101100011
S(1) = 2 = 0010 S(2) = 14 = 1110 S(3) = 9 = 1001 S(4) = 2 = 0010
S(5) = 3 = 0011 S(6) = 3 = 0011 S(7) = 11 = 1011 S(8) = 1 = 0001
Выходная (S1..S8) = 00101110100100100011001110110001
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 |
Результат = 01100110011010000010111110010001
L(0) = 11111111000011010001010000000000
R(0) = 01100110011010000010111110010001
XOR R(1)=10011001011001010011101110010001
L(1) = R(0)
В итоге этих действий появляется новая правая половина, а старая правая половина становится новой левой. Эти действия повторяются 16 раз, образуя 16 этапов DES.
L(1) = 11111111111111110101001101110000
R(1) = 10011001011001010011101110010001E(R1) = 110011110010101100001010100111110111110010100011
R(1) XOR K(2) = 100111111000011110101110110011111101111111100100
S(1..8) = 00101001100011011111100011000100
P = 10110001000111000101001111100001
R(1) XOR L(1) = 01001110111000110000000010010001 = R(2)L(2) = R(1) = 10011001011001010011101110010001
E(R2) = 101001011101011100000110100000000001010010100010
R(2) XOR K(3) = 011101010111101100100000011101101001000000101110
S(1..8) = 00111010001110101000100101000010
P = 01010101010110100010001001000110
R(2) XOR L(2) = 11001100001111110001100111010111 = R(3)L(3) = R(2) = 01001110111000110000000010010001
E(R3) = 111001011000000111111110100011110011111010101111
R(3) XOR K(4) = 000001010010011111011000110001110000100101100100
S(1..8) = 00000111000110110110011111010100
P = 11000110011101000110000011111001
R(3) XOR L(3) = 10001000100101110110000001101000 = R(4)L(4) = R(3) = 11001100001111110001100111010111
E(R4) = 010001010001010010101110101100000000001101010001
R(4) XOR K(5) = 101001011000001010001000100011101111001101111000
S(1..8) = 01001100001100001000101000011100
P = 00011111001010001000000000110100
R(4) XOR L(4) = 11010011000101111001100111100011 = R(5)L(5) = R(4) = 10001000100101110110000001101000
E(R5) = 111010100110100010101111110011110011111100000111
R(5) XOR K(6) = 000010101111101011011101101011010110001001100101
S(1..8) = 01000010100111101110010001001110
P = 01001101010101101001000111101000
R(5) XORL(5) = 11000101110000011111000110000000 = R(6)L(6) = R(5) = 11010011000101111001100111100011
E(R6) = 011000001011111000000011111110100011110000000001
R(6) XOR K(7) = 110001000110110001110001011101101001010100111011
S(1..8) = 01011110010010011000100110010101
P = 11010011000010011010100001110011
R(6) XOR L(6) = 00000000000111100011000110010000 = R(7)L(7) = R(6) = 11000101110000011111000110000000
E(R7) = 000000000000000011111100000110100011110010100000
R(7) XOR K(8) = 101001100101001110101110111111110110001011110000
S(1..8) = 01001010010111110011101010010000
P = 11110110011010011001000011000001
R(7) XOR L(7) = 00110011101010000110000101000001 = R(8)L(8) = R(7) = 00000000000111100011000110010000
E(R8) = 100110100111110101010000001100000010101000000010
R(8) XOR K(9) = 101111000010111000000011111110111011000001000010
S(1..8) = 01110001010110001110000010110010
P = 00000111000001111100011011000011
R(8) XOR L(8) = 00000111000110011111011101010011 = R(9)L(9) = R(8) = 00110011101010000110000101000001
E(R9) = 100000001110100011110011111110101110101010100110
R(9) XOR K(10) = 101011111011100110100010001010100010110110011010
S(1..8) = 10010101100101101010111010000000
P = 00010101111000000101000110011011
R(9) XOR L(9) = 00100110010010000011000011011010 = R(10)L(10) = R(9) = 00000111000110011111011101010011
E(R10) = 000100001100001001010000000110100001011011110100
R(10) XOR K(11) = 000111111000001110001001000000110000100001111000
S(1..8) = 01001001010101100010011101101111
P = 00001100011110111111110010101000
R(10) XOR L(10) = 00001011011000100000101111111011 = R(11)L(11) = R(10) = 00100110010010000011000011011010
E(R11) = 100001010110101100000100000001010111111111110110
R(11) XOR K(12) = 100110100010101010011101110111010000111101000111
S(1..8) = 10001110111111101001000000111000
P = 01101111110010010001010101010100
R(11) XOR L(11) = 01001001100000010010010110001110 = R(12)L(12) = R(11) = 00001011011000100000101111111011
E(R12) = 001001010011110000000010100100001011110001011100
R(12) XOR K(13) = 001110100011010110001011101100111101011001110001
S(1..8) = 10001000011111110111100000101111
P = 10111100110011110001110011100100
R(12) XOR L(12) = 10110111101011010001011100011111 = R(13)L(13) = R(12) = 01001001100000010010010110001110
E(R13) = 110110101111110101011010100010101110100011111111
R(13) XOR K(14) = 110000011101010111010111001110001101000101101101
S(1..8) = 11111011111011000110100110111000
P = 01011010100011011111011111000111
R(13) XOR L(13) = 00010011000011001101001001001001 = R(14)L(14) = R(13) = 10110111101011010001011100011111
E(R14) = 100010100110100001011001011010100100001001010010
R(14) XOR K(15) = 100100110100010011010101110011110100000101100101
S(1..8) = 11101100100000101111010010111110P = 00101011110011101000011110111001
R(14) XOR L(14) = 10011100011000111001000010100110 = R(15)L(15) = R(14) = 00010011000011001101001001001001
E(R15) = 010011111000001100000111110010100001010100001101
R(15) XOR K(16) = 000111101010111110001011011011010101011011001101
S(1..8) = 01000100011111111001110111110111P = 10110111010100111011110001111101
R(15) XOR L(15) = 10100100010111110110111000110100 = R(16)
L(16) = R(15) = 10011100011000111001000010100110
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 |
Вход (L16R16) = 1001110001100011100100001010011010100100010111110110111000110100
Полученная = 00110000 00111001 11101011 01101000 01100110 10011011 00111000 11000101 =
48 57 235 104 102 155 56 197 = 0 9 л hf> 8 Е
Шифрование
Расшифровка