RE: [PHP-DEV] [DRAFT RFC] Adding Simplified Password Hashing API
| From: | Jonathan Bond-Caron | Date: | Tue, 31 Jul 2012 12:02:39 +0000 |
| Subject: | RE: [PHP-DEV] [DRAFT RFC] Adding Simplified Password Hashing API | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-61887@lists.php.net to get a copy of this message | ||
On Wed Jun 27 12:32 PM, Arvids Godjuks wrote:
> because at the moment i do not understand how salt stored in the hash itself makes hash more
> secure than an unsalted one.
a) In terms of 'effort' to break many passwords, there's a benefit to the salt stored
in the hash itself.
It's not 'more secure' but 'better/recommended' since the attacker would
need to create a 'rainbow table' for each password it's trying to crack
Overall, the technique offers better protection.
b) In terms of 'effort' to break a single password, there's **no** benefit to the
salt stored in the hash itself.
If you want a single password to be really secure, don't let the attacker know the salt and
keep it long:
// no benefit of short salt, ~ same effort required by the attacker
$password = '234';
md5($password);
$salt = '1';
$password = '234';
md5($salt . $password);
c) The best of both worlds: long private salt (b) + different for every user (a)
$saltInpassword = $password[0]; // could be random bytes, stored in password like crypt() does
$salt = 'my-long-private-value-use-all-bytes'. $saltInPassword;
$password = '234';
$hash = md5($salt . $password);
This one requires more effort by the attacker since the long salt forces more
'bits/guesses' to pass into md5()
// require even more effort, iterate
for($i = 0; $i < 1000; $i++)
$hash = md5($i . $hash);