From 05c122b5614740a50bee67808d4540ed94ae69e9 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 24 Nov 2014 08:41:05 -1000 Subject: Initial minimal X509Certificate interfaces This will be expanded in the future to include algorithm identifier, subject, issuer, extensions, etc --- src/cryptography/hazmat/primitives/interfaces.py | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/primitives/interfaces.py b/src/cryptography/hazmat/primitives/interfaces.py index 7d9fc4fb..561be972 100644 --- a/src/cryptography/hazmat/primitives/interfaces.py +++ b/src/cryptography/hazmat/primitives/interfaces.py @@ -488,3 +488,36 @@ class MACContext(object): # DeprecatedIn07 CMACContext = MACContext + + +@six.add_metaclass(abc.ABCMeta) +class X509Certificate(object): + @abc.abstractmethod + def fingerprint(self, algorithm): + """ + Returns bytes using digest passed. + """ + + @abc.abstractproperty + def serial(self): + """ + Returns certificate serial number + """ + + @abc.abstractmethod + def public_key(self): + """ + Returns the public key + """ + + @abc.abstractproperty + def not_before(self): + """ + Not before time (represented as UTC datetime) + """ + + @abc.abstractproperty + def not_after(self): + """ + Not after time (represented as UTC datetime) + """ -- cgit v1.2.3 From 6c4302e64c8ee866bfde6cd0acd5a86a9b1834de Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 24 Nov 2014 09:20:38 -1000 Subject: add backend interface for loading x509 certificates --- src/cryptography/hazmat/backends/interfaces.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/interfaces.py b/src/cryptography/hazmat/backends/interfaces.py index f433afcb..dcdd1c39 100644 --- a/src/cryptography/hazmat/backends/interfaces.py +++ b/src/cryptography/hazmat/backends/interfaces.py @@ -250,3 +250,12 @@ class PKCS8SerializationBackend(object): Load a private key from PKCS8 encoded data, using password if the data is encrypted. """ + + +@six.add_metaclass(abc.ABCMeta) +class X509Backend(object): + @abc.abstractmethod + def load_pem_x509_certificate(self, data): + """ + Load an X.509 certificate from PEM encoded data. + """ -- cgit v1.2.3 From 8473df6d553a2e0bf790b613c2818beb4bd2f416 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 24 Nov 2014 17:13:59 -1000 Subject: add load_der_x509_certificate X509Backend method --- src/cryptography/hazmat/backends/interfaces.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/interfaces.py b/src/cryptography/hazmat/backends/interfaces.py index dcdd1c39..8fc78309 100644 --- a/src/cryptography/hazmat/backends/interfaces.py +++ b/src/cryptography/hazmat/backends/interfaces.py @@ -259,3 +259,9 @@ class X509Backend(object): """ Load an X.509 certificate from PEM encoded data. """ + + @abc.abstractmethod + def load_der_x509_certificate(self, data): + """ + Load an X.509 certificate from DER encoded data. + """ -- cgit v1.2.3 From 244637cedae3eef1997fd2eb85c74eb3d92d52ce Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 25 Nov 2014 08:20:59 -1000 Subject: add X509Certificate version attribute --- src/cryptography/hazmat/primitives/interfaces.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/primitives/interfaces.py b/src/cryptography/hazmat/primitives/interfaces.py index 561be972..18a62601 100644 --- a/src/cryptography/hazmat/primitives/interfaces.py +++ b/src/cryptography/hazmat/primitives/interfaces.py @@ -504,6 +504,12 @@ class X509Certificate(object): Returns certificate serial number """ + @abc.abstractproperty + def version(self): + """ + Returns the certificate version + """ + @abc.abstractmethod def public_key(self): """ -- cgit v1.2.3