diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-06 19:51:43 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-06 19:51:43 -0500 |
commit | 7a31eac16d9c00b04846d2ba2690932a9f286b18 (patch) | |
tree | e0e0e22344763045cee42c8cbf7505d4925a8438 /src | |
parent | 40087ae7bde2b2455491f98a33c7fef580284ee5 (diff) | |
download | cryptography-7a31eac16d9c00b04846d2ba2690932a9f286b18.tar.gz cryptography-7a31eac16d9c00b04846d2ba2690932a9f286b18.tar.bz2 cryptography-7a31eac16d9c00b04846d2ba2690932a9f286b18.zip |
We wrote a function, now use it
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/primitives/serialization.py | 14 |
1 files changed, 2 insertions, 12 deletions
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): |