Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bcrypt -- keeping up with Moore's law [duplicate]

I'm using bcrypt to store passwords in my database, using a work factor of 7, which takes about 0.02s to hash a single password on my reasonably modern laptop.

Coda Hale says that using bcrypt allows you to 'keep up with Moore's law' by tweaking the work factor. But there's no way to re-encrypt a user's password, since I'm not storing the plaintext. How can I keep my database up-to-date and difficult to crack (assuming it hangs around for the 5+ years it would take for this to become an issue)?

like image 855
nornagon Avatar asked Jan 19 '23 21:01

nornagon


1 Answers

Re-encrypt on login. See Optimal bcrypt work factor.

Remember that the value is stored in the password: $2a$(2 chars work)$(22 chars salt)(31 chars hash). It is not a fixed value.

If you find the load is too high, just make it so the next time they log in, you crypt to something faster to compute. Similarly, as time goes on and you get better servers, if load isn't an issue, you can upgrade the strength of their hash when they log in.

The trick is to keep it taking roughly the same amount of time forever into the future along with Moore's Law. The number is log2, so every time computers double in speed, add 1 to the default number...

like image 108
nornagon Avatar answered Jan 22 '23 11:01

nornagon