aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/x509/extensions.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-06-04 13:36:58 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-06-04 07:36:58 -1000
commit6a0718faddbc7b6b57f86417f6daa468c18ea248 (patch)
tree624fe16cf368a13cbbd7370b2a4780fa5da76c91 /src/cryptography/x509/extensions.py
parent140ec5d6e2167692ba5619b368f44a1b07f96a4a (diff)
downloadcryptography-6a0718faddbc7b6b57f86417f6daa468c18ea248.tar.gz
cryptography-6a0718faddbc7b6b57f86417f6daa468c18ea248.tar.bz2
cryptography-6a0718faddbc7b6b57f86417f6daa468c18ea248.zip
Refs #3461 -- parse SCTs from x.509 extension (#3480)
* Stub API for SCTs, feedback wanted * grr, flake8 * finish up the __init__ * Initial implementation and tests * write a test. it fails because computer * get the tests passing and fix some TODOs * changelog entry * This can go now * Put a skip in this test * grump * Removed unreachable code * moved changelog to the correct section * Use the deocrator for expressing requirements * This needs f for the right entry_type * coverage * syntax error * tests for coverage * better sct eq tests * docs * technically correct, the most useless kind of correct * typo and more details * bug * drop __eq__
Diffstat (limited to 'src/cryptography/x509/extensions.py')
-rw-r--r--src/cryptography/x509/extensions.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index aa30f8ff..1b64f4a5 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -18,6 +18,9 @@ from cryptography import utils
from cryptography.hazmat.primitives import constant_time, serialization
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePublicKey
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
+from cryptography.x509.certificate_transparency import (
+ SignedCertificateTimestamp
+)
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
from cryptography.x509.name import RelativeDistinguishedName
from cryptography.x509.oid import (
@@ -1152,6 +1155,39 @@ class InvalidityDate(object):
@utils.register_interface(ExtensionType)
+class PrecertificateSignedCertificateTimestamps(object):
+ oid = ExtensionOID.PRECERT_SIGNED_CERTIFICATE_TIMESTAMPS
+
+ def __init__(self, signed_certificate_timestamps):
+ signed_certificate_timestamps = list(signed_certificate_timestamps)
+ if not all(
+ isinstance(sct, SignedCertificateTimestamp)
+ for sct in signed_certificate_timestamps
+ ):
+ raise TypeError(
+ "Every item in the signed_certificate_timestamps list must be "
+ "a SignedCertificateTimestamp"
+ )
+ self._signed_certificate_timestamps = signed_certificate_timestamps
+
+ def __iter__(self):
+ return iter(self._signed_certificate_timestamps)
+
+ def __len__(self):
+ return len(self._signed_certificate_timestamps)
+
+ def __getitem__(self, idx):
+ return self._signed_certificate_timestamps[idx]
+
+ def __repr__(self):
+ return (
+ "<PrecertificateSignedCertificateTimestamps({0})>".format(
+ list(self)
+ )
+ )
+
+
+@utils.register_interface(ExtensionType)
class UnrecognizedExtension(object):
def __init__(self, oid, value):
if not isinstance(oid, ObjectIdentifier):