note 94104 added to function.hash
| From: | KaiPetzke at osu1 dot php dot net | Date: | Fri, 16 Oct 2009 12:14:54 +0000 |
| Subject: | note 94104 added to function.hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-161805@lists.php.net to get a copy of this message | ||
The well known hash functions MD5 and SHA1 should be avoided in new applications. Collission attacks
against MD5 are well documented in the cryptographics literature and have already been demonstrated
in practice. Therefore, MD5 is no longer secure for certain applications.
Collission attacks against SHA1 have also been published, though they still require computing power,
which is somewhat out of scope. As computing power increases with time and the attacks are likely to
get better, too, attacks against systems relying on SHA1 for security are likely to become feasible
within the next few years.
There is no lack of potential alternative hash algorithms, as the many choices for the
"algo" argument of PHPs hash() function already suggests. Unfortunately, there is lack of
analysis, as to how secure these alternative algorithms are. It is rather safe to assume, though,
that the SHA2 family with its most prominent members SHA-256 und SHA-512, is better than SHA1.
When storing password hashes, it is a good idea to prefix a salt to the password before hashing, to
avoid the same passwords to hash to the same values and to avoid the use of rainbow tables for
password recovery. Unlike suggested in other articles, there is no security advantage in putting the
salt in the middle, or even at both the beginning and the end, of the combined salt-password-string.
Rather, there are two other factors, that determine the strength of the salt: Its length and its
variability. For example, using the same salt for all passwords is easy to implement, but gives only
very little additional security. In particular, if users type the same passwords, they will still
hash to the same value!
Therefore, the salt should be random string with at least as many variable bits, as there are bits
in the hash result. In the user database, store username, the randomly generated salt for that user,
and the result of hashing the salt-password-string. Access authentication is then done by looking up
the entry for the user, calculating the hash of the salt found in the database and the password
provided by the user, and comparing the result with the one stored in the database.
----
Server IP: 69.147.83.197
Probable Submitter: 87.193.148.44
----
Manual Page -- http://www.php.net/manual/en/function.hash.php
Edit -- https://master.php.net/note/edit/94104
Del: integrated -- https://master.php.net/note/delete/94104/integrated
Del: useless -- https://master.php.net/note/delete/94104/useless
Del: bad code -- https://master.php.net/note/delete/94104/bad+code
Del: spam -- https://master.php.net/note/delete/94104/spam
Del: non-english -- https://master.php.net/note/delete/94104/non-english
Del: in docs -- https://master.php.net/note/delete/94104/in+docs
Del: other reasons-- https://master.php.net/note/delete/94104
Reject -- https://master.php.net/note/reject/94104
Search -- https://master.php.net/manage/user-notes.php