Skip to content

Commit

Permalink
Increased the default PBKDF2 iterations.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Jan 17, 2015
1 parent d468903 commit c512588
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion django/contrib/auth/hashers.py
Expand Up @@ -226,7 +226,7 @@ class PBKDF2PasswordHasher(BasePasswordHasher):
safely but you must rename the algorithm if you change SHA256.
"""
algorithm = "pbkdf2_sha256"
iterations = 20000
iterations = 24000
digest = hashlib.sha256

def encode(self, password, salt, iterations=None):
Expand Down
6 changes: 3 additions & 3 deletions django/contrib/auth/tests/test_hashers.py
Expand Up @@ -46,7 +46,7 @@ def test_simple(self):
def test_pkbdf2(self):
encoded = make_password('lètmein', 'seasalt', 'pbkdf2_sha256')
self.assertEqual(encoded,
'pbkdf2_sha256$20000$seasalt$oBSd886ysm3AqYun62DOdin8YcfbU1z9cksZSuLP9r0=')
'pbkdf2_sha256$24000$seasalt$V9DfCAVoweeLwxC/L2mb+7swhzF0XYdyQMqmusZqiTc=')
self.assertTrue(is_password_usable(encoded))
self.assertTrue(check_password('lètmein', encoded))
self.assertFalse(check_password('lètmeinz', encoded))
Expand Down Expand Up @@ -210,14 +210,14 @@ def test_low_level_pkbdf2(self):
hasher = PBKDF2PasswordHasher()
encoded = hasher.encode('lètmein', 'seasalt2')
self.assertEqual(encoded,
'pbkdf2_sha256$20000$seasalt2$Flpve/uAcyo6+IFI6YAhjeABGPVbRQjzHDxRhqxewgw=')
'pbkdf2_sha256$24000$seasalt2$TUDkfilKHVC7BkaKSZgIKhm0aTtXlmcw/5C1FeS/DPk=')
self.assertTrue(hasher.verify('lètmein', encoded))

def test_low_level_pbkdf2_sha1(self):
hasher = PBKDF2SHA1PasswordHasher()
encoded = hasher.encode('lètmein', 'seasalt2')
self.assertEqual(encoded,
'pbkdf2_sha1$20000$seasalt2$pJt86NmjAweBY1StBvxCu7l1o9o=')
'pbkdf2_sha1$24000$seasalt2$L37ETdd9trqrsJDwapU3P+2Edhg=')
self.assertTrue(hasher.verify('lètmein', encoded))

def test_upgrade(self):
Expand Down
5 changes: 4 additions & 1 deletion docs/releases/1.9.txt
Expand Up @@ -38,7 +38,10 @@ Minor features
:mod:`django.contrib.auth`
^^^^^^^^^^^^^^^^^^^^^^^^^^

* ...
* The default iteration count for the PBKDF2 password hasher has been increased
by 20%. This backwards compatible change will not affect users who have
subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
default value.

:mod:`django.contrib.gis`
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit c512588

Please sign in to comment.