Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I'm conducting an experiment dealing with differences in padding across different aes operations for my Intro to Crypto class, and the question says OpenSSL uses PKCS5 padding, and that I need to prove this. All we've been taught up to this point was how to encrypt something by doing this:

openssl enc -aes-128-cbc -e -in example.txt -out example.bin -K 1001001 -iv 0100110

Now my question, really, is: Where do you implement the padding into this shell command, or is the padding automatically added, and if it is auto added, why can I not see in it my hex editor?

share|improve this question
    
I'm no openssl expert here, but the documentation states: "All the block ciphers normally use PKCS#5 padding also known as standard block padding". I tried your code from the command line and padding was indeed used. Keep in mind that padding might just be a single byte, depending on the length of the input. –  hunter Oct 22 '13 at 16:56
    
Tha padding is added to the plaintext to get encrypted. If you view the output in cipher text, the padding will not be recognizable. You may still notice existence of the padding from extension of the output. Try to decrypt the ciphertext with -nopad option to find out any possible padding following the cipher text. –  user4982 Oct 22 '13 at 16:58
    
@user4982 - PCKS5 padding is recognizable in the ciphertext by comparing its length with that of the cleartext. –  hunter Oct 22 '13 at 17:01
    
@hunter Like I said, "You may still notice existence of the padding from extension of the output.". It often not possible to distinguish PKCS#5 padding from other possible paddings like "bit padding", ANSI X.923 etc. merely from the size expansion. This is why I suggested decryption. –  user4982 Oct 22 '13 at 19:49

1 Answer 1

up vote 3 down vote accepted

You can decrypt with the -nopad option and check the HEX output.

Example piped command :

$ echo "hi" 
| openssl enc -aes-128-cbc -e -K 1001001 -iv 0100110 
| openssl enc -aes-128-cbc -d -nopad -K 1001001 -iv 0100110 
| hd

And output :

00000000  68 69 0a 0d 0d 0d 0d 0d  0d 0d 0d 0d 0d 0d 0d 0d  |hi..............|
00000010
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.