From 7a31eac16d9c00b04846d2ba2690932a9f286b18 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 6 Mar 2016 19:51:43 -0500 Subject: We wrote a function, now use it --- src/cryptography/hazmat/primitives/serialization.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/primitives/serialization.py b/src/cryptography/hazmat/primitives/serialization.py index fc50456e..5c166c89 100644 --- a/src/cryptography/hazmat/primitives/serialization.py +++ b/src/cryptography/hazmat/primitives/serialization.py @@ -117,18 +117,8 @@ def _load_ssh_ecdsa_public_key(expected_key_type, decoded_data, backend): "Compressed elliptic curve points are not supported" ) - # key_size is in bits, and sometimes it's not evenly divisible by 8, so we - # add 7 to round up the number of bytes. - if len(data) != 1 + 2 * ((curve.key_size + 7) // 8): - raise ValueError("Malformed key bytes") - - x = utils.int_from_bytes( - data[1:1 + (curve.key_size + 7) // 8], byteorder='big' - ) - y = utils.int_from_bytes( - data[1 + (curve.key_size + 7) // 8:], byteorder='big' - ) - return ec.EllipticCurvePublicNumbers(x, y, curve).public_key(backend) + numbers = ec.EllipticCurvePublicNumbers.from_encoded_point(curve, data) + return numbers.public_key(backend) def _read_next_string(data): -- cgit v1.2.3