II 31 marks]

SECTION II
The Feistel cipher is a symmetric block cipher encryption framework which is the basis of many modern day encryption algorithms. In this coursework you will implement a Feistel cipher system as a software implementation in both a high level language and Hack Assembly.
In a Feistel cipher the plaintext, P, to be encrypted is split into two equal size parts
Lo and Ro such that P = LoRo. A function F is applied to one half of the plaintext,
combined with a key, and the result is XOR’d with the other half of the plaintext.
Feistel ciphers often employ multiple rounds of this scheme. In general the scheme
works as follows, for all i = 0,.
R+1 = L; @ F(R, K;
To decrypt an encrypted message using this cipher we can apply the same procedure
in reverse. For 1 = n, n. –
For this coursework we are interested in the 16-bit Feistel cipher which uses 4 rounds
The function F(A, B) = A © -B.
The keys are derived from a single 8-bit key Ko such that
K1 =bob;babgbabybob
K2 =6564636261bob-b6
K3 = babybbibob-66bs
(a) Write a program (XOR.asm) in HACK assembly that implements an XOR func tion between two 16-bit values stored in RAM 3] and RAM(4] and stores the result in RAMI5].
(b) Write a program (Rotate.asm) in HACK assembly that implements an algorithm to rotate the bits of a 16-bit number left (Least Significant bit (LSb) to Most Significant bit (MSb)). The original number should be stored in RAM 3 the number of times to rotate the bits should be in RAM|4 and the result stored in RAM(5), i.e. 10101111 rotated left 3 times would be 01111101 where the MSb is used to replace the LSb.
(c) Write a program (FeistelEncryption.asm) in HACK assembly, that implements the described Feistel encryption system. The initial key, Ko. will be stored in RAM(1], and the 16-bit plaintext will be stored in RAM|2]. The result of the encryption should be stored in RAM O
[Total for Section II 31 marks]
3. General guidance and study support
Tools required to simulate the hardware and CPU are provided on Minerva under
Learning resources: Software.