Silly question – is it possible to find out size of original file from encrypted file? Encrypted with aes-128-cbc. Looks like there is no way to calculate it. As far as I understand ,all original files with length between let’s say 33 and 47 will have length 48 bytes after aes-128-cbc encryption (should be rounded to next 16 byte block). But, just in case asking the crowd 😊
Update: Well, I’m not mathematician, just a programmer, and the formula provided in an answer below means not much for me ☹ so I need more plain explanation how I could that. The story is - I encrypt files (longer than 48 bytes 😊) by using standard Node.js module (crypto). I ask this module to use aes-128-cbs algorithm (but, generally speaking, I could use others algorithms) and I know the key, the key length, the IV. Looks like I need to read last 2 blocks (32 bytes) of a encrypted file, give them to decipher, it will not be able to correctly decrypt penultimate block due to luck of IV, but should decrypt very last one. What I suppose to do with this data (last decrypted block)? How EXACTLY I can calculate size of original file knowing content of last block, the key, the key length etc? Thanks a lot in advance.
I know the key, the key length, the IVand
penultimate block due to luck of IV$\endgroup$