aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-12-30 20:37:43 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-12-30 20:37:43 -0500
commit7640889dbbc379fe1f164cbd3094b2189aa655ba (patch)
tree39e6b91587b9c7e7ab602eaa399770e0e1eb320e /src
parentd72d8a250e79fb15bf5ccc74897f20336775725f (diff)
parent1628b5c33f92cdfdb77125782095f3028044939f (diff)
downloadcryptography-7640889dbbc379fe1f164cbd3094b2189aa655ba.tar.gz
cryptography-7640889dbbc379fe1f164cbd3094b2189aa655ba.tar.bz2
cryptography-7640889dbbc379fe1f164cbd3094b2189aa655ba.zip
Merge pull request #2604 from reaperhulk/unrecognized-extension-class
add UnrecognizedExtension class
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/x509/__init__.py3
-rw-r--r--src/cryptography/x509/extensions.py31
2 files changed, 33 insertions, 1 deletions
diff --git a/src/cryptography/x509/__init__.py b/src/cryptography/x509/__init__.py
index dc19161e..a1deb7f4 100644
--- a/src/cryptography/x509/__init__.py
+++ b/src/cryptography/x509/__init__.py
@@ -21,7 +21,7 @@ from cryptography.x509.extensions import (
InhibitAnyPolicy, InvalidityDate, IssuerAlternativeName, KeyUsage,
NameConstraints, NoticeReference, OCSPNoCheck, PolicyInformation,
ReasonFlags, SubjectAlternativeName, SubjectKeyIdentifier,
- UnsupportedExtension, UserNotice
+ UnrecognizedExtension, UnsupportedExtension, UserNotice
)
from cryptography.x509.general_name import (
DNSName, DirectoryName, GeneralName, IPAddress, OtherName, RFC822Name,
@@ -169,4 +169,5 @@ __all__ = [
"CertificateIssuer",
"CRLReason",
"InvalidityDate",
+ "UnrecognizedExtension",
]
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index 4e7a53b6..0c5b5523 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -1065,3 +1065,34 @@ class InvalidityDate(object):
return hash(self.invalidity_date)
invalidity_date = utils.read_only_property("_invalidity_date")
+
+
+@utils.register_interface(ExtensionType)
+class UnrecognizedExtension(object):
+ def __init__(self, oid, value):
+ if not isinstance(oid, ObjectIdentifier):
+ raise TypeError("oid must be an ObjectIdentifier")
+ self._oid = oid
+ self._value = value
+
+ oid = utils.read_only_property("_oid")
+ value = utils.read_only_property("_value")
+
+ def __repr__(self):
+ return (
+ "<UnrecognizedExtension(oid={0.oid}, value={0.value!r})>".format(
+ self
+ )
+ )
+
+ def __eq__(self, other):
+ if not isinstance(other, UnrecognizedExtension):
+ return NotImplemented
+
+ return self.oid == other.oid and self.value == other.value
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __hash__(self):
+ return hash((self.oid, self.value))