Sei sulla pagina 1di 9

CSE5NSW

Name: AMIN MAGGANG


Student id: 17619732

Answer Q1.

Figure 1 in the questions


The missing step between F and Final Permutation (FP) in Figure 1 of the question is a swap. The
swap after last round in encryption process is required in symmetric cipher block such as Feistel
cipher structure to prepare an input for decryption process. If there is no swap before FP, the cipher
text will be wrong decrypted in decryption process. This happens because both encryption and
decryption have the same process. The only different is that the use of sub keys are in different
order. It starts from Kn, Kn-1, Kn-2 and so on until the last rounds.

After the last round of encryption process L16 and R16 should be swapped before go to final
permutation so that L16 (in encryption part) will become R16 (in decryption part) and R16 (in
encryption part) will become L16 (in decryption part).
In the first round of decryption process, R16 (in decryption part) which is L16 (in encryption part)
comeback to be L15 (similar as in encryption part) whereas L16 (in decryption part) which is R16
(in encryption part) comeback to be R15 (similar as in encryption part). This will be repeated until
obtain the plain text.

Answer Q2.
R0 = Half Right Block
L0 = Half Left Block
F = function block
Pseudocode of DES encryption based on Figure 1 of the question (assume sub keys K have been put
into F-function as there is no sub Key in the picture).
Encrypt (64 bit plaintext, F-function)
{
Initial_Permute(64 bit plaintext, initial permutation table)
Split (64 bit plaintext to 32-bit R0 and 32-bit L0)
For (round = 1 to 16)
{
Scramble(32 bit of R0, F-function)
XOR(32 bit L0, 32 bit combination of R0 and F-function)
If (round != 16) swap(L0, R0)
}
swap(L0, R0)
Combine(32-bit R0, 32-bit L0 to be 64 bits)
Final_Permute(64 bits combination, final permutation table)
}
Return (Output 64 bits CipherText)

Answer Q3.
Algorithm for IP and FP
In initial and final permutation, P-boxes table is used to permute the 64-bit input according to the
predetermined rule and that generate 64-bit at the output as well. Based on the initial and final
permutation steps below we can see that the the bit input 58th is switched to 1th output of initial
permutation and input bit 1th is switched to bit 40th.

Figure 2 initial and final permutation steps


There are two tables, one for initial permutation and another for final permutation. Both tables
perform reversed process. Basically the values in the table are the output ports. If we have a 64input bit feeds into initial permutation box, the output will follow the ports number in the p-box
table. The following table follows the steps above.
Table 1. initial and final permutation table

IP Algorithm
Input: Plaintext = 64 bits, R = predetermined rules table
Algorithm:
-

X = R(plaintext),
applying permutation on plaintext based on the predefined rules
input bit 58th switch to output bit 1th,
input bit 50th switch to output bit 2nd
and so on..
Returning output 64 bits permutation

FP Algorithm
Input: Plaintext = 64 bits, R = reversed predetermined rules table
Algorithm:
-

X = R(plaintext),
applying permutation on plaintext based on the reversed predefined rules
input bit 58th switch back to output bit 1th,
input bit 50th switch back to output bit 2nd
and so on..

Returning output 64 bits of cipher text

Answer Q4.
Algorithm of F routine in Pseudocode
K = 48-bit sub keys
F_routine(32 bit left_Block, 48 bit subKey)
{
XOR(32 bit left Block, 48 bit sub Key, Output Block 48 bits)
Split(48 bits outpuBlock, an 8 6-bit chunks, 4 row by 16 column table)
For (s-boxes 1 to 8)
{
Substitute(4 row, 16 column, Output Block 32 bits with 4 bits per
box)
}
Permute(32 bit s-boxes, fixed Permutation)
Return(32 bit fixed permutation)
}

Answer Q5.
E-Table:
Table 2. E table

The E table basically is used to expand the halves 32-bits of RI-1 to 48-bit before performing XOR
operation with a 48-bit sub key. The 6 columns of the table is the output port of the expansion box
where every 4-bit input that derived from 32-bit input is feed in. the 8 rows are the 8 6-bit output.
The table basically performs the expansion permutation from 32 bit input to 48 bit output by
mapping all the 4-input bit to 2, 3, 4 and 5 of output bit respectively. Also input bit 4 from previous
session is placed to bit 1 output and input bit 1 from the next session goes to output bit 6.
Based on the table we can see that there are 48 output ports provided where the 48 bit output will
come out. However, there are only 1 to 32 value range as the input. This shows that the expansion
box puts some of the inputs into more than one output.

For example, a 32-bit input feeding to input port 1 to 32 respectively is as follows : 1(port 1) 1 0 1
1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1(port 32). Based on the E table the output
would be:
1
2
3
4
5
6
7
8

1
1
1
1
1
1
0
1
1

2
1
1
0
1
1
0
0
0

3
0
1
1
1
0
0
0
0

4
1
1
1
1
0
0
0
0

5
1
1
1
1
0
1
1
0

6
1
1
1
1
0
0
0
1

If we write in a sequence, the 48-bit output would be: 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 11 1 1 1 1 1 1


10000000010100010100001

S-Boxes
The main purpose of s-boxes is to do a mixing or confusion. There are 8-boxes where each of them
has different tables and has the input of a 6-bit and a 4-bit output. It is clearer from the array of SBoxes below.

Figure 3 array s-Boxes


Table 3. S-boxes table 1.

The table input is constructed using 4 rows by 16 columns. The input values are the table rows and
columns while the output values are decimal number and it is given in the space. 4 rows and 16
columns are defined by the combination of two bits of a 6-bit input whereas another 4 bits inputs
are combined to define the 16 columns.

For example:
The input to S-box 1 is 100110.
With the combination of the 1th and 6th bit we get 10 which is 2 in decimal. Next, the combination
of bits 2, 3, 4 and 5 of input bits would be 3 in decimal. The output can be obtained by looking at
value in row 2 and column 3 which is 7. So that, the 4 binary output would be 0 1 1 1.
Table 3. S-boxes table 2 to 8:
S boxes table 2

S-boxes table 3

S-box table 4

S-box table 5

S-box table 6

S-box table 7

S-box table 8

P-boxes
P-box in the F-function is used to rearrange the 32-bit output from s-boxes and it will give 32-bit
output in accordance with the fixed permutation. This is done so that the 32-bit output from
previous s-boxes will be spread to 4 dissimilar s-boxes in the following rounds.
Table 4. Straight permutation Table:

The table basically describes the relationship between the input and output of the p-box operation.
Based on table we can see that the 16th bit of the input becomes the 1th output bit as well as the 1th
bit input becomes 9th bit output.
Example:
32-bit input:
1

32-bit output:
1

Answer Q6.
Key-mixing stage:
The way keys are generated is by following the key generator picture below.

Figure 4. key generation


The cipher bit normally has 64 bit together with 8 parity bits. However the parity bits will be
dropped and only 56 bits will be the cipher key and they will go to actual round-key generator. This
round key generator will generate 16 round keys in which every round has 48 bits. The 56 bit cipher
key will be split into 2 parts, every part has 28-bit. This 28-bit of the two parts then is shifted left
one or two bit using circular shift. After that these two part will be combined again to create a 56bit. The following table shows the number of shift in every round.
Table 5. for the number of bit shifts:

After combining the 56-bit is compressed using table compression key to produce 48 bits as the
round key. The process will be repeated for 16 times.

Pseudocode of key-generator:
Key_generating(inputBlock: 64-bit Key with Parity)
{
Permute(64-bit key, Parity_Drop table, output 56-bit cipher key)
Split(56-bit cipher Key, 28-bit left Key, 28-bit right Key)
For (round = 1 to 16)
{
Shift_left (28-bit left Key, shift table[round])
Shift_left (28-bit right Key, shift table[round])
Combine (28-bit left Key, 28-bit right Key)
Compression (56 bit combination)
}
Return (48-bit round key output)
}

Answer Q7.
Pseudocode of DES decryption:
R0 = Half Right Block
F = function block
Pseudocode of DES decryption based on Figure 1 of the question (assume that sub keys K have
been put into F-function as there is no sub Key in the figure one of the question).
decrypt (64 bit ciphertext, F-function)
{
Permute(64 bit ciphertext, initial permutation table)
Split (64 bit ciphertext to 32-bit R0 and 32-bit L0)
For (round = 1 to 16)
{
Scramble(32 bit of R0, F-function)
XOR(32 bit L0, 32 bit combination of R0 and F-function)
If (round != 16) swap(L0, R0)
}
swap(L0, R0)
Combine(32-bit R0, 32-bit L0 to be 64 bits)
Permute(64 bits combination, final permutation table)
}
Return 64 bits PlainText _Ouput

Potrebbero piacerti anche