6

I am trying to fully understand the relationship between BCRYPT's COST factors and how much more time it would take a machine to crack a password with PHP 5.5's password_hash()

The encryption times I observed on an average server for password_hash() are:

COST 14 takes 1.23s to 2s
COST 13 takes 0.6 to 1s
COST 12 takes about 0.3s
COST 11 takes about 0.15s
COST 10 takes about 0.08s
COST 09 takes about 0.04s
  1. Are the number of rounds linearly proportional to the time taken?

  2. Is the computation time required to crack a password on the same linear scale or exponential like?

e.g. If a COST 10 hash took 1 minute to crack. How much time are we looking at with COST 14 for the same password? I assume this would vary depending on the password entropy. So let's take an average fairly weak 10 letter password such as "EasyCrack1" as basis for the reasoning.

8

As documented rather indirectly in the page for the crypt() function, the cost parameter is the base-2 logarithm of iteration count, or to put it another way, each +1 increase to cost represents a doubling of the number of iterations.

If a cost-10 hash takes one minute to crack, a cost-14 would take 2^(14-10) = 16 minutes. Cracking a cryptographic hash like bcrypt consists of guessing what the password is, hashing it, and seeing if the hashes match, so the difficulty of cracking increases proportionately with the hashing time. Just like increasing the cost by 1 doubles the hashing time, it doubles the effort involved in cracking the hash.

  • Got it. For weak passwords, the cost isn't doing much at all then. Especially with the cost being given away in the hash itself. – hexalys Apr 16 '15 at 5:39
  • Right. If the password is in the attacker's dictionary, an increased cost will slow them down, but not by enough to matter. It's only once they've exhausted the dictionary and are starting to try every possible combination that the increase pays off: one hour vs. ten hours doesn't really matter, but one year vs. ten years does. – Mark Apr 16 '15 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.