diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-31 12:00:37 -0600 | 
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-31 13:14:45 -0600 | 
| commit | 53473d3447fd6ad5d70810da3e638e6e7a59afbb (patch) | |
| tree | 889e8a5af9b0b68b8d66de50adb4df203760a50f /tests/hazmat/backends | |
| parent | 3f2524572d6efedb413558c50ba875256eadfaab (diff) | |
| download | cryptography-53473d3447fd6ad5d70810da3e638e6e7a59afbb.tar.gz cryptography-53473d3447fd6ad5d70810da3e638e6e7a59afbb.tar.bz2 cryptography-53473d3447fd6ad5d70810da3e638e6e7a59afbb.zip  | |
improve init/finish engine funcs, do a better job inc/dec struct/func refs
Diffstat (limited to 'tests/hazmat/backends')
| -rw-r--r-- | tests/hazmat/backends/test_openssl.py | 24 | 
1 files changed, 3 insertions, 21 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 4be5cd03..82832b10 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -31,7 +31,6 @@ ffi.cdef("""  static const char *const Cryptography_faux_engine_name;  static const char *const Cryptography_faux_engine_id;  int Cryptography_add_faux_engine(void); -int Cryptography_remove_faux_engine(void);  """)  dummy_engine = ffi.verify(      source=""" @@ -77,21 +76,6 @@ dummy_engine = ffi.verify(              return 1;          } - -        int Cryptography_remove_faux_engine(void) { -            ENGINE *e = ENGINE_by_id(Cryptography_faux_engine_id); -            if (e == NULL) { -                return 0; -            } -            if (!ENGINE_remove(e)) { -                ENGINE_free(e); -                return 0; -            } -            if (!ENGINE_free(e)) { -                return 0; -            } -            return 1; -        }      """,      libraries=["crypto", "ssl"],  ) @@ -103,6 +87,8 @@ def register_dummy_engine():      name = backend.lib.ENGINE_get_name(current_rand)      assert name != backend.ffi.NULL      assert name != dummy_engine.Cryptography_faux_engine_id +    res = backend.lib.ENGINE_finish(current_rand) +    assert res == 1      e = backend.lib.ENGINE_by_id(dummy_engine.Cryptography_faux_engine_id)      assert e != backend.ffi.NULL      res = backend.lib.ENGINE_init(e) @@ -115,8 +101,6 @@ def register_dummy_engine():      assert res == 1      # this resets the RNG to use the new engine      backend.lib.RAND_cleanup() -    res = backend.lib.ENGINE_finish(current_rand) -    assert res == 1  def unregister_dummy_engine(): @@ -126,10 +110,8 @@ def unregister_dummy_engine():          assert name != backend.ffi.NULL          if name == dummy_engine.Cryptography_faux_engine_name:              backend.lib.ENGINE_unregister_RAND(e) -            res = backend.lib.ENGINE_finish(e) -            assert res == 1              backend.lib.RAND_cleanup() -        res = backend.lib.ENGINE_free(e) +        res = backend.lib.ENGINE_finish(e)          assert res == 1  | 
