blob: 557f8c4de85fd2054765ca396dd364ddc5efaebf [file] [log] [blame]
Alex Stapletonc368ac22013-12-31 13:43:38 +00001.. hazmat::
2
3OpenSSL Binding
4===============
5
6.. currentmodule:: cryptography.hazmat.bindings.openssl.binding
7
8These are `CFFI`_ bindings to the `OpenSSL`_ C library.
9
10.. class:: cryptography.hazmat.bindings.openssl.binding.Binding()
11
12 This is the exposed API for the OpenSSL bindings. It has two public
13 attributes:
14
15 .. attribute:: ffi
16
17 This is a :class:`cffi.FFI` instance. It can be used to allocate and
18 otherwise manipulate OpenSSL structures.
19
20 .. attribute:: lib
21
22 This is a ``cffi`` library. It can be used to call OpenSSL functions,
23 and access constants.
24
Alex Stapletonfcae1502014-01-23 20:43:34 +000025 .. classmethod:: init_static_locks
26
27 Enables the best available locking callback for OpenSSL.
28 See :ref:`openssl-threading`.
29
30.. _openssl-threading:
31
32Threading
33---------
34
Alex Stapleton5fb7eb42014-01-24 19:02:33 +000035``cryptography`` enables OpenSSLs `thread safety facilities`_ in two different
Alex Stapletonfcae1502014-01-23 20:43:34 +000036ways depending on the configuration of your system. Normally the locking
37callbacks provided by your Python implementation specifically for OpenSSL will
Alex Stapleton5fb7eb42014-01-24 19:02:33 +000038be used. However if you have linked ``cryptography`` to a different version of
Alex Stapletonfcae1502014-01-23 20:43:34 +000039OpenSSL than that used by your Python implementation we enable an alternative
40locking callback. This version is implemented in Python and so may result in
41lower performance in some situations. In particular parallelism is reduced
42because it has to acquire the GIL whenever any lock operations occur within
43OpenSSL.
Alex Stapletonc368ac22013-12-31 13:43:38 +000044
45.. _`CFFI`: https://cffi.readthedocs.org/
46.. _`OpenSSL`: https://www.openssl.org/
Alex Stapletonfcae1502014-01-23 20:43:34 +000047.. _`thread safety facilities`: http://www.openssl.org/docs/crypto/threads.html