From dd53a5b216ac45620e7eee0c5a70e9dbfa33d08d Mon Sep 17 00:00:00 2001 From: Glyph Date: Sat, 27 Jun 2015 15:16:25 -0700 Subject: also retain method with a global reference --- src/cryptography/hazmat/bindings/openssl/binding.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py index 17dad4c1..d3999959 100644 --- a/src/cryptography/hazmat/bindings/openssl/binding.py +++ b/src/cryptography/hazmat/bindings/openssl/binding.py @@ -34,16 +34,18 @@ def osrandom_rand_status(): return 1 +method = ffi.new( + "RAND_METHOD*", dict(bytes=osrandom_rand_bytes, + pseudorand=osrandom_pseudo_rand_bytes, + status=osrandom_rand_status) +) + + def _register_osrandom_engine(): looked_up_engine = lib.ENGINE_by_id(_osrandom_engine_id) if looked_up_engine != ffi.NULL: return 2 - method = ffi.new( - "RAND_METHOD*", dict(bytes=osrandom_rand_bytes, - pseudorand=osrandom_pseudo_rand_bytes, - status=osrandom_rand_status) - ) engine = lib.ENGINE_new() try: result = lib.ENGINE_set_id(engine, _osrandom_engine_id) -- cgit v1.2.3