aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cryptography/x509/extensions.py3
-rw-r--r--tests/test_x509_ext.py8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index ca323a3b..7979ccb2 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -1022,6 +1022,9 @@ class CRLReason(object):
def __ne__(self, other):
return not self == other
+ def __hash__(self):
+ return hash(self.reason)
+
reason = utils.read_only_property("_reason")
diff --git a/tests/test_x509_ext.py b/tests/test_x509_ext.py
index 898f9bcf..cfca5794 100644
--- a/tests/test_x509_ext.py
+++ b/tests/test_x509_ext.py
@@ -140,6 +140,14 @@ class TestCRLReason(object):
assert reason1 != reason2
assert reason1 != object()
+ def test_hash(self):
+ reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ reason2 = x509.CRLReason(x509.ReasonFlags.unspecified)
+ reason3 = x509.CRLReason(x509.ReasonFlags.ca_compromise)
+
+ assert hash(reason1) == hash(reason2)
+ assert hash(reason1) != hash(reason3)
+
def test_repr(self):
reason1 = x509.CRLReason(x509.ReasonFlags.unspecified)
assert repr(reason1) == (