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 | |
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')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 19 | ||||
-rw-r--r-- | src/cryptography/hazmat/bindings/openssl/_conditional.py | 23 |
2 files changed, 10 insertions, 32 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): diff --git a/src/cryptography/hazmat/bindings/openssl/_conditional.py b/src/cryptography/hazmat/bindings/openssl/_conditional.py index 3fecfe59..044a6a46 100644 --- a/src/cryptography/hazmat/bindings/openssl/_conditional.py +++ b/src/cryptography/hazmat/bindings/openssl/_conditional.py @@ -343,40 +343,17 @@ def cryptography_has_evp_r_memory_limit_exceeded(): def cryptography_has_engine(): return [ - "ENGINE_get_first", - "ENGINE_get_last", "ENGINE_add", - "ENGINE_remove", "ENGINE_by_id", "ENGINE_init", "ENGINE_finish", - "ENGINE_load_builtin_engines", "ENGINE_get_default_RAND", "ENGINE_set_default_RAND", - "ENGINE_register_RAND", "ENGINE_unregister_RAND", - "ENGINE_register_all_RAND", - "ENGINE_ctrl", "ENGINE_ctrl_cmd", - "ENGINE_ctrl_cmd_string", - "ENGINE_new", "ENGINE_free", - "ENGINE_up_ref", - "ENGINE_set_id", - "ENGINE_set_name", - "ENGINE_set_RAND", - "ENGINE_set_destroy_function", - "ENGINE_set_init_function", - "ENGINE_set_finish_function", - "ENGINE_set_ctrl_function", - "ENGINE_get_id", "ENGINE_get_name", - "ENGINE_get_RAND", - "ENGINE_add_conf_module", - "ENGINE_load_openssl", "ENGINE_load_dynamic", - "ENGINE_cleanup", - "ENGINE_METHOD_RAND", "ENGINE_R_CONFLICTING_ENGINE_ID", "Cryptography_add_osrandom_engine", ] |