diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-12-26 15:17:40 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-12-26 15:17:40 -0600 |
commit | 945ee6e9cdd2d0a24381c6b79128cf47137c6b83 (patch) | |
tree | 4bd948224c5819481e3df46187228a092af97100 | |
parent | 3bcd2d778f91e10a78ec5af3b53abbbc388fd7c2 (diff) | |
parent | 410fe35dab3eb60fbcc5791e5ef24584ab45c324 (diff) | |
download | cryptography-945ee6e9cdd2d0a24381c6b79128cf47137c6b83.tar.gz cryptography-945ee6e9cdd2d0a24381c6b79128cf47137c6b83.tar.bz2 cryptography-945ee6e9cdd2d0a24381c6b79128cf47137c6b83.zip |
Merge pull request #2583 from alex/ski-hash
Refs #2578 -- implement __hash__ on SubjectKeyIdentifier
-rw-r--r-- | src/cryptography/x509/extensions.py | 3 | ||||
-rw-r--r-- | tests/test_x509_ext.py | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index 0eed21b9..4681629c 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -235,6 +235,9 @@ class SubjectKeyIdentifier(object): def __ne__(self, other): return not self == other + def __hash__(self): + return hash(self.digest) + @utils.register_interface(ExtensionType) class AuthorityInformationAccess(object): diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py index a12a48fc..8aaf8059 100644 --- a/tests/test_x509_ext.py +++ b/tests/test_x509_ext.py @@ -687,6 +687,20 @@ class TestSubjectKeyIdentifier(object): assert ski != ski2 assert ski != object() + def test_hash(self): + ski1 = x509.SubjectKeyIdentifier( + binascii.unhexlify(b"092384932230498bc980aa8098456f6ff7ff3ac9") + ) + ski2 = x509.SubjectKeyIdentifier( + binascii.unhexlify(b"092384932230498bc980aa8098456f6ff7ff3ac9") + ) + ski3 = x509.SubjectKeyIdentifier( + binascii.unhexlify(b"aa8098456f6ff7ff3ac9092384932230498bc980") + ) + + assert hash(ski1) == hash(ski2) + assert hash(ski1) != hash(ski3) + class TestAuthorityKeyIdentifier(object): def test_authority_cert_issuer_not_generalname(self): |