One of my professors mentioned in class that there is a way of using PKCS#7 padding to have the padding persistent after decryption.
For example, if I encrypt a 20-byte file using
openssl enc -aes-128-ecb -in input.txt -out encrypted.txt -K 0123456789 -v
I obviously get the padded difference of:
bytes read : 20
bytes written: 32
So 12 bytes of padding was added.
After decryption of the file, I want the padding to remain.
The only method I could think of was making the bytes in the original input.txt
file the same character that PKCS#7 uses to pad, so that when it's time to unpad, it doesn't know what to unpad. I haven't been able to find exactly which character it uses, or if it's not a character. I've read some about the standard here and here, but with no real luck.
I'm still reading on it, but I haven't had any eureka moments yet.
An example of what I'm looking for would be if I gave it a 4-byte file such as:
AAAA
And it encrypted it, but added 12 bytes of C at the end, I'd want the decrypted file to be:
AAAACCCCCCCCCCCC