Alex Stapleton | c368ac2 | 2013-12-31 13:43:38 +0000 | [diff] [blame] | 1 | .. hazmat:: |
| 2 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 3 | OpenSSL binding |
Alex Stapleton | c368ac2 | 2013-12-31 13:43:38 +0000 | [diff] [blame] | 4 | =============== |
| 5 | |
| 6 | .. currentmodule:: cryptography.hazmat.bindings.openssl.binding |
| 7 | |
Paul Kehrer | 12649af | 2014-03-10 12:45:19 -0400 | [diff] [blame] | 8 | These are `CFFI`_ bindings to the `OpenSSL`_ C library. Cryptography supports |
| 9 | version ``0.9.8e`` (present in Red Hat Enterprise Linux 5) and greater. Earlier |
| 10 | versions may work but are **not tested or supported**. |
Alex Stapleton | c368ac2 | 2013-12-31 13:43:38 +0000 | [diff] [blame] | 11 | |
| 12 | .. class:: cryptography.hazmat.bindings.openssl.binding.Binding() |
| 13 | |
| 14 | This is the exposed API for the OpenSSL bindings. It has two public |
| 15 | attributes: |
| 16 | |
| 17 | .. attribute:: ffi |
| 18 | |
| 19 | This is a :class:`cffi.FFI` instance. It can be used to allocate and |
| 20 | otherwise manipulate OpenSSL structures. |
| 21 | |
| 22 | .. attribute:: lib |
| 23 | |
| 24 | This is a ``cffi`` library. It can be used to call OpenSSL functions, |
| 25 | and access constants. |
| 26 | |
Alex Stapleton | fcae150 | 2014-01-23 20:43:34 +0000 | [diff] [blame] | 27 | .. classmethod:: init_static_locks |
| 28 | |
| 29 | Enables the best available locking callback for OpenSSL. |
| 30 | See :ref:`openssl-threading`. |
| 31 | |
| 32 | .. _openssl-threading: |
| 33 | |
| 34 | Threading |
| 35 | --------- |
| 36 | |
Alex Stapleton | 5fb7eb4 | 2014-01-24 19:02:33 +0000 | [diff] [blame] | 37 | ``cryptography`` enables OpenSSLs `thread safety facilities`_ in two different |
Alex Stapleton | fcae150 | 2014-01-23 20:43:34 +0000 | [diff] [blame] | 38 | ways depending on the configuration of your system. Normally the locking |
| 39 | callbacks provided by your Python implementation specifically for OpenSSL will |
Alex Stapleton | 5fb7eb4 | 2014-01-24 19:02:33 +0000 | [diff] [blame] | 40 | be used. However if you have linked ``cryptography`` to a different version of |
Alex Stapleton | fcae150 | 2014-01-23 20:43:34 +0000 | [diff] [blame] | 41 | OpenSSL than that used by your Python implementation we enable an alternative |
| 42 | locking callback. This version is implemented in Python and so may result in |
| 43 | lower performance in some situations. In particular parallelism is reduced |
| 44 | because it has to acquire the GIL whenever any lock operations occur within |
| 45 | OpenSSL. |
Alex Stapleton | c368ac2 | 2013-12-31 13:43:38 +0000 | [diff] [blame] | 46 | |
| 47 | .. _`CFFI`: https://cffi.readthedocs.org/ |
| 48 | .. _`OpenSSL`: https://www.openssl.org/ |
Alex Gaynor | e9df294 | 2014-12-12 10:56:26 -0800 | [diff] [blame] | 49 | .. _`thread safety facilities`: https://www.openssl.org/docs/crypto/threads.html |