Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If an adaptive hash function like bcrypt or PBKDF2 is used in hashing passwords, the number of iterations used in the hashing process can be configured.

For a penetration tester or a malicious hacker, what are the ways to determine how many iterations were used in hashing passwords, assuming that they do not have access to source codes, only a database dump of the password hashes.

share|improve this question

migrated from Jul 27 '12 at 10:55

This question came from our site for information security professionals.

I still think this fits security.SE better than crypto.SE. – CodesInChaos Jul 27 '12 at 11:12
up vote 6 down vote accepted

The plain hash itself does not give any indication of the number of iterations. But with practical schemes, such as most crypt based ones, the number of iterations is stored alongside hash and salt in the database.

Keeping the number of iterations secret doesn't gain you much security in practice. Figuring out the number of iterations isn't that hard in practice. Choose a few users who probably have weak passwords, and compare after each iteration. Or if you can register your own accounts, you can simply attack that single user whose password you know.

If you want to improve security in a scenario where the attacker obtains only the database, but not the source-code/config file, there are much better techniques than a secret number of iteration. For example you could concatenate the salt with a secret key, or encrypt the hash. That way an attacker has no chance of attacking the hashes without gaining access to the place where you store the key.

share|improve this answer

For a penetration tester, I do not know of any easy way to determine the number of iterations given only black-box access to the application -- unless you find some other vulnerability that gives you an "in" to access this information.

If you find some other vulnerability that gives you access to the database, you can read the number of iterations from the database, since it is stored with the password hash. If you find some other vulnerability that lets you get access to the web application's source code (or compiled code), you can read the number of iterations out of the source code.

share|improve this answer
Is figuring the number of iterations easy in practice, as CodesInChaos claimed above? – Pacerier Dec 2 '14 at 7:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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