mirror of https://github.com/django/django.git
Increased the default PBKDF2 iterations.
This commit is contained in:
parent
d4689034be
commit
c51258882b
|
@ -226,7 +226,7 @@ class PBKDF2PasswordHasher(BasePasswordHasher):
|
||||||
safely but you must rename the algorithm if you change SHA256.
|
safely but you must rename the algorithm if you change SHA256.
|
||||||
"""
|
"""
|
||||||
algorithm = "pbkdf2_sha256"
|
algorithm = "pbkdf2_sha256"
|
||||||
iterations = 20000
|
iterations = 24000
|
||||||
digest = hashlib.sha256
|
digest = hashlib.sha256
|
||||||
|
|
||||||
def encode(self, password, salt, iterations=None):
|
def encode(self, password, salt, iterations=None):
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||||
def test_pkbdf2(self):
|
def test_pkbdf2(self):
|
||||||
encoded = make_password('lètmein', 'seasalt', 'pbkdf2_sha256')
|
encoded = make_password('lètmein', 'seasalt', 'pbkdf2_sha256')
|
||||||
self.assertEqual(encoded,
|
self.assertEqual(encoded,
|
||||||
'pbkdf2_sha256$20000$seasalt$oBSd886ysm3AqYun62DOdin8YcfbU1z9cksZSuLP9r0=')
|
'pbkdf2_sha256$24000$seasalt$V9DfCAVoweeLwxC/L2mb+7swhzF0XYdyQMqmusZqiTc=')
|
||||||
self.assertTrue(is_password_usable(encoded))
|
self.assertTrue(is_password_usable(encoded))
|
||||||
self.assertTrue(check_password('lètmein', encoded))
|
self.assertTrue(check_password('lètmein', encoded))
|
||||||
self.assertFalse(check_password('lètmeinz', encoded))
|
self.assertFalse(check_password('lètmeinz', encoded))
|
||||||
|
@ -210,14 +210,14 @@ class TestUtilsHashPass(SimpleTestCase):
|
||||||
hasher = PBKDF2PasswordHasher()
|
hasher = PBKDF2PasswordHasher()
|
||||||
encoded = hasher.encode('lètmein', 'seasalt2')
|
encoded = hasher.encode('lètmein', 'seasalt2')
|
||||||
self.assertEqual(encoded,
|
self.assertEqual(encoded,
|
||||||
'pbkdf2_sha256$20000$seasalt2$Flpve/uAcyo6+IFI6YAhjeABGPVbRQjzHDxRhqxewgw=')
|
'pbkdf2_sha256$24000$seasalt2$TUDkfilKHVC7BkaKSZgIKhm0aTtXlmcw/5C1FeS/DPk=')
|
||||||
self.assertTrue(hasher.verify('lètmein', encoded))
|
self.assertTrue(hasher.verify('lètmein', encoded))
|
||||||
|
|
||||||
def test_low_level_pbkdf2_sha1(self):
|
def test_low_level_pbkdf2_sha1(self):
|
||||||
hasher = PBKDF2SHA1PasswordHasher()
|
hasher = PBKDF2SHA1PasswordHasher()
|
||||||
encoded = hasher.encode('lètmein', 'seasalt2')
|
encoded = hasher.encode('lètmein', 'seasalt2')
|
||||||
self.assertEqual(encoded,
|
self.assertEqual(encoded,
|
||||||
'pbkdf2_sha1$20000$seasalt2$pJt86NmjAweBY1StBvxCu7l1o9o=')
|
'pbkdf2_sha1$24000$seasalt2$L37ETdd9trqrsJDwapU3P+2Edhg=')
|
||||||
self.assertTrue(hasher.verify('lètmein', encoded))
|
self.assertTrue(hasher.verify('lètmein', encoded))
|
||||||
|
|
||||||
def test_upgrade(self):
|
def test_upgrade(self):
|
||||||
|
|
|
@ -38,7 +38,10 @@ Minor features
|
||||||
:mod:`django.contrib.auth`
|
: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`
|
:mod:`django.contrib.gis`
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
Loading…
Reference in New Issue