aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2019-01-20 17:24:41 -0600
committerAlex Gaynor <alex.gaynor@gmail.com>2019-01-20 17:24:41 -0600
commit2de450a2166e6a390f2d9e121b3d660b049b1807 (patch)
treeeae6eb157b62d6181364bbdeaf490aa48d9648d9 /src
parenta07b1f5463361570c3248c1096ffd8b3bff0bfa5 (diff)
downloadcryptography-2de450a2166e6a390f2d9e121b3d660b049b1807.tar.gz
cryptography-2de450a2166e6a390f2d9e121b3d660b049b1807.tar.bz2
cryptography-2de450a2166e6a390f2d9e121b3d660b049b1807.zip
deprecate encode_point and migrate all internal callers (#4720)
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py7
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/ec.py8
-rw-r--r--src/cryptography/x509/extensions.py5
3 files changed, 18 insertions, 2 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index b5232ba0..64a91f03 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -1885,10 +1885,15 @@ class Backend(object):
"Only SECP256R1, SECP384R1, and SECP521R1 curves are "
"supported by the SSH public key format"
)
+
+ point = key.public_bytes(
+ serialization.Encoding.X962,
+ serialization.PublicFormat.UncompressedPoint
+ )
return b"ecdsa-sha2-" + curve_name + b" " + base64.b64encode(
ssh._ssh_write_string(b"ecdsa-sha2-" + curve_name) +
ssh._ssh_write_string(curve_name) +
- ssh._ssh_write_string(public_numbers.encode_point())
+ ssh._ssh_write_string(point)
)
def _parameter_bytes(self, encoding, format, cdata):
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py
index c93cc090..1de0976a 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/ec.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py
@@ -359,6 +359,14 @@ class EllipticCurvePublicNumbers(object):
return backend.load_elliptic_curve_public_numbers(self)
def encode_point(self):
+ warnings.warn(
+ "encode_point has been deprecated on EllipticCurvePublicNumbers"
+ " and will be removed in a future version. Please use "
+ "EllipticCurvePublicKey.public_bytes to obtain both "
+ "compressed and uncompressed point encoding.",
+ utils.DeprecatedIn25,
+ stacklevel=2,
+ )
# key_size is in bits. Convert to bytes and round up
byte_length = (self.curve.key_size + 7) // 8
return (
diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py
index bdd445d9..88afa310 100644
--- a/src/cryptography/x509/extensions.py
+++ b/src/cryptography/x509/extensions.py
@@ -35,7 +35,10 @@ def _key_identifier_from_public_key(public_key):
serialization.PublicFormat.PKCS1,
)
elif isinstance(public_key, EllipticCurvePublicKey):
- data = public_key.public_numbers().encode_point()
+ data = public_key.public_bytes(
+ serialization.Encoding.X962,
+ serialization.PublicFormat.UncompressedPoint
+ )
else:
# This is a very slow way to do this.
serialized = public_key.public_bytes(