From f2c2dfd7ce179b1763a98747282ea2ce019d6c1a Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Tue, 19 Mar 2019 09:23:54 +0800 Subject: add new branch for unsupported openssh serialization (#4813) we don't support ed448 openssh keys so we'll use that to test this branch. if we ever do support ed448 keys we can always just call this private method directly to keep coverage. --- src/cryptography/hazmat/backends/openssl/backend.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index 779d2ee1..74dedbe0 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -1892,8 +1892,7 @@ class Backend(object): ssh._ssh_write_string(b"ssh-ed25519") + ssh._ssh_write_string(raw_bytes) ) - else: - assert isinstance(key, ec.EllipticCurvePublicKey) + elif isinstance(key, ec.EllipticCurvePublicKey): public_numbers = key.public_numbers() try: curve_name = { @@ -1916,6 +1915,10 @@ class Backend(object): ssh._ssh_write_string(curve_name) + ssh._ssh_write_string(point) ) + else: + raise ValueError( + "OpenSSH encoding is not supported for this key type" + ) def _parameter_bytes(self, encoding, format, cdata): if encoding is serialization.Encoding.OpenSSH: -- cgit v1.2.3