ONLY PART B PLEASE!!! Implement the Tiny Encryption Algorithm (TEA). a. Use your
ID: 3884136 • Letter: O
Question
ONLY PART B PLEASE!!!
Implement the Tiny Encryption Algorithm (TEA). a. Use your TEA algorithm to encrypt the 64-bit plaintext block 0x0123456789ABCDEF using the 128-bit key OxA56BABCD00000000FFFFFFFFABCDEF01. Decrypt the resulting ciphertext and verify that you obtain the original plaintext. b. Using the key in part a, encrypt and decrypt the following message using each of the three block cipher modes discussed in the text (ECB mode, CBC mode, and CTR mode). Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.Explanation / Answer
import java.math.BigInteger; public class TEA { BigInteger [] K ; //128 bits key private String plainText; public static final BigInteger delta = new BigInteger("9e3779b9",16); //constructor receives a string of plaintext and 128 bit key in hexadecimal public TEA(String plainText, String key) { parseKey(key); } //constructor receives a hexadecimal public TEA(String key) { parseKey(key); } //parses a 128 bit key, given in hexadecimal form, and store its value in 4 integers (total of 128 bits), private void parseKey(String key) { if(key.substring(0,2).equals("0x")) key= key.substring(2); //validating input if(key.length() != 32) { System.out.println("Invalid key size!"); return; } //dividing the key into 4 strings String[] kStr = new String[4]; int index=-1; for(int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.