aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat/primitives/asymmetric
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-25 15:44:29 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-10-26 08:27:22 -0500
commit467072f7d50778f064f192b4e318c19c6cf98293 (patch)
tree9ef70c8cf76f86795f05fc00d22b9db785b9e659 /docs/hazmat/primitives/asymmetric
parent9bbf778b7dde2fab6d957f3b5b4422d5bb3ce5a0 (diff)
downloadcryptography-467072f7d50778f064f192b4e318c19c6cf98293.tar.gz
cryptography-467072f7d50778f064f192b4e318c19c6cf98293.tar.bz2
cryptography-467072f7d50778f064f192b4e318c19c6cf98293.zip
add support for encoding/decoding elliptic curve points
Based on the work of @ronf in #2346.
Diffstat (limited to 'docs/hazmat/primitives/asymmetric')
-rw-r--r--docs/hazmat/primitives/asymmetric/utils.rst41
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/hazmat/primitives/asymmetric/utils.rst b/docs/hazmat/primitives/asymmetric/utils.rst
index 07883598..825fe3c1 100644
--- a/docs/hazmat/primitives/asymmetric/utils.rst
+++ b/docs/hazmat/primitives/asymmetric/utils.rst
@@ -28,3 +28,44 @@ Asymmetric Utilities
:param int s: The raw signature value ``s``.
:return bytes: The encoded signature.
+
+.. function:: encode_ec_point(curve, x, y)
+
+ .. versionadded:: 1.1
+
+ Encodes an elliptic curve point to a byte string as described in
+ _`SEC 1 v2.0` section 2.3.3. This function only supports uncompressed
+ points.
+
+ :param curve: A :class:`EllipticCurve` provider.
+
+ :param x: The x value of the point.
+
+ :type: int or None
+
+ :param int y: The y value of the point.
+
+ :return bytes: The encoded point.
+
+ :raises TypeError: Raised when curve is not an :class:`EllipticCurve`.
+
+.. function:: decode_ec_point(key_length, data)
+
+ .. versionadded:: 1.1
+
+ Decodes a byte string as described in _`SEC 1 v2.0` section 2.3.3 to the
+ ``x`` and ``y`` integer values. This function only supports uncompressed
+ points.
+
+ :param curve: A :class:`EllipticCurve` provider.
+
+ :param bytes data: The serialized point byte string.
+
+ :returns: The decoded tuple ``(x, y)``.
+
+ :raises ValueError: Raised on invalid point type or data length.
+
+ :raises TypeError: Raised when curve is not an :class:`EllipticCurve`.
+
+
+.. _`SEC 1 v2.0`: http://www.secg.org/sec1-v2.pdf