Вопрос

I'm using RijndaelManaged to encrypt and decrypt data. I may well have misunderstood the point of an initialization vector, but I am finding that if I set it to a different value when decrypting my data, all but the first 16 characters are still decrypted correctly. Is that expected behaviour?

Это было полезно?

Решение

Yes. In CBC mode each cyphertext block is used as the IV for the next cyphertext block. Using a faulty IV will mess up the first 16 byte block, but subsequent blocks will be unaffected. This can be a useful property as it allows error recovery after a faulty block, which can be important in some situations. It also illustrates why it is not really necessary to keep the IV secret (unlike the key!).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top