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.

Theoretically, when using a symmetric block cipher in CBC mode, the current block is dependent on the previous block. Suppose one plaintext is encrypted using CBC, and then one bit of it is changed, let's say somewhere in the middle. Then the new ciphertext will change from the middle onward. Would it be better if I used CBC like this?

  1. encrypt plaintext
  2. reverse the ciphertext
  3. continue encrypting (now from finish to start)

That would ensure that one modification to the plain text will change the entire new ciphertext. Right?

share|improve this question
    
Yes, but using an IV you are already making sure two similar messages that start the same don't encrypt to the same ciphertext. And using a MAC (which I am confident you are doing) will let you catch any integrity (and/or authentication) failure, if you were thinking of using this as some kind of safeguard against transmission errors. Basically, my question is, why do you need this property? –  Thomas Apr 9 '13 at 7:35
    
I'm not thinking of transmitting this data... It's about stored data. But that data might be sent to another device to sync with it. So you are saying I need a new IV for every encryption ? –  Clau Apr 9 '13 at 7:37
2  
Absolutely, every distinct message encrypted with CBC should (almost always) use a fresh new IV. Using the same IV for multiple messages is the number one cryptographic failure and while it isn't as devastating for CBC as for some other modes, it's still a major weakness. Still wondering, though, why is it important that the whole ciphertext changes if any one bit is changed? –  Thomas Apr 9 '13 at 7:41
    
@Thomas, care to write your comments up as an answer? –  mikeazo Apr 9 '13 at 14:35
    
@mikeazo Done.. –  Thomas Apr 9 '13 at 14:58
add comment

3 Answers 3

Your problem is that if you encrypt two messages which start the same (and change at some point later on) the beginning of the ciphertext will be the same in CBC mode when using the same IV.

Normally you should change the IV every time you encrypt a new message. This is precisely what the IV is meant for - achieving IND-CPA (semantic) security which prevents an attacker from detecting where the the message was changed. Once you do this, your concerns go away, since even two similar messages (say, an old document, and a newer, slightly revised one) will be encrypted with completely different IV's, and hence their ciphertext will be unrelated. And you don't need a two-pass scheme anymore!

share|improve this answer
add comment

It looks like what you are describing is comparable to IGE (Infinite Garble Extension) and especially biIGE mode of encryption.

So I guess my question and the answer on my question here is of relevance.

share|improve this answer
    
April? Sheesh, I'm kicking old cows :) –  owlstead Nov 25 '13 at 20:21
add comment

You need to use different IV for every message you encrypt. Thus rather than the process:

  1. encrypt plaintext
  2. reverse the ciphertext
  3. continue encrypting (now from finish to start)

You need to generate IV each time. I.e.:

  1. generate IV
  2. encrypt the plaintext using the IV
  3. store/send the ciphertext and the materials required to recreate IV

The easiest way choice is to generate random IVs. This will of course require more storage space (ciphertext + 16 bytes).

Some other schemes which deterministically generate IV are allowed. See NIST SP800-38A for recommendations on how CBC mode IV can be generated.

How to use CBC without expanding block

Linux's dm-crypt uses CBC-ESSIV mode, which generates IV on the fly without need for expansion and thus allows to use CBC mode, without requiring more space than the size of plaintext (assuming plaintext size is multiple of AES block size). However, this mode requires significant amount of processing to calculate IV.

(There are also some other ways to use CBC or build mode based on CBC, which does not need to store IV). Common for all such modes and mode variants is: you need to be very careful with such mode to avoid IV reuse does not happen unexpectedly.

For example, one notable situation where IV reuse occurs is when CBC-ESSIV stores the same value to the same block. In some security models this is considered acceptable.

share|improve this answer
1  
CBC-ESSIV does not solve the problem of IV-reuse leaking information about where a plaintext has changed; it's simply a fix on the even worse problem of IVs changing in predictable ways from sector to sector that affected earlier versions of dm-crypt (and still affects CBC-plain). While you're probably aware of this, I worry that your answer does not make it clear. –  Seth Nov 25 '13 at 19:58
    
@Seth: Thanks. Yes, I specifically wrote: "you need to be very careful with such mode to avoid IV reuse does not happen unexpectedly." This is indeed one of situations where I would say IV reuse is expected event. But, I'll clarify the response anyway. –  user4982 Nov 26 '13 at 21:02
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.