View the step-by-step solution to:

The objective of this lab is to explore the different modes of operation of block ciphers by implementing 5 of the modes. Task Write a program that...

The objective of this lab is to explore the different modes of operation of block ciphers by implementing 5 of the modes.


Task

Write a program that encrypts a given plaintext file with  the given key. The program gets the  name of the file that contains the key, name of the file that contains the plaintext, and a prefix for the  names of the file containing the ciphertexts from the command line. The program will encrypt the plaintext file in the 5 modes below using 128-bit AES and produce a file for each mode below.

1.     EBC

2.     CBC

3.     OFB

4.     CFB (128-bit)

5.     CTR (counter starts with 0)

After  producing the 5 ciphertext files, the program will decrypt these files and store the decrypted texts in 5 separate files.  NoteCBC,OFB, and CFB modes require an initialization vector (IV).  Use the SecureRandom class in Java to generate the IVs. Note that you need to keep these IVs for decryptions in modes CBC, CFB, and OFB.

So, if the program is run by


encrypt key.txt plain.txt cipher


then the program will produce 10 files :

 


cipherECB.txt

cipherCBC.txt

cipherOFB.txt

cipherCFB.txt

cipherCTR.txt

 

cipherECBdec.txt

cipherCBCdec.txt

cipherOFBdec.txt

cipherCFBdec.txt

cipherCTRdec.txt.


 

Note that at the end of a successful run, the files cipherECBdec.txt, cipherCBCdec.txt, cipherOFBdec.txt, cipherCFBdec.txt, cipherCTRdec.txt will all contain the same data which will be the pliantext that you started with. The plaintext will be given in hexadecimal one block per line. You can assume that each line will have 32 hex digits (hence you will NOT need to do any padding.)


Plain text file:

e9e75f740c3411c4879c58e3b13b8b8b

660a71244330950a4e3a1385d717c4b0

8670deb3fd4c2a6fffd96560b9d66647

48b162a4fa317a14e1515ae82aa80209

bde9daeb7995c7866e3ee0e220d8fe3a


Key file:

a619057ba102bfc917aeb04719dedcb9

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question