Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When changing a (small) part of the plaintext of a CBC-encrypted file, how much of the file will have to be rewritten?

My suspicion is that everything after the modified block will have to be decrypted and reencrypted as well, due to the changes of the ciphertext blocks cascading through the rest of the file.

share|improve this question
up vote 7 down vote accepted

If you could use the same IV, then yes, you would need to rewrite everything after the modified block.

But you shouldn't do that; every time the contents change, you should generate a new IV, which would require the whole file to be rewritten. Otherwise an attacker can learn more information than it should about how the file changed (precisely by checking which blocks of the file have changed).

share|improve this answer

As @Conrado stated this should not be done as it leaks some information that can be used by an attacker in order to make some statistical analysis. According to theory this is the diffusion property that a cryptosystems must hold: One bit flipping in the plaintext must change as much as possible the the bits on the ciphertext. The linear parts of a block cipher as AES achieve this.

share|improve this answer

Your Answer


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.