I'm developping a program which encrypts USB drives using RijndaelManaged method in C#, with the possibility of choosing between 128/192/256-bits key size. I assume that encryption should take more time with a 256-bits key, however even with a lot of files, the process takes the exact same time than with a 128-bits key. Do you think it's a programming mistake ?
I generate my key and iv from a password using this function :
private List<byte[]> GenerateKeys(string password, int strength)
{
byte[] key;
byte[] iv;
List<byte[]> result = new List<byte[]>();
Rfc2898DeriveBytes rfcDb = new Rfc2898DeriveBytes(password, System.Text.Encoding.UTF8.GetBytes(password));
key = rfcDb.GetBytes(strength); // strength value can be 16, 24 or 32 depending
iv = rfcDb.GetBytes(strength); // on the user choice
result.Add(key);
result.Add(iv);
return result;
}
I then use my RijndaelManaged method this way :
RijndaelManaged rijndael = new RijndaelManaged();
rijndael.Mode = CipherMode.CBC;
rijndael.BlockSize = Strenght * 8;
rijndael.KeySize = Strenght * 8;
ICryptoTransform aesEncryptor = rijndael.CreateEncryptor(key, iv); // key and iv from the other method
Do you see anything wrong ?