php - Is my Bcrypt encryption safe enough? -
i working on project needs advanced security system when comes saving passwords etc. question is, way save passwords safe enough?
this way programmed:
- when user registers, salt created out of following details:
- an unique user id (primary key in mysql)
- the users emailaddress
- the current (micro)timestamp
- some random key defined in configuration of website
- this salt being hashed sha512 key.
- after salt has been created, following string being hashed using bcrypt: password + sha512 salt (worklevel 10, ($2a$10...)).
- then skip first 5 characters of bcrypt output ($2a$10) , save remaining string database.
when user tries log in, first check if username exists. if does, check if password correct using check() function.
i use this bcrypt class encrypt , check.
can guys tell me if way of encrypting , verifying enough big project?
regards,
jan willem
- there's absolutely no point in deriving salt particular input. in fact, can serve weaken it. salt derived value has relation value hashed not salt, it's altered hashing algorithm. salts entirely (pseudo) random noise, period. point make input unique; , unique value random noise.
- if derive salt pseudo random number generator, there's no need hash it. can serve reduce entropy.
you should store entire result in database (including
$2a$10
). if you're doing properly, hash virtually impossible brute force is. omitting piece of information makes your job more difficult, doesn't make meaningfully more difficult potential attacker.storing value lets see algorithm hash created , upgrade it on time. hardware becomes faster should increase work factor of algorithm , better algorithms become available (hello scrypt!) should upgrade algorithm used. way works check whether hash created using latest , greatest when user logs in. @ point opportunity rehash cleartext password , upgrade it.
use php's new password_hash
api or password_compat shim older versions, tested , "advanced".
Comments
Post a Comment