diff options
-rw-r--r-- | docs/hazmat/backends/openssl.rst | 14 | ||||
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 3 | ||||
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 3 |
3 files changed, 20 insertions, 0 deletions
diff --git a/docs/hazmat/backends/openssl.rst b/docs/hazmat/backends/openssl.rst index e293c064..22807f1c 100644 --- a/docs/hazmat/backends/openssl.rst +++ b/docs/hazmat/backends/openssl.rst @@ -36,6 +36,20 @@ greater. The string name of this backend: ``"openssl"`` + .. method:: openssl_version_text() + + :return text: The friendly string name of the loaded OpenSSL library. + This is not necessarily the same version as it was compiled against. + + .. method:: openssl_version_number() + + .. versionadded:: 1.8 + + :return int: The integer version of the loaded OpenSSL library. This is + defined in ``opensslv.h`` as ``OPENSSL_VERSION_NUMBER`` and is + typically shown in hexadecimal (e.g. ``0x1010003f``). This is + not necessarily the same version as it was compiled against. + .. method:: activate_osrandom_engine() Activates the OS random engine. This will effectively disable OpenSSL's diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index d2a9e6c9..a8d779ba 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -206,6 +206,9 @@ class Backend(object): self._lib.OpenSSL_version(self._lib.OPENSSL_VERSION) ).decode("ascii") + def openssl_version_number(self): + return self._lib.OpenSSL_version_num() + def create_hmac_ctx(self, key, algorithm): return _HMACContext(self, key, algorithm) diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 6d6f3452..8fa64bc8 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -71,6 +71,9 @@ class TestOpenSSL(object): backend.openssl_version_text().startswith("LibreSSL") ) + def test_openssl_version_number(self): + assert backend.openssl_version_number() > 0 + def test_supports_cipher(self): assert backend.cipher_supported(None, None) is False |