From 5119125467c7cfe68f052ad804ac6ba88635739c Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 7 Jul 2015 06:24:25 -0400 Subject: no need to hash it twice, also simplify fingerprint method --- src/cryptography/hazmat/backends/openssl/x509.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index 5e42b8e4..4896e9fb 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -227,18 +227,11 @@ class _Certificate(object): return not self == other def __hash__(self): - # TODO: Using fingerprint() with SHA256 is way overkill. - return hash(self.fingerprint(hashes.SHA256())) + return hash(self.public_bytes(serialization.Encoding.DER)) def fingerprint(self, algorithm): h = hashes.Hash(algorithm, self._backend) - bio = self._backend._create_mem_bio() - res = self._backend._lib.i2d_X509_bio( - bio, self._x509 - ) - assert res == 1 - der = self._backend._read_mem_bio(bio) - h.update(der) + h.update(self.public_bytes(serialization.Encoding.DER)) return h.finalize() @property -- cgit v1.2.3