Hi Thulasi,You are right! It's a bug on my part.
I have a follow-up question regarding what EVP_DecryptFinal is doing.In my case, the original string is 27 bytes long, the ciphertext length is 48 ( I am using AES-CBC-128). The decrypted plaintext before finalization is 32 but the finalization added 11 more bytes. So the total decrypted len is 43.
Can you explain where the 11 more bytes are coming from after finalization? Also It seems OK even if I don't use finalization,
Just wanted to say that Thulasi’s explanations and advice are exactly correct; thanks!
--
Principal Security Engineer
Akamai Technologies, Cambridge MA
IM: rs...@jabber.me Twitter: RichSalz
Hi Thulasi/Rich,Thanks! This prompted me to uncover another bug in the code. I did encrypt an extra block of zeros! Now everything makes sense.Can't help to dig a little deeper into this: In AES-CBC mode, the decryption can be paralleled. Is this what the EVP_DecryptUpdate is doing behind the scene?
For example, I need to break a long string into blocks to use EVP_EncryptUpdate but I only need to feed the ciphertext into EVP_DecryptUpdate once.