Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5f762af3
Commit
5f762af3
authored
Jun 24, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove a detailed discussion of content-based short circuiting, off topic for library docs.
parent
f61e7910
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
13 deletions
+4
-13
Doc/library/hmac.rst
Doc/library/hmac.rst
+4
-13
No files found.
Doc/library/hmac.rst
View file @
5f762af3
...
...
@@ -70,22 +70,13 @@ This module also provides the following helper function:
.. function:: compare_digest(a, b)
Return ``a == b``. This function uses an approach designed to prevent
timing
analysis by avoiding content based short circuiting behaviour, making it
appropriate for cryptography. *a* and *b* must both be of the same type:
either :class:`str` (ASCII only, as e.g. returned by
Return ``a == b``. This function uses an approach designed to prevent
timing analysis by avoiding content-based short circuiting behaviour,
making it appropriate for cryptography. *a* and *b* must both be of the
same type:
either :class:`str` (ASCII only, as e.g. returned by
:meth:`HMAC.hexdigest`), or any type that supports the buffer protocol
(e.g. :class:`bytes`).
Using a short circuiting comparison (that is, one that terminates as soon as
it finds any difference between the values) to check digests for correctness
can be problematic, as it introduces a potential vulnerability when an
attacker can control both the message to be checked *and* the purported
signature value. By keeping the plaintext consistent and supplying different
signature values, an attacker may be able to use timing variations to search
the signature space for the expected value in O(n) time rather than the
desired O(2**n).
.. note::
If *a* and *b* are of different lengths, or if an error occurs,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment