diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-06-27 10:33:56 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-06-27 10:33:56 -0400 |
commit | 1c453c25e35ba564746e599f64a389bb77263799 (patch) | |
tree | 1a39c75a462dc93b60ee9ab078a3f02ca04a62b6 /src | |
parent | e4f01bedb4369e4b83c8b77bb128f0c94b0881fb (diff) | |
download | cryptography-1c453c25e35ba564746e599f64a389bb77263799.tar.gz cryptography-1c453c25e35ba564746e599f64a389bb77263799.tar.bz2 cryptography-1c453c25e35ba564746e599f64a389bb77263799.zip |
More branch coverage improvements. By virtue of reorganization and a new test
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index e27fb6e8..af66aca1 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -1351,9 +1351,6 @@ class Backend(object): def _private_key_bytes(self, encoding, format, encryption_algorithm, evp_pkey, cdata): - if not isinstance(encoding, serialization.Encoding): - raise TypeError("encoding must be an item from the Encoding enum") - if not isinstance(format, serialization.PrivateFormat): raise TypeError( "format must be an item from the PrivateFormat enum" @@ -1416,6 +1413,8 @@ class Backend(object): elif format is serialization.PrivateFormat.PKCS8: write_bio = self._lib.i2d_PKCS8PrivateKey_bio key = evp_pkey + else: + raise TypeError("encoding must be an item from the Encoding enum") bio = self._create_mem_bio() res = write_bio( @@ -1448,11 +1447,6 @@ class Backend(object): if not isinstance(encoding, serialization.Encoding): raise TypeError("encoding must be an item from the Encoding enum") - if not isinstance(format, serialization.PublicFormat): - raise TypeError( - "format must be an item from the PublicFormat enum" - ) - if format is serialization.PublicFormat.SubjectPublicKeyInfo: if encoding is serialization.Encoding.PEM: write_bio = self._lib.PEM_write_bio_PUBKEY @@ -1469,6 +1463,10 @@ class Backend(object): write_bio = self._lib.i2d_RSAPublicKey_bio key = cdata + else: + raise TypeError( + "format must be an item from the PublicFormat enum" + ) bio = self._create_mem_bio() res = write_bio(bio, key) |