This lab is to be done individually. Although you may discuss with other students, your answers should be your own.
What to turn in: For this part, turn in answers to the questions.
The openssl program can perform a wide variety of cryptographic operations. It is installed on all computers in the eos lab. Extensive documentation is available through the man pages, and through the program itself.
The openssl enc command is used for encryption and decryption. A full explanation of all of the options for this command is included in the enc man page.
First, let's encrypt a file. You will need to create a small text file to perform these commands on. It only needs to be a few lines of text, enough to be several aes blocks. Make the file more than ten but less than hundreds of lines, or try using the source code to a program you have written. I'll assume it is called testfile.txt.
To encrypt the file using 128 bit aes in electronic codebook mode (each block is encrypted independantly), the command is:
openssl enc -aes-128-ecb -in testfile.txt -out testfile.txt.aes -K 'E33202510575DF98CD66D5F35A1915D0' -iv '582221FEB84119C54FC41FBED8E9D778'
While you are not yet expected to understand all the terms used, briefly this command is doing the following:
The key and IV can be any hex string of appropriate length. They are often randomly generated. Use the same key and IV for each command in this section.
You can use the xxd command to get a hex dump of your encrypted file (you will have to pipe the output to another file). Modify one byte somewhere in the middle of the hex dump, then use xxd -r to convert the hex dump back to a binary file. Now, try to decrypt the modified encrypted file.
Now, make a copy of your plaintext, but try changing (replacing, not adding or deleting) a couple characters in the middle of it. Encrypt the modified version, and compare the result with the encrypted original version (it may be easier to compare hex dumps of each).
Now that you have some experience with openssl, I will provide less details. It will be up to you to figure out the exact commands. This time we are using public key cryptography. This is only designed to operate on a small amount of data, so run it on a very small file.
Complete the following tasks: