aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-01-04 15:54:32 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-01-04 15:55:51 -0600
commit76da86a9d5f5b395a89e2768d07b19b23a96d8d8 (patch)
tree865f90b52721f5f6b1972a976404f979c7b29a46
parentfc89b5512782ce3beee64c039512991bba7e1e1c (diff)
downloadcryptography-76da86a9d5f5b395a89e2768d07b19b23a96d8d8.tar.gz
cryptography-76da86a9d5f5b395a89e2768d07b19b23a96d8d8.tar.bz2
cryptography-76da86a9d5f5b395a89e2768d07b19b23a96d8d8.zip
add DER backend interfaces
-rw-r--r--docs/hazmat/backends/interfaces.rst24
-rw-r--r--src/cryptography/hazmat/backends/interfaces.py16
2 files changed, 40 insertions, 0 deletions
diff --git a/docs/hazmat/backends/interfaces.rst b/docs/hazmat/backends/interfaces.rst
index e9ee9467..3d222684 100644
--- a/docs/hazmat/backends/interfaces.rst
+++ b/docs/hazmat/backends/interfaces.rst
@@ -468,6 +468,30 @@ A specific ``backend`` may provide one or more of these interfaces.
serialized data contains.
:raises ValueError: If the data could not be deserialized.
+.. class:: DERSerializationBackend
+
+ .. versionadded:: 0.8
+
+ A backend with methods for working with DER encoded keys.
+
+ .. method:: load_der_private_key(data, password)
+
+ :param bytes data: DER data to load.
+ :param bytes password: The password to use if the data is encrypted.
+ Should be ``None`` if the data is not encrypted.
+ :return: A new instance of the appropriate type of private key that the
+ serialized data contains.
+ :raises ValueError: If the data could not be deserialized.
+ :raises cryptography.exceptions.UnsupportedAlgorithm: If the data is
+ encrypted with an unsupported algorithm.
+
+ .. method:: load_der_public_key(data)
+
+ :param bytes data: DER data to load.
+ :return: A new instance of the appropriate type of public key
+ serialized data contains.
+ :raises ValueError: If the data could not be deserialized.
+
.. class:: X509Backend
.. versionadded:: 0.7
diff --git a/src/cryptography/hazmat/backends/interfaces.py b/src/cryptography/hazmat/backends/interfaces.py
index 4dc879ac..6feb8106 100644
--- a/src/cryptography/hazmat/backends/interfaces.py
+++ b/src/cryptography/hazmat/backends/interfaces.py
@@ -233,6 +233,22 @@ class PEMSerializationBackend(object):
@six.add_metaclass(abc.ABCMeta)
+class DERSerializationBackend(object):
+ @abc.abstractmethod
+ def load_der_private_key(self, data, password):
+ """
+ Loads a priate key from DER encoded data. Uses the provided password
+ if the data is encrypted.
+ """
+
+ @abc.abstractmethod
+ def load_der_public_key(self, data):
+ """
+ Loads a public key from DER encoded data.
+ """
+
+
+@six.add_metaclass(abc.ABCMeta)
class X509Backend(object):
@abc.abstractmethod
def load_pem_x509_certificate(self, data):