diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-08 11:40:48 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-09-08 11:40:48 -0700 |
commit | f0ca2e8bf0eaaba32ea0fe1a608c2a5c6348f5fa (patch) | |
tree | 896d51f203f627fce998fdec0fb404e0788ee5ee /cryptography | |
parent | 86dd8345a9bd8f826b950b4574072427676f43b3 (diff) | |
download | cryptography-f0ca2e8bf0eaaba32ea0fe1a608c2a5c6348f5fa.tar.gz cryptography-f0ca2e8bf0eaaba32ea0fe1a608c2a5c6348f5fa.tar.bz2 cryptography-f0ca2e8bf0eaaba32ea0fe1a608c2a5c6348f5fa.zip |
Start moving everything to the new API
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 14 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/serialization.py | 22 |
2 files changed, 29 insertions, 7 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 01e61283..333bef0a 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -25,7 +25,8 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.backends.interfaces import ( CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, - HashBackend, PBKDF2HMACBackend, PKCS8SerializationBackend, RSABackend, + HashBackend, PBKDF2HMACBackend, PEMSerializationBackend, + PKCS8SerializationBackend, RSABackend, TraditionalOpenSSLSerializationBackend ) from cryptography.hazmat.backends.openssl.ciphers import ( @@ -74,6 +75,7 @@ _OpenSSLError = collections.namedtuple("_OpenSSLError", @utils.register_interface(PKCS8SerializationBackend) @utils.register_interface(RSABackend) @utils.register_interface(TraditionalOpenSSLSerializationBackend) +@utils.register_interface(PEMSerializationBackend) class Backend(object): """ OpenSSL API binding interfaces. @@ -770,12 +772,7 @@ class Backend(object): def create_cmac_ctx(self, algorithm): return _CMACContext(self, algorithm) - def load_traditional_openssl_pem_private_key(self, data, password): - # OpenSSLs API for loading PKCS#8 certs can also load the traditional - # format so we just use that for both of them. - return self.load_pkcs8_pem_private_key(data, password) - - def load_pkcs8_pem_private_key(self, data, password): + def load_pem_private_key(self, data, password): return self._load_key( self._lib.PEM_read_bio_PrivateKey, self._evp_pkey_to_private_key, @@ -783,6 +780,9 @@ class Backend(object): password, ) + load_traditional_openssl_pem_private_key = load_pkcs8_pem_private_key = \ + load_pem_private_key + def _load_key(self, openssl_read_func, convert_func, data, password): mem_bio = self._bytes_to_bio(data) diff --git a/cryptography/hazmat/primitives/serialization.py b/cryptography/hazmat/primitives/serialization.py index 55b8640e..cf1ca8ec 100644 --- a/cryptography/hazmat/primitives/serialization.py +++ b/cryptography/hazmat/primitives/serialization.py @@ -13,12 +13,34 @@ from __future__ import absolute_import, division, print_function +import warnings + +from cryptography import utils + def load_pem_traditional_openssl_private_key(data, password, backend): + warnings.warn( + "load_pem_traditional_openssl_private_key is deprecated and will be " + "removed in a future version, use load_pem_private_key instead.", + utils.DeprecatedIn06, + stacklevel=2 + ) + return backend.load_traditional_openssl_pem_private_key( data, password ) def load_pem_pkcs8_private_key(data, password, backend): + warnings.warn( + "load_pem_pkcs8_private_key is deprecated and will be removed in a " + "future version, use load_pem_private_key instead.", + utils.DeprecatedIn06, + stacklevel=2 + ) + return backend.load_pkcs8_pem_private_key(data, password) + + +def load_pem_private_key(data, password, backend): + return backend.load_pem_private_key(data, password) |