Opened 4 weeks ago
Last modified 2 weeks ago
#36546 assigned Cleanup/optimization
Deprecate django.utils.crypto.constant_time_compare()
Reported by: | Tim Graham | Owned by: | |
---|---|---|---|
Component: | Utilities | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | JaeHyuckSa | Triage Stage: | Someday/Maybe |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Historically it was a bespoke implementation (added in 45c7f427ce830dd1b2f636fb9c244fda9201cadb) before the stdlib implementation was preferred (58176dee88ac7c1038c7f685af023e634b143d02). Now it's just alias of secrets.compare_digest
(which itself is an alias of hmac.compare_digest
, which was used before 1d0bab0bfd77edcf1228d45bf654457a8ff1890d).
constant_time_compare()
does call force_bytes()
on its arguments but this was a workaround for Python 2.7 (7e3cf3cfd27e53ced0a1fc65a02849f78a292d3d) and no tests in Django's test suite fail with those calls removed.
Change History (15)
comment:1 by , 4 weeks ago
comment:2 by , 4 weeks ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 3 weeks ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:4 by , 3 weeks ago
Has patch: | set |
---|
comment:5 by , 3 weeks ago
Patch needs improvement: | set |
---|
comment:6 by , 3 weeks ago
Patch needs improvement: | unset |
---|
comment:7 by , 3 weeks ago
Patch needs improvement: | set |
---|
comment:8 by , 3 weeks ago
Patch needs improvement: | unset |
---|
comment:9 by , 3 weeks ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:12 by , 2 weeks ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
Triage Stage: | Ready for checkin → Someday/Maybe |
Reopening following revert. See discussion in #36572
A later first step could be to replace internal usage of constant_time_compare() with compare_digest()
The deprecation itself needs more consideration
comment:13 by , 2 weeks ago
There are quite a few points that need further discussion, so it’s difficult to move this forward right now. I’ll unassign myself for the time being
comment:14 by , 2 weeks ago
Owner: | removed |
---|---|
Status: | new → assigned |
comment:15 by , 2 weeks ago
Cc: | added |
---|
what about adding a warning in function constant_time_compare in file
django.utils.crypto.py
`