Background [Updated]
Consider a situation where a website was created over a decade ago and user account password storage was done by storing SHA1(password)
into the database.
It would be great to upgrade the system to use Pbkdf2(salt, password)
with a large work factor of say 50000 for the password hashing using HMACSHA256 as the prf. The resultant hash | salt
could be stored in the database and used to validate the visitor when they return and supply a password. This approach seems to be well regarded here on crypto.stackoverflow.com.
It would be great to be able to improved the hashing for all the existing accounts without needing users to reset their password. So I'm wondering if the following approach is good from a security perspective.
OldHash = SHA1(password)
UpgradedHash = Pbkdf2(salt , OldHash )
StoredInDatabase = UpgradedHash | salt
One desirable property of this approach is that all existing password hashes can be upgraded to using Pbkdf2, salt and a high work factor without needing to have the passwords reset. All the new passwords could even be handled the same way just to keep all the hashes consistent. So new passwords could work like this:
Hash = Pbkdf2(salt , SHA1(password))
StoredInDatabase = Hash | salt
Rational for Upgrading the Hashes
The need to upgrade the password hashes is because the SHA-1 hashes don't include salt and SHA-1 has since been reported as broken. The goal in upgrading the password hashes in the database is to reduce the likelihood that a hacker with access to the database of password hashes could obtain the corresponding passwords for those accounts.
Question
Does this seem like a security valid approach for upgrading the password hashing approach in an existing system?
public static byte[] Pbkdf2(string password, byte[] salt, KeyDerivationPrf prf, int iterationCount, int numBytesRequested)
The method is part of this assembly:Assembly Microsoft.AspNetCore.Cryptography.KeyDerivation
I will update my question to show salt as a parameter rather than a concatenation. $\endgroup$