Password vault, hash () with sha-512 or crypt () with blowfish (bcrypt)?

This is my current password hashing procedure in PHP / SQL projects ...

  • Take 512 bits of one user fraction from / dev / urandom stored in the user database entry in addition to the final hash
  • Take the 512 bit pepper from / dev / urandom, which is stored on the file system. This is constant for each application and the same for each user.
  • Then hash('sha512', $password.$salt.$pepper, TRUE)

The hash and salt are stored in binary format in the database, mostly out of habit. I do not think this has any security implications. If something is a little less convenient for SQL backups and makes the PHP code a little more complicated.

Is hash() with SHA-256 or SHA-512, which are believed to have been surpassed by bcrypt these days?
I believe that SHA-2 (256/512) is still considered cryptographically secure, and I will probably overdo the entropy bits. Most likely, this will be an error in my code, which will lead to problems than an attacker reconstructing the SHA-2 hash from a database dump.

But do I need to update my methodology to use crypt() instead of CRYPT_BLOWFISH (I believe this is called bcrypt, and blowfish is technically an encryption algorithm, not a hash)?
Even as the best best practice?

I'm not particularly worried about the computational expense of the algorithms (within reason). This would ever be a factor when creating accounts, changing passwords, or when logging in when you haveh the comparison. These actions make up a small percentage of page views. I guess the slower the better, if it makes the server work harder, then it will make the attacker work slower than brute force.

Greetings, B

+2
source share
2 answers

If you can wait for til php 5.5, there will be some useful functions for this built-in:

https://gist.github.com/3707231

Until then, use crypt - you can look at this compatible port for new features:

https://github.com/ircmaxell/password_compat

+5
source

You are definitely on the right track, bcrypt is a very good way to store your passwords (it's best to use scrypt, but it's hard to find a good implementation in PHP).

Remember that sha1, sha256, sha512 were never done with hash passwords. They were designed to be fast so you can take large datasets and create a unique signature for them as soon as possible. They are used to sign more than anything else.

You definitely want to use a hashing algorithm that takes longer.

Note: Some argue that pepper is pointless because if they crack your system, they will have access to your salts and pepper.

This post contains a great introduction to password security.

+1
source

Source: https://habr.com/ru/post/1439363/


All Articles