CRLNumber needs to be a class for reasons.
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py
index 45c0df5..7e89ac6 100644
--- a/src/cryptography/hazmat/backends/openssl/x509.py
+++ b/src/cryptography/hazmat/backends/openssl/x509.py
@@ -182,7 +182,7 @@
def _decode_crl_number(backend, ext):
asn1_int = backend._ffi.cast("ASN1_INTEGER *", ext)
asn1_int = backend._ffi.gc(asn1_int, backend._lib.ASN1_INTEGER_free)
- return backend._asn1_integer_to_int(asn1_int)
+ return x509.CRLNumber(backend._asn1_integer_to_int(asn1_int))
class _X509ExtensionParser(object):
diff --git a/src/cryptography/x509/__init__.py b/src/cryptography/x509/__init__.py
index 70e1d3d..c4434fd 100644
--- a/src/cryptography/x509/__init__.py
+++ b/src/cryptography/x509/__init__.py
@@ -14,7 +14,7 @@
from cryptography.x509.extensions import (
AccessDescription, AuthorityInformationAccess,
AuthorityKeyIdentifier, BasicConstraints, CRLDistributionPoints,
- CertificatePolicies, DistributionPoint, DuplicateExtension,
+ CRLNumber, CertificatePolicies, DistributionPoint, DuplicateExtension,
ExtendedKeyUsage, Extension, ExtensionNotFound, ExtensionType, Extensions,
GeneralNames, InhibitAnyPolicy, IssuerAlternativeName, KeyUsage,
NameConstraints, NoticeReference, OCSPNoCheck, PolicyInformation,
@@ -124,6 +124,7 @@
"ExtendedKeyUsage",
"OCSPNoCheck",
"BasicConstraints",
+ "CRLNumber",
"KeyUsage",
"AuthorityInformationAccess",
"AccessDescription",
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 71ce8a1..15feb71 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -109,6 +109,31 @@
@utils.register_interface(ExtensionType)
+class CRLNumber(object):
+ oid = ExtensionOID.CRL_NUMBER
+
+ def __init__(self, crl_number):
+ if not isinstance(crl_number, six.integer_types):
+ raise TypeError("crl_number must be an integer")
+
+ self._crl_number = crl_number
+
+ def __eq__(self, other):
+ if not isinstance(other, CRLNumber):
+ return NotImplemented
+
+ return self.crl_number == other.crl_number
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __repr__(self):
+ return "<CRLNumber({0})>".format(self.crl_number)
+
+ crl_number = utils.read_only_property("_crl_number")
+
+
+@utils.register_interface(ExtensionType)
class AuthorityKeyIdentifier(object):
oid = ExtensionOID.AUTHORITY_KEY_IDENTIFIER