In: Computer Science
Using Ubuntu SeedLab
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:
1. 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.
2. 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" > f1.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 p1.txt 00000000 31 32 33 34 35 36 37 38 39 49 4a 4b 4c 0a |123456789IJKL.
$ xxd p1.txt 00000000: 3132 3334 3536 3738 3949 4a4b 4c0a
123456789IJKL.
Answer 1
*********
In Electronic Code Book (ECB) and Cipher Block Chaining (CBC) mode
require their contribution to be a careful various of the square
size. On the off chance that the plaintext to be encoded isn't a
precise various, you have to cushion before scrambling by including
a cushioning string. While unscrambling, the getting party has to
realize how to expel the cushioning in an unambiguous way.
CFB and OFB do not need padding
Answer 2
*********
encrypted size if 32 bytes as shown in the screenshot
and padded bytes are 0b 0b 0b 0b
in decimal its 11
in octal its 13
in binary its 1011
if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)