Allow the use of stronger key derivation functions
Posted: Sat Mar 02, 2019 3:15 am
It seems that AES Crypt derives the AES key from a given password quite fast. As far as I can tell, there are only 8192 iterations in the GenerateAESKey1 method:
In many scenarios, it would be far preferable to use a stronger (i.e., computationally more expensive) key derivation function (KDF) such as PBKDF2, with runtimes measured in seconds, to defend against brute-force attacks.
Note that AES Crypt would not need to implement any KDFs itself, keeping code modifications at a minimum. For example, the Microsoft.AspNetCore.Cryptography.KeyDerivation package already provides a tried-and-tested PBKDF2 implementation for .NET projects.
Regards
Christoph
Code: Select all
private byte[] GenerateAESKey1(byte[] password)
{
…
for (int i = 0; i < 8192; i++)
{
m_hash.Initialize();
m_hash.TransformBlock(key, 0, key.Length, key, 0);
m_hash.TransformFinalBlock(password, 0, password.Length);
key = m_hash.Hash;
}
return key;
}
Note that AES Crypt would not need to implement any KDFs itself, keeping code modifications at a minimum. For example, the Microsoft.AspNetCore.Cryptography.KeyDerivation package already provides a tried-and-tested PBKDF2 implementation for .NET projects.
Regards
Christoph