问题
I am implementing a decryption of ciphertext using Rijndael's algorithm. Unfortunately, I have not got access to the encryption of the data and have only been provided with a password (to generate the key with) and the type of algorithm.
I do not have a salt (which seems to be ok), and I do not have the IV. Now, my question is whether I absolutely have to have the IV in order to perform decryption? I suspect the developers who wrote the encryption made no use of salt, or IV (if this is even possible).
I have tried to set the IV to null, with no luck, and generating a Rijndael instance creates a default IV, and this is distorting the first 16 characters of my plaintext after decryption.
Is there any way to negate the effect of the IV? Or do a need to try and get hold of what IV was used in the encryption?
回答1:
If the cipher has been used to encrypt in CBC mode (which is the default) then you have to know the IV, there's no way around it.
However, since the purpose of the IV is not the same as the purpose of the password, sometimes you find the IV prepended to the encrypted data (so that the recipient can easily grab it to use when decrypting).
回答2:
You can use the ECB mode and it will ignore the IV. You need an IV for other modes like CBC, though.
回答3:
If it was encrypted with an IV, then yes, you will need the IV in order to correctly decrypt.
From your description about the first 16 characters, it sounds like you're working in CBC mode. See the diagram here for why you'll need the IV: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29.
来源:https://stackoverflow.com/questions/7308663/is-it-possible-to-not-use-the-iv-when-implementing-rijndael-decryption