Trying to find related answer for a long time, but not convinced yet.
What I am trying is to encrypt using RijndaelManaged. To create Key, I am passing password, salt and iteration to Rfc2898DeriveBytes.
I was thinking to add constant if user entered password is below specific length before passing it to Rfc2898DeriveBytes.
So far what I found that adding constant will not add any benefit to security. Let suppose attacker get an access to database containing encrypted data along with salt, but not to constant will give him a bit harder time. Although in the end he will find that constant.
Or it is "really and extremely" safe to pass any length password to Rfc2898DeriveBytes without getting worried?
Does passing shorter or lengthier password affect key derivation process in term of which one is better and most recommended?
So far what I know that random salt and more iteration is important.
Following is the code, should I remove adding constant to password or keep it?
(Note: password length restriction to user is not applied at GUI, user can pass 1 character or even more than 10 characters)
string constant = "AnyConstantToMakePasswordBigger";
if (password.Length < 8)
{
password = password + constant;
}
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] salt = new byte[8];
rng.GetBytes(salt);
Rfc2898DeriveBytes derivedKey = new Rfc2898DeriveBytes(password, salt, 1000);
using (RijndaelManaged aes = new RijndaelManaged())
{
aes.Key = derivedKey.GetBytes(keyLength);
.....
}
Welcoming any positive or negative comment and responses.
Rfc2898DeriveBytes
). If you want to improve security ensure the password excedes a minimum length. – Jodrell