aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2013-12-14 08:10:49 -0800
committerPaul Kehrer <paul.l.kehrer@gmail.com>2013-12-14 08:10:49 -0800
commitca4a22b4dea8243d02bc4a2699048694e591ae75 (patch)
treeed7403a37084a7e2e1b6c363e25b39877a5a3f4a /docs/hazmat
parentb9dd85c661f405099a88b7a76aefde5f59a6b985 (diff)
parent383a04cf47cef37ec94dcc56f52c0e6a18013dcb (diff)
downloadcryptography-ca4a22b4dea8243d02bc4a2699048694e591ae75.tar.gz
cryptography-ca4a22b4dea8243d02bc4a2699048694e591ae75.tar.bz2
cryptography-ca4a22b4dea8243d02bc4a2699048694e591ae75.zip
Merge pull request #283 from juliankrause/constant_time
Beginnings of a constant_time module.
Diffstat (limited to 'docs/hazmat')
-rw-r--r--docs/hazmat/primitives/constant-time.rst38
-rw-r--r--docs/hazmat/primitives/index.rst1
2 files changed, 39 insertions, 0 deletions
diff --git a/docs/hazmat/primitives/constant-time.rst b/docs/hazmat/primitives/constant-time.rst
new file mode 100644
index 00000000..632e7c68
--- /dev/null
+++ b/docs/hazmat/primitives/constant-time.rst
@@ -0,0 +1,38 @@
+.. hazmat::
+
+Constant time functions
+=======================
+
+.. currentmodule:: cryptography.hazmat.primitives.constant_time
+
+This module contains functions for operating with secret data in a way that
+does not leak information about that data through how long it takes to perform
+the operation. These functions should be used whenever operating on secret data
+along with data that is user supplied.
+
+An example would be comparing a HMAC signature received from a client to the
+one generated by the server code for authentication purposes.
+
+For more information about this sort of issue, see `Coda Hale's blog post`_
+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.
+
+ .. doctest::
+
+ >>> from cryptography.hazmat.primitives import constant_time
+ >>> constant_time.bytes_eq(b"foo", b"foo")
+ True
+ >>> 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``.
+
+
+.. _`Coda Hale's blog post`: http://codahale.com/a-lesson-in-timing-attacks/
diff --git a/docs/hazmat/primitives/index.rst b/docs/hazmat/primitives/index.rst
index 614c414a..b115fdbc 100644
--- a/docs/hazmat/primitives/index.rst
+++ b/docs/hazmat/primitives/index.rst
@@ -10,4 +10,5 @@ Primitives
hmac
symmetric-encryption
padding
+ constant-time
interfaces