aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-28 11:15:03 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-28 11:15:03 -0400
commit7df9094221fd7cf2a76dbc21546569322d770072 (patch)
tree7208baeaf02f0e7c8cf5e39d10864d28481df17a
parent4ef63b64a9517cb4b1e3f4c5b8068e3467378862 (diff)
downloadcryptography-7df9094221fd7cf2a76dbc21546569322d770072.tar.gz
cryptography-7df9094221fd7cf2a76dbc21546569322d770072.tar.bz2
cryptography-7df9094221fd7cf2a76dbc21546569322d770072.zip
be more pedantic in checking the written size of the digest (refs #696)
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index c7ae9141..f3febd94 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -535,9 +535,10 @@ class _HashContext(object):
def finalize(self):
buf = self._backend._ffi.new("unsigned char[]",
self.algorithm.digest_size)
- res = self._backend._lib.EVP_DigestFinal_ex(self._ctx, buf,
- self._backend._ffi.NULL)
+ outlen = self._backend._ffi.new("unsigned int *")
+ res = self._backend._lib.EVP_DigestFinal_ex(self._ctx, buf, outlen)
assert res != 0
+ assert outlen[0] == self.algorithm.digest_size
res = self._backend._lib.EVP_MD_CTX_cleanup(self._ctx)
assert res == 1
return self._backend._ffi.buffer(buf)[:]