Ticket #15627: 15627.diff

File 15627.diff, 808 bytes (added by Harro, 14 years ago)

Patch to use constant_time_compare

  • django/contrib/auth/models.py

    diff -r e06fa0ab9ee8 django/contrib/auth/models.py
    a b  
    1010from django.utils.encoding import smart_str
    1111from django.utils.hashcompat import md5_constructor, sha_constructor
    1212from django.utils.translation import ugettext_lazy as _
     13from django.utils.crypto import constant_time_compare
    1314
    1415
    1516UNUSABLE_PASSWORD = '!' # This will never be a valid hash
     
    3940    encryption formats behind the scenes.
    4041    """
    4142    algo, salt, hsh = enc_password.split('$')
    42     return hsh == get_hexdigest(algo, salt, raw_password)
     43    return constant_time_compare(hsh, get_hexdigest(algo, salt, raw_password))
    4344
    4445def update_last_login(sender, user, **kwargs):
    4546    """
Back to Top