c# - Manipulating the Initialization Vector does not (really) prevent me from decrypting AES ciphertexts -


i created following class, based examples on msdn: https://gist.github.com/anonymous/19d9e5f6747dfe75d553

whenever use this, seems encrypts fine:

var key = crypto.generatekey(); var vector = crypto.generatevector(key);  var cyphertext = crypto.encryptbase64("abcdefghijklmnopqrstuvwxyz1234567890", key, vector); vector = crypto.generatevector(key); var plaintext = crypto.decrypt(cyphertext, key, vector); 

then plaintext contains following:

�\au��(���p\u0003�b\u001dxqrstuvwxyz1234567890

so seems changing iv, doesn't (especially on longer documents). why need iv?

the default mode of operation symmetricalgorithm ciphermode.cbc.

given way how cbc mode works change of iv of encrypted data impact first decrypted block of data.

citing linked article:

decrypting incorrect iv causes first block of plaintext corrupt subsequent plaintext blocks correct. because plaintext block can recovered 2 adjacent blocks of ciphertext. consequence, decryption can parallelized. note one-bit change ciphertext causes complete corruption of corresponding block of plaintext, , inverts corresponding bit in following block of plaintext, rest of blocks remain intact.

this 1 of reasons why encryption without authentication (e.g. here) not idea.

on other hand changing iv during encryption results in different ciphertext change in first block propagated subsequent blocks.

desclaimer: no crypto expert, please validate thoughts.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -