Secret Key Encryption Lab |
Secret Key Encryption Lab
Overview
The goal of this lab is for students to become acquainted with the basics of secret-key encryption. Students should be able to obtain first-hand experience with encryption algorithms, encryption modes, paddings, and starting vectors after completing the lab (IV). Students will also be able to encrypt and decrypt messages using tools and applications. The following subjects are covered in this lab:
• Secret-key encryption
• Substitution cyphers and frequency analysis
• Encryption modes and paddings
• Crypto library programming
Environment in the Laboratory This lab was tested on our pre-built Ubuntu 12.04 and Ubuntu 16.04 virtual machines, both of which are available for download on the SEED website.
2 Lab Assignments
2.1 Frequency Analysis Against Monoalphabetic Substitution Cipher is the first task.
Because it may be exposed to frequency analysis, monoalphabetic substitution cypher (also known as mono alphabetic cypher) is recognised to be insecure. In this lab, you will be given a cipher-text that has been encrypted using a mono alphabetic cypher, which means that each letter in the original text has been substituted by a letter that does not vary (i.e., a letter is always replaced by the same letter during the encryption). Your task is to use frequency analysis to locate the original text. The original text is an English article, as far as we know.
We will describe how we encrypt the original article and what simplifications we have made in the following sections. Instead of requesting students to utilise the ciphertext created by us, instructors can use the same procedure to encrypt an article of their choice.
• Step 1: Let's simplify the original article a little bit. All uppercase letters were converted to lowercase letters, and all punctuation and digits were eliminated. The gaps between words are preserved, so you can still discern the word boundaries in the ciphertext. Spaces will be deleted in real encryption using a monoalphabetic cypher. To make the process easier, we preserve the spacing. We used the following command to accomplish this:
$ tr [:upper:] $ tr [:lower:] $ tr [: [:lower:] lowercase.txt > article.txt tr -cd '[a-z][n][:space:]' $ tr -cd '[a-z][n][:space:]' plaintext.txt > lowercase.txt
Secret-Key Encryption Lab 2 at SEED Labs
• Step 2: Create the encryption key, also known as the replacement table. Using Python, we'll permute the alphabet from a to z and utilise the permuted alphabet as the key. Look at the following video.
>>> python $ >>> Import random >>> s = "abcdefghijklmnopqrstuvwxyz" >>> s = "abcdefghijklmnopqrstuvwxyz" random.sample(s, len(s)) >>> list = random.sample(s, len(s)) 'sxtrwinqbedpvgkfmalhyuojzc'.join(list)
• Step 3: To encrypt data, we utilise the tr command. We encrypt only letters, leaving the space and return characters unencrypted.
$ tr 'abcdefghijklmnopqrstuvwxyz"sxtrwinqbedpvgkfmalhyuojzc' plaintext.txt > ciphertext.txt plaintext.txt plaintext.txt plaintext.txt plaintext.txt plaintext.txt plaintext.txt plaintext.txt plaintext.
Using a separate encryption key, we've constructed a ciphertext (not the one described above). It's available for download on the lab's website. Your task is to figure out the encryption key and the original plaintext using frequency analysis.
Guidelines. You can easily get the plaintext for some of the characters using frequency analysis. You might wish to turn those characters back to plaintext to see if you can glean any additional clues. It is preferable to use capital letters for plaintext so that we can distinguish between plaintext and ciphertext for the same letter. You may do this with the tr command. For example, in in.txt, we replace letters a, e, and t with letters X, G, and E, respectively, and save the results in out.txt.
tr 'aet' 'XGE' in.txt > out.txt $ tr 'aet' 'XGE' in.txt > out.txt
You can use a variety of online resources. The following are four helpful links:
•http://www.richkni.co.uk/php/crypta/freq.php : (http://www.richkni.co.uk/php/crypta : This site can generate statistics for a ciphertext, such as single-letter frequencies, bigram frequencies (2-letter sequence), and trigram frequencies (3-letter sequence), among other things.
2.2 Task 2: Different Ciphers and Modes for Encryption
We'll experiment with several encryption techniques and modes in this exercise. You can encrypt and decrypt a file with the openssl enc command. Type man openssl and man enc to access the manuals.
-K 00112233445566778889aabbccddeeff -iv 0102030405060708 $ openssl enc -ciphertype -e -in plain.txt -out cipher.bin
Secret-Key Encryption Lab 3 at SEED Labs
Please use a specified cypher type instead of ciphertype, such as -aes-128-cbc, -bf-cbc, -aes-128-cfb, and so on. You should try at least three different cyphers in this job. By typing "man enc," you can learn about the command-line parameters and all of the supported cypher types. The following are some common arguments for the openssl enc command:
-e encrypt -in input file -out output file decryption -d The next argument is -[pP] -K/-iv key/iv in hex. the iv/key should be printed (then exit if -P)
2.3 Task 3: ECB vs. CBC Encryption Mode
The file image original.bmp, which contains a simple picture, can be obtained from this lab's website. We'd like to encrypt this image so that only those with the encryption keys may see what's inside. Please encrypt the file using the ECB and CBC modes, and then do the following:
1. We'll treat the encrypted image as a picture and display it with picture-viewing software. In any case, The first 54 bytes of a.bmp file contain picture header information, which we must set appropriately so that the encrypted file can be considered as a legitimate.bmp file.
Post a Comment
Post a Comment
Please don't enter any span link or word in comment box. Thanks