Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.