Merge pull request #2078 from alex/ssh-load-coverage
Improvemed branch coverage for ssh public key loading
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index af66aca..18faecb 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -685,8 +685,7 @@
def generate_dsa_parameters(self, key_size):
if key_size not in (1024, 2048, 3072):
- raise ValueError(
- "Key size must be 1024 or 2048 or 3072 bits.")
+ raise ValueError("Key size must be 1024 or 2048 or 3072 bits.")
if (self._lib.OPENSSL_VERSION_NUMBER < 0x1000000f and
key_size > 1024):
diff --git a/src/cryptography/hazmat/primitives/serialization.py b/src/cryptography/hazmat/primitives/serialization.py
index 8699fa9..9fbc32b 100644
--- a/src/cryptography/hazmat/primitives/serialization.py
+++ b/src/cryptography/hazmat/primitives/serialization.py
@@ -106,12 +106,11 @@
if rest:
raise ValueError('Key body contains extra bytes.')
- if curve_name == b"nistp256":
- curve = ec.SECP256R1()
- elif curve_name == b"nistp384":
- curve = ec.SECP384R1()
- elif curve_name == b"nistp521":
- curve = ec.SECP521R1()
+ curve = {
+ b"nistp256": ec.SECP256R1,
+ b"nistp384": ec.SECP384R1,
+ b"nistp521": ec.SECP521R1,
+ }[curve_name]()
if six.indexbytes(data, 0) != 4:
raise NotImplementedError(