blob: ac65aa97b09bad4a75f77b8c236063bc1bea5007 [file] [log] [blame]
Alex Stapletonc368ac22013-12-31 13:43:38 +00001.. hazmat::
2
Alex Stapletonc5fffd32014-03-18 15:29:00 +00003OpenSSL binding
Alex Stapletonc368ac22013-12-31 13:43:38 +00004===============
5
6.. currentmodule:: cryptography.hazmat.bindings.openssl.binding
7
Paul Kehrer12649af2014-03-10 12:45:19 -04008These are `CFFI`_ bindings to the `OpenSSL`_ C library. Cryptography supports
Alex Gaynor0e8cdf12016-12-13 21:05:35 -05009OpenSSL version 1.0.1 and greater.
Alex Stapletonc368ac22013-12-31 13:43:38 +000010
11.. class:: cryptography.hazmat.bindings.openssl.binding.Binding()
12
13 This is the exposed API for the OpenSSL bindings. It has two public
14 attributes:
15
16 .. attribute:: ffi
17
Paul Kehrer45efdbc2015-02-12 10:58:22 -060018 This is a ``cffi.FFI`` instance. It can be used to allocate and
Alex Stapletonc368ac22013-12-31 13:43:38 +000019 otherwise manipulate OpenSSL structures.
20
21 .. attribute:: lib
22
23 This is a ``cffi`` library. It can be used to call OpenSSL functions,
24 and access constants.
25
Alex Stapletonfcae1502014-01-23 20:43:34 +000026 .. classmethod:: init_static_locks
27
28 Enables the best available locking callback for OpenSSL.
29 See :ref:`openssl-threading`.
30
31.. _openssl-threading:
32
33Threading
34---------
35
Alex Stapleton5fb7eb42014-01-24 19:02:33 +000036``cryptography`` enables OpenSSLs `thread safety facilities`_ in two different
Alex Stapletonfcae1502014-01-23 20:43:34 +000037ways depending on the configuration of your system. Normally the locking
38callbacks provided by your Python implementation specifically for OpenSSL will
Alex Gaynor16b67fc2015-09-24 21:48:51 -040039be used. However, if you have linked ``cryptography`` to a different version of
Alex Stapletonfcae1502014-01-23 20:43:34 +000040OpenSSL than that used by your Python implementation we enable an alternative
41locking callback. This version is implemented in Python and so may result in
42lower performance in some situations. In particular parallelism is reduced
43because it has to acquire the GIL whenever any lock operations occur within
44OpenSSL.
Alex Stapletonc368ac22013-12-31 13:43:38 +000045
Alex Gaynor988df9b2016-04-28 10:57:16 -040046.. _`CFFI`: https://cffi.readthedocs.io
Alex Stapletonc368ac22013-12-31 13:43:38 +000047.. _`OpenSSL`: https://www.openssl.org/
Alex Gaynore51236d2016-11-06 10:13:35 -050048.. _`thread safety facilities`: https://www.openssl.org/docs/man1.0.2/crypto/threads.html