From a07b1f5463361570c3248c1096ffd8b3bff0bfa5 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sun, 20 Jan 2019 15:02:59 -0600 Subject: add support for encoding compressed points (#4638) * add support for encoding compressed points * review feedback --- docs/hazmat/primitives/asymmetric/ec.rst | 16 ++++++++++++---- .../hazmat/primitives/asymmetric/serialization.rst | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'docs/hazmat/primitives') diff --git a/docs/hazmat/primitives/asymmetric/ec.rst b/docs/hazmat/primitives/asymmetric/ec.rst index bd618551..a356dcaa 100644 --- a/docs/hazmat/primitives/asymmetric/ec.rst +++ b/docs/hazmat/primitives/asymmetric/ec.rst @@ -668,12 +668,20 @@ Key Interfaces .. method:: public_bytes(encoding, format) - Allows serialization of the key to bytes. Encoding ( - :attr:`~cryptography.hazmat.primitives.serialization.Encoding.PEM` or + Allows serialization of the key data to bytes. When encoding the public + key the encodings ( + :attr:`~cryptography.hazmat.primitives.serialization.Encoding.PEM`, :attr:`~cryptography.hazmat.primitives.serialization.Encoding.DER`) and format ( :attr:`~cryptography.hazmat.primitives.serialization.PublicFormat.SubjectPublicKeyInfo`) - are chosen to define the exact serialization. + are chosen to define the exact serialization. When encoding the point + the encoding + :attr:`~cryptography.hazmat.primitives.serialization.Encoding.X962` + should be used with the formats ( + :attr:`~cryptography.hazmat.primitives.serialization.PublicFormat.UncompressedPoint` + or + :attr:`~cryptography.hazmat.primitives.serialization.PublicFormat.CompressedPoint` + ). :param encoding: A value from the :class:`~cryptography.hazmat.primitives.serialization.Encoding` enum. @@ -681,7 +689,7 @@ Key Interfaces :param format: A value from the :class:`~cryptography.hazmat.primitives.serialization.PublicFormat` enum. - :return bytes: Serialized key. + :return bytes: Serialized data. .. method:: verify(signature, data, signature_algorithm) diff --git a/docs/hazmat/primitives/asymmetric/serialization.rst b/docs/hazmat/primitives/asymmetric/serialization.rst index 4c2e5f2a..87a6372c 100644 --- a/docs/hazmat/primitives/asymmetric/serialization.rst +++ b/docs/hazmat/primitives/asymmetric/serialization.rst @@ -536,6 +536,20 @@ Serialization Formats A raw format used by :doc:`/hazmat/primitives/asymmetric/x448`. It is a binary format and is invalid for other key types. + .. attribute:: CompressedPoint + + .. versionadded:: 2.5 + + A compressed elliptic curve public key as defined in ANSI X9.62 section + 4.3.6 (as well as `SEC 1 v2.0`_). + + .. attribute:: UncompressedPoint + + .. versionadded:: 2.5 + + An uncompressed elliptic curve public key as defined in ANSI X9.62 + section 4.3.6 (as well as `SEC 1 v2.0`_). + .. class:: ParameterFormat .. versionadded:: 2.0 @@ -594,6 +608,13 @@ Serialization Encodings A raw format used by :doc:`/hazmat/primitives/asymmetric/x448`. It is a binary format and is invalid for other key types. + .. attribute:: X962 + + .. versionadded:: 2.5 + + The format used by elliptic curve point encodings. This is a binary + format. + Serialization Encryption Types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -626,3 +647,4 @@ Serialization Encryption Types .. _`PKCS3`: https://www.emc.com/emc-plus/rsa-labs/standards-initiatives/pkcs-3-diffie-hellman-key-agreement-standar.htm +.. _`SEC 1 v2.0`: http://www.secg.org/sec1-v2.pdf -- cgit v1.2.3