aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/backends/openssl/backend.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2019-02-25 13:32:05 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2019-02-25 00:32:05 -0500
commit76c784340c3851f402abc38dff8fa5f008cdc4d4 (patch)
treeb08f245978f3ec2e5ffa8b1ace388944500c8650 /src/cryptography/hazmat/backends/openssl/backend.py
parent01a517919ce16cc9dd75db9d02dae00a4cc390bb (diff)
downloadcryptography-76c784340c3851f402abc38dff8fa5f008cdc4d4.tar.gz
cryptography-76c784340c3851f402abc38dff8fa5f008cdc4d4.tar.bz2
cryptography-76c784340c3851f402abc38dff8fa5f008cdc4d4.zip
support NO_ENGINE (#4763)
* support OPENSSL_NO_ENGINE * support some new openssl config args * sigh
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/backend.py')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index 73491726..d7bba224 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -150,14 +150,15 @@ class Backend(object):
self.openssl_assert(res == 1)
def activate_osrandom_engine(self):
- # Unregister and free the current engine.
- self.activate_builtin_random()
- with self._get_osurandom_engine() as e:
- # Set the engine as the default RAND provider.
- res = self._lib.ENGINE_set_default_RAND(e)
- self.openssl_assert(res == 1)
- # Reset the RNG to use the new engine.
- self._lib.RAND_cleanup()
+ if self._lib.Cryptography_HAS_ENGINE:
+ # Unregister and free the current engine.
+ self.activate_builtin_random()
+ with self._get_osurandom_engine() as e:
+ # Set the engine as the default RAND provider.
+ res = self._lib.ENGINE_set_default_RAND(e)
+ self.openssl_assert(res == 1)
+ # Reset the RNG to use the new engine.
+ self._lib.RAND_cleanup()
def osrandom_engine_implementation(self):
buf = self._ffi.new("char[]", 64)