diff options
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/ec.py | 7 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_ec.py | 7 |
2 files changed, 2 insertions, 12 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index f25ea6de..7782133c 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -272,21 +272,18 @@ class EllipticCurvePublicNumbers(object): if not isinstance(curve, EllipticCurve): raise TypeError("curve must be an EllipticCurve instance") - if data == b'\x00': - raise ValueError("null points are not supported") - elif data.startswith(b'\x04'): + if data.startswith(b'\x04'): # key_size is in bits. Convert to bytes and round up byte_length = (curve.key_size + 7) // 8 if len(data) == 2 * byte_length + 1: x = utils.int_from_bytes(data[1:byte_length + 1], 'big') y = utils.int_from_bytes(data[byte_length + 1:], 'big') + return cls(x, y, curve) else: raise ValueError('Invalid elliptic curve point data length') else: raise ValueError('Unsupported elliptic curve point type') - return cls(x, y, curve) - curve = utils.read_only_property("_curve") x = utils.read_only_property("_x") y = utils.read_only_property("_y") diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index ac1ba27a..5baaa3cd 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -167,13 +167,6 @@ def test_encode_point(): ) -def test_from_encoded_point_null(): - with pytest.raises(ValueError): - ec.EllipticCurvePublicNumbers.from_encoded_point( - ec.SECP384R1(), b"\x00" - ) - - def test_from_encoded_point(): # secp256r1 point data = binascii.unhexlify( |