diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-02-25 20:43:45 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-02-25 07:43:45 -0500 |
commit | cc31c4f99e9ff1c2fa5acd0eabbf19a671b06b1d (patch) | |
tree | c10a521b576d5b51fbb1f053826665da1e4085b2 /src/cryptography/hazmat/backends/openssl | |
parent | 76c784340c3851f402abc38dff8fa5f008cdc4d4 (diff) | |
download | cryptography-cc31c4f99e9ff1c2fa5acd0eabbf19a671b06b1d.tar.gz cryptography-cc31c4f99e9ff1c2fa5acd0eabbf19a671b06b1d.tar.bz2 cryptography-cc31c4f99e9ff1c2fa5acd0eabbf19a671b06b1d.zip |
reduce our engine bindings even more (#4768)
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index d7bba224..e2a5fd78 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -119,15 +119,16 @@ class Backend(object): return binding._openssl_assert(self._lib, ok) def activate_builtin_random(self): - # Obtain a new structural reference. - e = self._lib.ENGINE_get_default_RAND() - if e != self._ffi.NULL: - self._lib.ENGINE_unregister_RAND(e) - # Reset the RNG to use the new engine. - self._lib.RAND_cleanup() - # decrement the structural reference from get_default_RAND - res = self._lib.ENGINE_finish(e) - self.openssl_assert(res == 1) + if self._lib.Cryptography_HAS_ENGINE: + # Obtain a new structural reference. + e = self._lib.ENGINE_get_default_RAND() + if e != self._ffi.NULL: + self._lib.ENGINE_unregister_RAND(e) + # Reset the RNG to use the new engine. + self._lib.RAND_cleanup() + # decrement the structural reference from get_default_RAND + res = self._lib.ENGINE_finish(e) + self.openssl_assert(res == 1) @contextlib.contextmanager def _get_osurandom_engine(self): |