aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/x509
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-30 10:58:25 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-12-30 10:58:25 -0600
commit14fd697c5c4a2435b2113e425c95ac9c05702cc2 (patch)
tree08c194803532e2d49184565a8f7a3cf22b63826f /src/cryptography/x509
parent42e0c790c5150bec47add345065929ca7df8e6ff (diff)
downloadcryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.tar.gz
cryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.tar.bz2
cryptography-14fd697c5c4a2435b2113e425c95ac9c05702cc2.zip
add UnrecognizedExtension class
Diffstat (limited to 'src/cryptography/x509')
-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))