blob: 79d14daeff12ada73d5fab443951698ef6d8b1a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
.. hazmat::
Asymmetric Utilities
====================
.. currentmodule:: cryptography.hazmat.primitives.asymmetric.utils
.. function:: decode_dss_signature(signature)
Takes in signatures generated by the DSA/ECDSA signers and returns a
tuple ``(r, s)``. These signatures are ASN.1 encoded ``Dss-Sig-Value``
sequences (as defined in :rfc:`3279`)
:param bytes signature: The signature to decode.
:returns: The decoded tuple ``(r, s)``.
:raises ValueError: Raised if the signature is malformed.
.. function:: encode_dss_signature(r, s)
Creates an ASN.1 encoded ``Dss-Sig-Value`` (as defined in :rfc:`3279`) from
raw ``r`` and ``s`` values.
:param int r: The raw signature value ``r``.
: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: An
:class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve`
instance.
:param int x: The x value of the point.
:param int y: The y value of the point.
:return bytes: The encoded point.
:raises TypeError: Raised when curve is not an
:class:`~cryptography.hazmat.primitives.asymmetric.ec.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: An
:class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve`
instance.
: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:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve`.
.. _`SEC 1 v2.0`: http://www.secg.org/sec1-v2.pdf
|