Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More clearly describe the behavior of constant_time.bytes_eq #563

Merged
merged 2 commits into from
Feb 5, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/hazmat/primitives/constant-time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ about the timing attacks on KeyCzar and Java's ``MessageDigest.isEqual()``.

.. function:: bytes_eq(a, b)

Compare ``a`` and ``b`` to one another in constant time if they are of the
same length.
Compares ``a`` and ``b`` with one another. If ``a`` and ``b`` have
different lengths, this returns ``False`` immediately. Otherwise it
compares them in a way that takes the same amount of time, regardless of
how many characters are the same between the two.

.. doctest::

Expand All @@ -30,9 +32,10 @@ about the timing attacks on KeyCzar and Java's ``MessageDigest.isEqual()``.
>>> constant_time.bytes_eq(b"foo", b"bar")
False

:param a bytes: The left-hand side.
:param b bytes: The right-hand side.
:returns boolean: True if ``a`` has the same bytes as ``b``.
:param bytes a: The left-hand side.
:param bytes b: The right-hand side.
:returns bool: ``True`` if ``a`` has the same bytes as ``b``, otherwise
``False``.


.. _`Coda Hale's blog post`: http://codahale.com/a-lesson-in-timing-attacks/