Skip to content

Commit 1ecc98d

Browse files
bpo-42982: Improve the text on suggested number of iterations of PBKDF2 (GH-24276)
Less specific number wording (as there is no one right number - the old 100k is too big for some applications and woefully small for others). We now link to NIST SP 800-132 to tell people what to read in there on how to decide for their application. Co-authored-by: Gregory P. Smith <[email protected]> [Google] (cherry picked from commit 897ce90) Co-authored-by: Illia Volochii <[email protected]>
1 parent b3cf525 commit 1ecc98d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Doc/library/hashlib.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ include a `salt <https://en.wikipedia.org/wiki/Salt_%28cryptography%29>`_.
249249
a proper source, e.g. :func:`os.urandom`.
250250

251251
The number of *iterations* should be chosen based on the hash algorithm and
252-
computing power. As of 2013, at least 100,000 iterations of SHA-256 are
253-
suggested.
252+
computing power. As of 2022, hundreds of thousands of iterations of SHA-256
253+
are suggested. For rationale as to why and how to choose what is best for
254+
your application, read *Appendix A.2.2* of NIST-SP-800-132_.
254255

255256
*dklen* is the length of the derived key. If *dklen* is ``None`` then the
256257
digest size of the hash algorithm *hash_name* is used, e.g. 64 for SHA-512.
@@ -731,6 +732,7 @@ Domain Dedication 1.0 Universal:
731732
.. _SHA-3: https://en.wikipedia.org/wiki/NIST_hash_function_competition
732733
.. _ChaCha: https://cr.yp.to/chacha.html
733734
.. _pyblake2: https://pythonhosted.org/pyblake2/
735+
.. _NIST-SP-800-132: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
734736

735737

736738

@@ -754,3 +756,6 @@ Domain Dedication 1.0 Universal:
754756

755757
https://www.ietf.org/rfc/rfc8018.txt
756758
PKCS #5: Password-Based Cryptography Specification Version 2.1
759+
760+
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf
761+
NIST Recommendation for Password-Based Key Derivation.

0 commit comments

Comments
 (0)