The learning objective of this coursework is for you to become familiar with the concepts in symmetric
encryption. After finishing the coursework, you should have first-hand experience on encryption algorithms,
encryption modes, and initialisation vectors (IV). Moreover, you will be able to use tools and write simple
scripts or programs to encrypt/decrypt messages.
This is an independent coursework and you are expected to work on your own to complete the coursework tasks. Your coursework submissions will be automatically checked for plagiarism. Here are some
further points to take into consideration:
• Coursework reports must be written in your own words and any code in your coursework must be your own
code. If some text or code in the coursework has been taken from other sources, these sources must be
• Failure to reference work that has been obtained from other sources or to copy the words and/or code
of another student is plagiarism and if detected, this will be reported to the School’s Discipline
Committee. If a student is found guilty of plagiarism, the penalty could involve voiding the course.
• Students must never give hard or soft copies of their coursework reports or code to another student.
Students must always refuse any request from another student for a copy of their report and/or code.
• Sharing a coursework report and/or code with another student is collusion, and if detected, this will be
reported to the School’s Discipline Committee. If found guilty of collusion, the penalty could involve
voiding the course.
• And remember: the consequences of taking unacceptable short cuts in coursework are much worse than
getting a bad mark (or even no marks) on a piece of coursework. There has been one case this year
where a student was awarded on Ordinary degree (rather than an Honours degree) because
of the sanction imposed by the University’s Discipline Committee. The offence was plagiarism of
You are required to submit a coursework report. At the end of each task, the information that you need
to provide to answer the task is indicated. For further information, including submission, see Section 4.
2 Lab Environment for Coursework
The tasks in this lab require access to a computing device that runs Linux OS. There are a few ways for you
to do this:
OpenSSL. In this lab, we will use openssl commands and libraries, which are installed on all Linux
lab machines. To confirm that you have openssl on your personal machine, your can type either of the
|OpenSSL 1.1.1||11 Sep 2018|
% which openssl
3 Coursework Tasks
3.1 Task 1: Frequency Analysis: Monoalphabetic Substitution Cipher
It is well-known that monoalphabetic substitution cipher is not secure because it can be subjected to frequency analysis. In this task, you are given a ciphertext that is encrypted using a monoalphabetic cipher;
namely, each letter in the original text is replaced by another letter, where the replacement does not vary
(i.e., a letter is always replaced by the same letter during the encryption). However, note that the shift
amount for each letter varies (i.e., amongst the alphabet of plaintext characters, the shift amount for the
encryption varies). Your job is to find out the original text using frequency analysis. It is known that the
original text is an English article. Each student is assigned a different ciphertext file, for which a different
plaintext file and different key was used for encryption. There is a pdf file on Canvas that matches
your name to the ciphertext filename that you must use
Note that the plaintext was modified before encrypting, so that all upper case letters have been converted
to lower cases, all the punctuations and numbers were removed. However, the spaces between words were
maintained in the plaintext (and appear as corresponding spaces in the ciphertext), so that you can still see
the boundaries of the words in the ciphertext.
Your task is to use frequency analysis to figure out the encryption key and the original plaintext.
Using the frequency analysis, you can find out the plaintext for some of the ciphertext characters quite
easily. For those characters, you may want to change them back to its plaintext, as you may be able to get
more clues. It is better to use capital letters for plaintext, so for the same letter, we know which is plaintext
and which is ciphertext. You can use the tr command to do this. For example, in the following, we replace
letters a, e, and t in in.txt with letters X, G, E, respectively; the results are saved in out.txt.
$ tr aet XGE < in.txt > out.txt
There are many online resources that you can use. We list four useful links in the following:
• https://onlinetoolz.net/letter-frequency: This website can produce the statistics
fro a ciphertext, including the single-letter frequencies, bigram frequencies (2-letter sequence), and
trigram frequencies (3-letter sequence), etc.
• https://en.wikipedia.org/wiki/Frequency_analysis: This Wikipedia page provides frequencies for a typical English plaintext.
• https://en.wikipedia.org/wiki/Bigram: Bigram frequency.
• https://en.wikipedia.org/wiki/Trigram: Trigram frequency.
In your report, include
• A short description (no more than a page) that explains what you did in your attempt to discover
the encryption key and the original plaintext. This description should indicate how you decrypted
various ciphertext letters, e.g., whether you used the single letter frequency analysis, bigram or trigram
frequencies, or some other reason to guess a particular plaintext character.
• The encryption key. You should write this as an encryption table that shows the mapping of each
plaintext letter to its corresponding ciphertext letter.
• The plaintext, included as an appendix in your report.
3.2 Task 2: Encryption Mode — Corrupted Cipher Text
To understand the properties of various encryption modes, we would like to do the following exercise:
1. Create a text file that is exactly 128 bytes long. To do this, use numbers or alphabetic characters for
your text each of which are 8 bits in length. Create your file with the command echo -n ‘‘YOUR
TEXT HERE’’ > 128bits.txt where you enter your 128 bytes of text in between the quotation
2. Encrypt the file using the AES-192 cipher, separately for each of the encryption modes of operation:
ECB, CBC, CFB, and OFB, using the appropriate key and iv as required by each mode. Include the
-nopad option in your encryption and decryption commands.
3. Assume that the 55th byte of each of the ciphertext files has been corrupted (don’t worry about how
this might have happened) and you’ve been instructed by your manager to remove the block containing
this byte. Thus, create new ciphertexts that remove this block.
4. Decrypt each new ciphertext file using the same key and initialisation vector (IV) as used to encrypt,
including again the -nopad option.
5. Observe the plaintexts that result from decrypting each new ciphertext file. You should explain what
you observe (i.e., in terms of what plaintext blocks are missing or corrupted and why) by using the
equations for the modes of operation.
In your report, include
• Screenshots to demonstrate your original plaintext, plaintext encryption, creation of the new ciphertexts, and recovered plaintexts for each of the four modes of operation.
• An explantion of the results, including a comparison between the modes.
3.3 Task 3: Partial known-plaintext attack
Download the English word list (words.txt) from Canvas. Each student is assigned a different ciphertext
file, for which a different key and plaintext file was used for encryption. There is a pdf file on Vision
that matches your name to the ciphertext filename that you must use for this task. The
Here is what you know:
• The plaintext was encrypted using 128-bit AES with CBC mode.
• The plaintext was encrypted using a password from the dictionary file words.txt that is shorter
than 16 characters, with a single digit from 0-9 appended to the word before encryption. A key was
generated from the password using the SHA-256 message digest with no salting performed.
• The plaintext consists of a short sentence “The secret word is: ” (with no carriage return or line feed)
that is followed by another word from the dictionary file. Thus you have partially known plaintext
corresponding to your ciphertext.
Your goal is to write a program using a shell script to find out the password and the plaintext, using
the downloaded English word list, and your ciphertext file. As part of your script you should use the commandline tools provided by openssl to encrypt and decrypt messages in order to perform a brute-force
cryptanalysis. Your script should also be clear (e.g., appropriate variable names, and suitably commented),
flexible (e.g., using variables and not hard-coded values, and taking options from the command line), efficient (e.g., complete in the least number of steps) and clearly present output (e.g., redirect unnecessary
Reflections on security: Give a critical analysis explaining why this attack is successful, and describe a
few countermeasures that could be put in place to reduce the likelihood of the attack (i.e., if done differently,
how might the encryption have been performed in order to mitigate the attack). You should also explain
why you believe that your countermeasures would be effective at mitigating this attack, e.g,. why, with your
countermeaures in place, an attack would take longer to execute.
In your report, include
• A short description (no more than a page) that explains what you did in your attempt to discover the
encryption key. Your description should talk about the key components of your script, and should
explain how may have validated the correct operation of key components.
• A copy of your script. Your script should be well commented to explain what is happening in the
script. Your script should also be flexible (e.g., using variables and not hard-coded values, and taking
options from the command line), efficient (e.g., finds the key in the least number of steps) and clearly
presents output (e.g., redirects unnecessary errors).
• Your reflections on security.
• A screenshot(s) to show the execution of your script.
Using shell scripting and command line openssl
As an example of how to process the word list file for another purpose, is available in the line count script
on Canvas (line count.sh) which reads text from a file and counts the number of lines. You will have to
replace the body of the loop by calls to the appropriate openssl command and checking the result file.
Hans-Wolfgang Loidl has kindly provided a screen-cast explaining the steps of the line count
Hint: to speed up development, test your script on a self encrypted, short text, and use a much shorter
word list; once your solution works for your own text, run it on the given text and the
You should submit a report to describe what you have done and what you have observed. With each task
above, some guidance is provided on what to include in your report. You should also explain any observations that are interesting or surprising. Document any difficulties that you met while doing any of the
In your report, you need to answer all the points listed for each task. Structure the report in sections,
addressing each of the tasks. Include an introduction section, discussing what you expect to learn from the
assignment in general (and for each task), and describe the environment that you used to complete the tasks
(e.g., what machines, software and versions). Include a summary/conclusion section, where you discuss
whether your expectations were met, highlighting issues of particular importance, what you learned (overall
and for each task), and suggesting further work, i.e. what kind of exercise could be done next building on
the material from this assignment. In writing-up the work you performed on the above tasks, make sure to
assess the strengths and weaknesses of the ciphers and modes used in for this assignm
- Assignment status: Already Solved By Our Experts
- (USA, AUS, UK & CA PhD. Writers)
- CLICK HERE TO GET A PROFESSIONAL WRITER TO WORK ON THIS PAPER AND OTHER SIMILAR PAPERS, GET A NON PLAGIARIZED PAPER FROM OUR EXPERTS