aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/x509
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-09-14 07:42:33 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-09-13 19:42:33 -0400
commitab96a53bc9020a4d605d57dc972e45df5c8c4862 (patch)
treeef8a1f47c623e5099f5f398387c1df9b25736613 /src/cryptography/x509
parent979c26303fbd6a2f4044855d989f4a74a4d51ac5 (diff)
downloadcryptography-ab96a53bc9020a4d605d57dc972e45df5c8c4862.tar.gz
cryptography-ab96a53bc9020a4d605d57dc972e45df5c8c4862.tar.bz2
cryptography-ab96a53bc9020a4d605d57dc972e45df5c8c4862.zip
implement __hash__ on CertificatePolicies and its child classes (#3914)
Diffstat (limited to 'src/cryptography/x509')
-rw-r--r--src/cryptography/x509/extensions.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 8880f744..9d6b3e79 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -597,6 +597,9 @@ class CertificatePolicies(object):
def __getitem__(self, idx):
return self._policies[idx]
+ def __hash__(self):
+ return hash(tuple(self._policies))
+
class PolicyInformation(object):
def __init__(self, policy_identifier, policy_qualifiers):
@@ -636,6 +639,14 @@ class PolicyInformation(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ if self.policy_qualifiers is not None:
+ pq = tuple(self.policy_qualifiers)
+ else:
+ pq = None
+
+ return hash((self.policy_identifier, pq))
+
policy_identifier = utils.read_only_property("_policy_identifier")
policy_qualifiers = utils.read_only_property("_policy_qualifiers")
@@ -670,6 +681,9 @@ class UserNotice(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash((self.notice_reference, self.explicit_text))
+
notice_reference = utils.read_only_property("_notice_reference")
explicit_text = utils.read_only_property("_explicit_text")
@@ -703,6 +717,9 @@ class NoticeReference(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash((self.organization, tuple(self.notice_numbers)))
+
organization = utils.read_only_property("_organization")
notice_numbers = utils.read_only_property("_notice_numbers")