Is there any security issues if you wrap your cryptographic hash with MD5 for storage purposes?
For example:
$hash = md5(hash($password,$salt,$rounds));
Note: hash()
uses scrypt
or bcrypt
or pbkdf2
internally.
The only purpose of md5 is for storage since it only uses 32 bytes vs storing very long raw hash.
EDIT: Judging from the comments below I agree MD5 is not a good idea as it is collision prone but what if I use a better hashing function like SHA512? Still, comments below argue it may actually weaken it but can somebody please explain how?
How can this:
$hash = SHA512(bcrypt($password,$salt,$rounds));
be weaker than this:
$hash = bcrypt($password,$salt,$rounds);
?
It appears to me the former is stronger since you have to "crack" SHA512 first before you can even begin working on cracking bcrypt. Why others says otherwise?
$hash = md5(hash($password,$salt,$rounds));
for as long ashash()
internally uses a strong algo likebcrypt
? – IMB Aug 09 '12 at 16:22md5()
(such as if thehash()
part were computed on the host and then sent to the server) andmd5(hash())
is always treated as an autonomous unit, then it should not be weaker than justhash()
by itself. – B-Con Aug 09 '12 at 16:37hash()
first beforemd5()
. On another note, I guess it goes without saying that in case the attacker obtained the database of hashes, themd5()
wrapping actually makes his job one step harder right vs justhash()
alone ? – IMB Aug 09 '12 at 16:44