blob: 2e8e26d74b24b139015ef4fe688584a3af5c6189 [file] [log] [blame]
Julian Krause9c3088f2013-12-04 14:49:50 -08001.. hazmat::
2
3Constant time functions
4=======================
5
6.. currentmodule:: cryptography.hazmat.primitives.constant_time
7
8In order for cryptographic operations to not leak information through timing
9side channels, constant time operations need to be made available.
10
11.. function:: bytes_eq(a, b)
12
13 Compare ``a`` and ``b`` to one another in constant time.
14
15 .. doctest::
16
17 >>> from cryptography.hazmat.primitives import constant_time
18 >>> constant_time.bytes_eq(b"foo", b"foo")
19 True
20 >>> constant_time.bytes_eq(b"foo", b"bar")
21 False
22
23 :param a: ``bytes``.
24 :param b: ``bytes``.