aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-07-07 06:24:25 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2015-07-07 06:24:25 -0400
commit5119125467c7cfe68f052ad804ac6ba88635739c (patch)
tree6eb924829692c762ce0eecbc617750ac9d0f935a
parent969f3a50c491b76a39261e3413277c3135050d97 (diff)
downloadcryptography-5119125467c7cfe68f052ad804ac6ba88635739c.tar.gz
cryptography-5119125467c7cfe68f052ad804ac6ba88635739c.tar.bz2
cryptography-5119125467c7cfe68f052ad804ac6ba88635739c.zip
no need to hash it twice, also simplify fingerprint method
-rw-r--r--src/cryptography/hazmat/backends/openssl/x509.py11
1 files changed, 2 insertions, 9 deletions
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