Now I understand your answer to my first question: The process takes this way:
+ The IV(16-byte zeros) XOR the first 16-byte of plaintext (which is a random number); + Use the key to encrypt the result then we get the first block of ciphertext + Feed this block as an input (we can see this block as an IV to the next round encryption) XOR the next block of plaintext + The real plain text encryption takes place from here... On Oct 17, 3:54 am, Mouse <[EMAIL PROTECTED]> wrote: > > I am reading this to get some hints about how to use crypto++ > > to en/ decrypt files. I am a bit confused by Mouse's answer > > though. I have two questions here: > > > + Why did he choose 16-byte zeros as the initial vector for CBC mode? > > Because for the sake of correctness, one should set IV to something. And > since you did not provide the means to transfer the "real" IV to the > decryptor - I chose to set it explicitly to something simple such as all > zeroes. It is cryptographically OK because the plaintext is prefixed with > random 16 bytes (that serve cryptographically as IV - though they are *not* > IV). > > > Apparently my guess is wrong and it seems the first 16-byte > > random prefix of the file is used as the real initial vector. > > No, don't mix IV (that is explicitly fed to the crypto engine) with prefix > (that is prepended to the data). End result is similar - but the processing > is very different. > > > If the file prefix guess is true then how can the decryptFile > > function decrypt the first 16-byte without knowning the IV. > > The first 16 bytes of the file decrypt into garbage because decryptor > doesn't have the correct IV - but since your random prefix carries no > information anyway, the only symptom of your error is that your decrypted > text is prepended with 16 garbage bytes. > > > + how does the function call cbcDecryption.ProcessData((byte > > *)garbage, (const byte *)iv_garbage, 16); make the decryptor state > > adjust to IV, and file position pointer advance to the past-IV spot. > > I leave this as a home exercise. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [EMAIL PROTECTED] More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
