aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/backends/openssl/hashes.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2016-03-10 20:54:32 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2016-03-10 21:03:16 -0400
commitd9e21589f179afdee3a8e0b9e2e3e825f324be8a (patch)
tree6b8c119902058ad093a8d2272cc9974f926b162c /src/cryptography/hazmat/backends/openssl/hashes.py
parentf10cc3866360a0c37f30d726f32333e0bae5eeda (diff)
downloadcryptography-d9e21589f179afdee3a8e0b9e2e3e825f324be8a.tar.gz
cryptography-d9e21589f179afdee3a8e0b9e2e3e825f324be8a.tar.bz2
cryptography-d9e21589f179afdee3a8e0b9e2e3e825f324be8a.zip
opaque EVP_MD_CTX and wrap EVP_MD_CTX_new + EVP_MD_CTX_free
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/hashes.py')
-rw-r--r--src/cryptography/hazmat/backends/openssl/hashes.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/hashes.py b/src/cryptography/hazmat/backends/openssl/hashes.py
index 02ce5f0d..2c8fce1a 100644
--- a/src/cryptography/hazmat/backends/openssl/hashes.py
+++ b/src/cryptography/hazmat/backends/openssl/hashes.py
@@ -18,9 +18,10 @@ class _HashContext(object):
self._backend = backend
if ctx is None:
- ctx = self._backend._lib.EVP_MD_CTX_create()
- ctx = self._backend._ffi.gc(ctx,
- self._backend._lib.EVP_MD_CTX_destroy)
+ ctx = self._backend._lib.Cryptography_EVP_MD_CTX_new()
+ ctx = self._backend._ffi.gc(
+ ctx, self._backend._lib.Cryptography_EVP_MD_CTX_free
+ )
evp_md = self._backend._lib.EVP_get_digestbyname(
algorithm.name.encode("ascii"))
if evp_md == self._backend._ffi.NULL:
@@ -38,9 +39,9 @@ class _HashContext(object):
algorithm = utils.read_only_property("_algorithm")
def copy(self):
- copied_ctx = self._backend._lib.EVP_MD_CTX_create()
+ copied_ctx = self._backend._lib.Cryptography_EVP_MD_CTX_new()
copied_ctx = self._backend._ffi.gc(
- copied_ctx, self._backend._lib.EVP_MD_CTX_destroy
+ copied_ctx, self._backend._lib.Cryptography_EVP_MD_CTX_free
)
res = self._backend._lib.EVP_MD_CTX_copy_ex(copied_ctx, self._ctx)
self._backend.openssl_assert(res != 0)
@@ -57,6 +58,4 @@ class _HashContext(object):
res = self._backend._lib.EVP_DigestFinal_ex(self._ctx, buf, outlen)
self._backend.openssl_assert(res != 0)
self._backend.openssl_assert(outlen[0] == self.algorithm.digest_size)
- res = self._backend._lib.EVP_MD_CTX_cleanup(self._ctx)
- self._backend.openssl_assert(res == 1)
return self._backend._ffi.buffer(buf)[:outlen[0]]