Julian Krause | 9c3088f | 2013-12-04 14:49:50 -0800 | [diff] [blame^] | 1 | .. hazmat:: |
| 2 | |
| 3 | Constant time functions |
| 4 | ======================= |
| 5 | |
| 6 | .. currentmodule:: cryptography.hazmat.primitives.constant_time |
| 7 | |
| 8 | In order for cryptographic operations to not leak information through timing |
| 9 | side 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``. |