From 893cda63da0f708e4c335a69003746c32ad51895 Mon Sep 17 00:00:00 2001 From: Andrew Wason Date: Sat, 9 Feb 2019 11:23:39 -0500 Subject: Fix numbers vs key mixups --- paramiko/ecdsakey.py | 5 ++--- paramiko/kex_ecdh_nist.py | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/paramiko/ecdsakey.py b/paramiko/ecdsakey.py index 3e8e2526..b607eee1 100644 --- a/paramiko/ecdsakey.py +++ b/paramiko/ecdsakey.py @@ -160,12 +160,11 @@ class ECDSAKey(PKey): pointinfo = msg.get_binary() try: - numbers = ec.EllipticCurvePublicKey.from_encoded_point( + self.verifying_key = ec.EllipticCurvePublicKey.from_encoded_point( self.ecdsa_curve.curve_class(), pointinfo - ).public_numbers() + ) except ValueError: raise SSHException("Invalid public key") - self.verifying_key = numbers.public_key(backend=default_backend()) @classmethod def supported_key_format_identifiers(cls): diff --git a/paramiko/kex_ecdh_nist.py b/paramiko/kex_ecdh_nist.py index beabbe5f..ad5c9c79 100644 --- a/paramiko/kex_ecdh_nist.py +++ b/paramiko/kex_ecdh_nist.py @@ -66,9 +66,9 @@ class KexNistp256: Q_C_bytes = m.get_string() self.Q_C = ec.EllipticCurvePublicKey.from_encoded_point( self.curve, Q_C_bytes - ).public_numbers() + ) K_S = self.transport.get_server_key().asbytes() - K = self.P.exchange(ec.ECDH(), self.Q_C.public_key(default_backend())) + K = self.P.exchange(ec.ECDH(), self.Q_C) K = long(hexlify(K), 16) # compute exchange hash hm = Message() @@ -110,9 +110,9 @@ class KexNistp256: Q_S_bytes = m.get_string() self.Q_S = ec.EllipticCurvePublicKey.from_encoded_point( self.curve, Q_S_bytes - ).public_numbers() + ) sig = m.get_binary() - K = self.P.exchange(ec.ECDH(), self.Q_S.public_key(default_backend())) + K = self.P.exchange(ec.ECDH(), self.Q_S) K = long(hexlify(K), 16) # compute exchange hash and verify signature hm = Message() -- cgit v1.2.3