Skip to content

Commit 5f160b9

Browse files
authored
Update recommended PBKDF2HMAC iteration counts (#12243)
This uses the current (as of 2025-01-07) default of 1,000,000 iterations used by Django.
1 parent 89efecb commit 5f160b9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/fernet.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ password through a key derivation function such as
237237
... algorithm=hashes.SHA256(),
238238
... length=32,
239239
... salt=salt,
240-
... iterations=480000,
240+
... iterations=1_000_000,
241241
... )
242242
>>> key = base64.urlsafe_b64encode(kdf.derive(password))
243243
>>> f = Fernet(key)
@@ -251,8 +251,8 @@ In this scheme, the salt has to be stored in a retrievable location in order
251251
to derive the same key from the password in the future.
252252

253253
The iteration count used should be adjusted to be as high as your server can
254-
tolerate. A good default is at least 480,000 iterations, which is what `Django
255-
recommends as of December 2022`_.
254+
tolerate. A good default is at least 1,000,000 iterations, which is what `Django
255+
recommends as of January 2025`_.
256256

257257
Implementation
258258
--------------
@@ -280,5 +280,5 @@ unsuitable for very large files at this time.
280280

281281

282282
.. _`Fernet`: https://github.com/fernet/spec/
283-
.. _`Django recommends as of December 2022`: https://github.com/django/django/blob/main/django/contrib/auth/hashers.py
283+
.. _`Django recommends as of January 2025`: https://github.com/django/django/blob/main/django/contrib/auth/hashers.py
284284
.. _`specification`: https://github.com/fernet/spec/blob/master/Spec.md

docs/hazmat/primitives/key-derivation-functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ PBKDF2
162162
... algorithm=hashes.SHA256(),
163163
... length=32,
164164
... salt=salt,
165-
... iterations=480000,
165+
... iterations=1_000_000,
166166
... )
167167
>>> key = kdf.derive(b"my great password")
168168
>>> # verify
169169
>>> kdf = PBKDF2HMAC(
170170
... algorithm=hashes.SHA256(),
171171
... length=32,
172172
... salt=salt,
173-
... iterations=480000,
173+
... iterations=1_000_000,
174174
... )
175175
>>> kdf.verify(b"my great password", key)
176176

0 commit comments

Comments
 (0)