$30
Task I (90%): Write two Java* programs, one for encryption and the other for decryption, to implement TEA
(modified from Textbook): Perhaps the simplest “serious” symmetric block L0 R0 encryption algorithm is the Tiny Encryption Algorithm (TEA). TEA operates on 64- bit blocks of plaintext using a 128- bit key. The plaintext is divided into two 32- bit blocks (L0, R0), and the key is divided into four 32-bit blocks (K0, K1, K2, K3). As shown in the diagram, encryption involves repeated application of a pair of rounds, defined as follows for rounds i and i + 1 (i starts with 1):
Li = Ri-1 Ri = Li-1 ⽥ F(Ri-1, K0, K1, δi)
Li+1 = Ri Ri+1 = Li ⽥ F(Ri, K2, K3, δi+1) where F is defined as
F(X, Km, Kn, δy) = (( X << 4) ⽥ Km) Å ( (X 5) ⽥ Kn) Å (X ⽥ δy)
and where the logical left shift of x by y bits is denoted by x << y; the logical R1 right shift of x by y bits is denoted by x y; δi (Deltai) is a sequence of predetermined constants; and ⽥ denotes addition-mod-232.
a. If only one pair of rounds, i.e., rounds 1 and 2, is used, then the ciphertext is the 64- bit block (L2, R2). You may express the encryption algorithm by representing L2 as a function of L0, R0, K0, K1, and δ1, and representing R2 as a function of L2, R0, K2, K3, and δ2.
b. The decryption algorithm is given as below. You may verify it by reverting the calculation in the block diagram.
R0 = R2 ⽈ [[(L2 << 4) ⽥ K2] Å [L2 ⽥ δ2] Å [(L2 5) ⽥ K3]] L0 = L2 ⽈ [[(R0 << 4) ⽥ K0] Å [R0 ⽥ δ1] Å [(R0 5) ⽥ K1]] where ⽈ denotes subtraction-mod-232.
Program TEA_Encryption: Write a Java program to implement TEA Encryption including only one pair of rounds: rounds 1 and 2 • Data and inputs: o declare a constant int DeltaOne with a hex value of 0x11111111 o declare a constant int DeltaTwo with a hex value of 0x22222222
o declare an int array with 4 elements: K[0], K[1], K[2], and K[3], get their values via user inputs in Hex strings
For each element K[i], where i = 0, 1, 2, or 3, display the following prompt message, read the user input as a String, and then convert the user input String into an integer by treating it as a Hex value, and assign this integer to K[i]. E.g., if the user input is “F3579BD1” for K[0], then K[0] = 0xF3579BD1.
Please input K[i] in Hex String (without “0x”): o declare two int arrays L[ ] and R[ ], each having a size of 3.
MSU Denver, M&CS CS 3750: Computer and Network Security, Fall 2019 Dr. Weiying Zhu
For each of L[0] and R[0], display a prompt message like the following one for L[0], read the user input as a String, and then convert the user input String into an integer by treating it as a Hex value, and assign this integer to L[0] or R[0]. E.g., if the user input is “2468ACE0” for L[0], then L[0] = 0x2468ACE0.
Please input L[0] in Hex String (without “0x”):
Initialize L[1], L[2], R[1], and R[2] as 0x00000000’s.
• The program and outputs: o Implement the encryption algorithm to calculate L[1] and R[1] first, and then L[2] and R[2]
o Display the hex values of L[i] and R[i], where i = 0, 1, and 2, in Hex strings. E.g., assuming L[0] = 0x2468ACE0,
L[0] = 2468ACE0 R[0] = …… L[1] = …… R[1] = ……
L[2] = …… R[2] = ……
Program TEA_Decryption: Write a Java program to implement TEA Decryption including only one pair of rounds: rounds 1 and 2 • Data and inputs: o declare a constant int DeltaOne with a hex value of 0x11111111 o declare a constant int DeltaTwo with a hex value of 0x22222222
o declare an int array with 4 elements: K[0], K[1], K[2], and K[3], get their values via user inputs in Hex strings
For each element K[i], where i = 0, 1, 2, or 3, display the following prompt message, read the user input as a String, and then convert the user input String into an integer by treating it as a Hex value, and assign this integer to K[i]. E.g., if the user input is “F3579BD1” for K[0], then K[0] = 0xF3579BD1.
Please input K[i] in Hex String (without “0x”): o declare two int arrays L[ ] and R[ ], each having a size of 3.
For each of L[2] and R[2], display a prompt message like the following one for L[2], read the user input as a String, and then convert the user input String into an integer by treating it as a Hex value, and assign this integer to L[2] or R[2]. E.g., if the user input is “2468ACE0” for L[2], then L[2] = 0x2468ACE0.
Please input L[2] in Hex String (without “0x”):
Initialize L[0], L[1], R[0], and R[1] as 0x00000000’s.
• The program and outputs: o Implement the decryption algorithm to calculate L[1] and R[1] first, and then L[0] and R[0]
o Display the hex values of L[i] and R[i], where i = 2, 1, and 0, in Hex strings. E.g., assuming L[2] = 0x2468ACE0,
L[2] = 2468ACE0 R[2] = …… L[1] = …… R[1] = …… L[0] = …… R[0] = ……
Task II (10%): Test your program on the virtual server.