aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-04 18:03:58 -0800
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-04 18:03:58 -0800
commit48ef0c1a319ea3787ac865d67c15dc303c588d70 (patch)
tree6ea131aa4d512104ea94a1cc7a5b8174d8b28549 /docs/hazmat
parent3eb7a9ee87ea7482774a98ecfd06c913b55cf17f (diff)
parente6c41b078b1f394d74f9287a15c74e5dfbf78616 (diff)
downloadcryptography-48ef0c1a319ea3787ac865d67c15dc303c588d70.tar.gz
cryptography-48ef0c1a319ea3787ac865d67c15dc303c588d70.tar.bz2
cryptography-48ef0c1a319ea3787ac865d67c15dc303c588d70.zip
Merge pull request #563 from alex/better-constant-time-docs
More clearly describe the behavior of constant_time.bytes_eq
Diffstat (limited to 'docs/hazmat')
-rw-r--r--docs/hazmat/primitives/constant-time.rst13
1 files changed, 8 insertions, 5 deletions
diff --git a/docs/hazmat/primitives/constant-time.rst b/docs/hazmat/primitives/constant-time.rst
index 632e7c68..c6fcb3a3 100644
--- a/docs/hazmat/primitives/constant-time.rst
+++ b/docs/hazmat/primitives/constant-time.rst
@@ -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::
@@ -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/