Starting from:

$29.99

COMP3260 Assignment 2 Solution

In this assignment, you will implement DES encryption and decryption of a single plaintext block. Your program will take as input a 64-bit plaintext block and a 64-bit key block (note that only 56 bits of those will be selected by PC-1) and produce as output a 64-bit ciphertext block. You will use your implementation to explore the Avalanche effect of the original DES denoted as DES0, as well as DES1, DES2, and DES3, where in each version an operation is missing in each round as follows:
0. DES0 - the original version of DES
1. DES1 – XOR with a round key is missing from F function in all rounds
2. DES2 – S-boxes are missing from F function in all rounds; instead, inverse 𝐸𝐸−1 of the Expansion Permutation E is used for contraction from 48 bits down to 32 bits
3. DES3 – Permutation P is missing from F function in all rounds

For additional clarity, the encryption algorithm for the four versions of DES is given in the picture bellow.



DES0 DES1 DES2 DES3 In addition to the original plaintext block 𝑃𝑃 and the key 𝐾𝐾, your program should use another plaintext blocks 𝑃𝑃′, such that 𝑃𝑃′ differs from 𝑃𝑃 only in (any of) one bit and another 𝐾𝐾′ differs from 𝐾𝐾 only in (any of) one bit, and use them to explore the Avalanche effect in DES as follows.

The program will encrypt plaintext 𝑃𝑃 under key 𝐾𝐾. Then it will encrypt plaintext 𝑃𝑃′ under key 𝐾𝐾 and it will find the number of different bits after each of the 16 rounds between 𝑃𝑃 under 𝐾𝐾, and 𝑃𝑃′ under 𝐾𝐾.

Similarly, your program will encrypt plaintext 𝑃𝑃 under key 𝐾𝐾′ and it will find the number of different bits after each of the 16 rounds between 𝑃𝑃 under 𝐾𝐾, and 𝑃𝑃 under 𝐾𝐾′.

Your program MUST be well commented, include a header stating the authors and purpose of the program, and be easy to understand. You MUST NOT use any available DES code or a portion of it.

Encryption
INPUT FILE
The following is an example of an input file, where
• the first row is the plaintext 𝑃𝑃
• the second row is the plaintext 𝑃𝑃′
• the third row is key 𝐾𝐾
• the last row is key 𝐾𝐾′
000…0
010…0
111…0
110…0
OUTPUT FILE
The following is a format of an output file (note that the numbers provided are sample values and not necessarily what you will obtain for different inputs):
Avalanche Demonstration
Plaintext P: 000…0
Plaintext P’: 010…0
Key K: 111…0
Key K’: 110…0
Total running time: XXX (second)

P and P’ under K
Ciphertext C: 010…0
Ciphertext C’: 101…1
Round DES0 DES1 DES2 DES3
0 1 1 1 1
1 5 etc

2 20
3 30
4 31
5 34
6 32
7 29
8 36
9 41
10 38
11 29
12 33
13 39
14 36
15 40
16 37

P under K and K’
Ciphertext C: 110…1
Ciphertext C’: 001…0
Round DES0 DES1 DES2 DES3
0 0 etc
1 2
2 18
3 27
4 33
5 41
6 30
7 34
8 37
9 29
10 33
11 40
12 37
13 43
14 38
15 29
16 35
In the above, ‘Round 0’ refers to the plain text before the beginning of the encryption. The column DESi contains the number of bits that differ between the original plaintext 𝑃𝑃 (resp. the original key K), and the intermediate result in each round of the encryption performed by DESi defined above.

Decryption
For decryption, the INPUT FILE should contain the ciphertext and the key, and the OUTPUT FILE should contain the ciphertext, the key and the plaintext.
The following is an example of an input file, where
• the first row is the ciphertext 𝐶𝐶
• the second row is the original key 𝐾𝐾
000…0
111…0
The following is a format of an output file (note that the numbers provided are sample values and not necessarily what you will obtain for different inputs):
DECRYPTION
Ciphertext C: 000…0
Key K: 111…0
Plaintext P: 010…0

Program Requirements

Submission
All assignments must be submitted via Canvas. If you submit more than once, then only the latest will be graded. Your submission should be one ZIP file containing:
• A PDF file that contains outputs of your program
• All source code files
• A text README file that contains instructions to execute your code


Assessment criteria
1 DES encryption and decryption – working and correct 60
2 Avalanche analysis, correct 30
3 Comments throughout the program 10
TOTAL 100
If your DES encryption and decryption are not working correctly you can score at most 40 marks in total.

More products