Question: 3 Task 3 : Padding For block ciphers, when the size of a plaintext is not a multiple of the block size, padding may be

3 Task 3: Padding
For block ciphers, when the size of a plaintext is not a multiple of the block size, padding may be required.
All the block ciphers normally use PKCS#5 padding, which is known as standard block padding. We will
conduct the following experiments to understand how this type of padding works:
Use ECB, CBC, CFB, and OFB modes to encrypt a file (you can pick any cipher). Please report
which modes have paddings and which ones do not. For those that do not need paddings, please
explain why.
Let us create three files, which contain 5 bytes, 10 bytes, and 16 bytes, respectively. We can use
the following "echo -n" command to create such files. The following example creates a file f1.txt
with length 5(without the -n option, the length will be 6, because a newline character will be added
by echo):
$echo -n "12345"> fl.txt
We then use "openssl enc-aes-128-cbc-e" to encrypt these three files using 128-bit AES with CBC
mode. Please describe the size of the encrypted files.
We would like to see what is added to the padding during the encryption. To achieve this goal, we
will decrypt these files using "openssl enc-aes-128-cbc-d". Unfortunately, decryption by default
will automatically remove the padding, making it impossible for us to see the padding. However,
the command does have an option called "-nopad", which disables the padding, i.e., during the
decryption, the command will not remove the padded data. Therefore, by looking at the decrypted
data, we can see what data are used in the padding. Please use this technique to figure out what
paddings are added to the three files.
It should be noted that padding data may not be printable, so you need to use a hex tool to display
the content. The following example shows how to display a file in the hex format:
$ hexdump-C pl.txt
00000000
$ xxd pl.txt
00000000:313233343536373839494a4b 4c0a 123456789IJKL.
Submission for Task 3(20 points)
(1) Which modes have paddings and which ones do not? How did you know if a mode has a padding
through the encrypted file? For those that do not need paddings, please explain why. Please also list the
commands that you used in step 1.(5 points)
(2) Please describe the size of the encrypted files which are encrypted in step 2?(5 points)
(3) What paddings are added to the three files in step 2? Please attach the screenshots of decrypted files
with paddings (i.e., decrypt the files with "-nopad").(10 points)
3 Task 3 : Padding For block ciphers, when the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!