diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-07-07 16:46:16 -0700 | 
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-07-07 16:46:16 -0700 | 
| commit | f0a3de4adb1cc4ae8b8d0892b6ad06c20a529206 (patch) | |
| tree | 9282f129082f1db7e06769624cebb6fd8ffe9b53 /cryptography | |
| parent | e4b1e854e0482ae4bc363f7938ad5b214c124d9f (diff) | |
| parent | 32b1a8e0268ec0585ee71b9d8d6d2413fd978be7 (diff) | |
| download | cryptography-f0a3de4adb1cc4ae8b8d0892b6ad06c20a529206.tar.gz cryptography-f0a3de4adb1cc4ae8b8d0892b6ad06c20a529206.tar.bz2 cryptography-f0a3de4adb1cc4ae8b8d0892b6ad06c20a529206.zip | |
Merge pull request #1222 from reaperhulk/add-pkcs8serialization-multibackend
add PKCS8SerializationBackend support to MultiBackend
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/exceptions.py | 1 | ||||
| -rw-r--r-- | cryptography/hazmat/backends/multibackend.py | 12 | 
2 files changed, 12 insertions, 1 deletions
| diff --git a/cryptography/exceptions.py b/cryptography/exceptions.py index c64b67f4..c14763f7 100644 --- a/cryptography/exceptions.py +++ b/cryptography/exceptions.py @@ -22,6 +22,7 @@ class _Reasons(object):      UNSUPPORTED_MGF = object()      UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object()      UNSUPPORTED_ELLIPTIC_CURVE = object() +    UNSUPPORTED_SERIALIZATION = object()  class UnsupportedAlgorithm(Exception): diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py index 800c3503..6741f045 100644 --- a/cryptography/hazmat/backends/multibackend.py +++ b/cryptography/hazmat/backends/multibackend.py @@ -17,7 +17,7 @@ from cryptography import utils  from cryptography.exceptions import UnsupportedAlgorithm, _Reasons  from cryptography.hazmat.backends.interfaces import (      CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, -    HashBackend, PBKDF2HMACBackend, RSABackend +    HashBackend, PBKDF2HMACBackend, PKCS8SerializationBackend, RSABackend  ) @@ -26,6 +26,7 @@ from cryptography.hazmat.backends.interfaces import (  @utils.register_interface(HashBackend)  @utils.register_interface(HMACBackend)  @utils.register_interface(PBKDF2HMACBackend) +@utils.register_interface(PKCS8SerializationBackend)  @utils.register_interface(RSABackend)  @utils.register_interface(DSABackend)  @utils.register_interface(EllipticCurveBackend) @@ -302,3 +303,12 @@ class MultiBackend(object):              "This backend does not support this elliptic curve.",              _Reasons.UNSUPPORTED_ELLIPTIC_CURVE          ) + +    def load_pkcs8_pem_private_key(self, data, password): +        for b in self._filtered_backends(PKCS8SerializationBackend): +            return b.load_pkcs8_pem_private_key(data, password) + +        raise UnsupportedAlgorithm( +            "This backend does not support this key serialization.", +            _Reasons.UNSUPPORTED_SERIALIZATION +        ) | 
