From 56ac648704e5515f44ffc3607faa36fb6f7fd2e5 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 20 Oct 2013 09:33:44 -0700 Subject: Cleanup hash ctxs when we're done with them --- cryptography/bindings/openssl/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index 3c2cf2e2..f6b6677f 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -168,6 +168,8 @@ class API(object): buf = self.ffi.new("unsigned char[]", digest_size) res = self.lib.EVP_DigestFinal_ex(ctx, buf, self.ffi.NULL) assert res != 0 + res = self.lib.EVP_MD_CTX_cleanup(ctx) + assert res != 0 return self.ffi.buffer(buf)[:digest_size] def copy_hash_context(self, ctx): -- cgit v1.2.3 From fb84cadbe89aceee31ba42f1c4aec10391864897 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 20 Oct 2013 09:52:20 -0700 Subject: Use more precise assertions --- cryptography/bindings/openssl/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cryptography/bindings/openssl/api.py b/cryptography/bindings/openssl/api.py index f6b6677f..9d5cbfbc 100644 --- a/cryptography/bindings/openssl/api.py +++ b/cryptography/bindings/openssl/api.py @@ -144,7 +144,7 @@ class API(object): res = self.lib.EVP_EncryptFinal_ex(ctx, buf, outlen) assert res != 0 res = self.lib.EVP_CIPHER_CTX_cleanup(ctx) - assert res != 0 + assert res == 1 return self.ffi.buffer(buf)[:outlen[0]] def supports_hash(self, hash_cls): @@ -169,7 +169,7 @@ class API(object): res = self.lib.EVP_DigestFinal_ex(ctx, buf, self.ffi.NULL) assert res != 0 res = self.lib.EVP_MD_CTX_cleanup(ctx) - assert res != 0 + assert res == 1 return self.ffi.buffer(buf)[:digest_size] def copy_hash_context(self, ctx): -- cgit v1.2.3