I have the following code:
var symmetricKey = Rijndael.Create().CreateEncryptor(key, iv);
key and iv are the same length, and they are byte arrays of length 32. In runtime, this snippet fails, saying the length isn't supported. I also tried with 16. doesn't work either.
Am I using this wrong? what gives?
It should work correctly if you set the IV to 16 bytes, matching Rijndael's default block size.
(Either that or change the BlockSize
itself to be compatible with the size of your IV.)