summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EC_POINT_new.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/EC_POINT_new.3')
-rw-r--r--src/lib/libcrypto/man/EC_POINT_new.3506
1 files changed, 129 insertions, 377 deletions
diff --git a/src/lib/libcrypto/man/EC_POINT_new.3 b/src/lib/libcrypto/man/EC_POINT_new.3
index db6280fce7..cfc988f294 100644
--- a/src/lib/libcrypto/man/EC_POINT_new.3
+++ b/src/lib/libcrypto/man/EC_POINT_new.3
@@ -1,54 +1,20 @@
1.\" $OpenBSD: EC_POINT_new.3,v 1.17 2025/03/08 17:04:07 tb Exp $ 1.\" $OpenBSD: EC_POINT_new.3,v 1.18 2025/04/25 19:57:12 tb Exp $
2.\" full merge up to: OpenSSL 50db8163 Jul 30 16:56:41 2018 +0100
3.\" 2.\"
4.\" This file was written by Matt Caswell <matt@openssl.org>. 3.\" Copyright (c) 2025 Theo Buehler <tb@openbsd.org>
5.\" Copyright (c) 2013, 2016 The OpenSSL Project. All rights reserved.
6.\" 4.\"
7.\" Redistribution and use in source and binary forms, with or without 5.\" Permission to use, copy, modify, and distribute this software for any
8.\" modification, are permitted provided that the following conditions 6.\" purpose with or without fee is hereby granted, provided that the above
9.\" are met: 7.\" copyright notice and this permission notice appear in all copies.
10.\" 8.\"
11.\" 1. Redistributions of source code must retain the above copyright 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" notice, this list of conditions and the following disclaimer. 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13.\" 16.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright 17.Dd $Mdocdate: April 25 2025 $
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: March 8 2025 $
52.Dt EC_POINT_NEW 3 18.Dt EC_POINT_NEW 3
53.Os 19.Os
54.Sh NAME 20.Sh NAME
@@ -56,163 +22,56 @@
56.Nm EC_POINT_free , 22.Nm EC_POINT_free ,
57.Nm EC_POINT_clear_free , 23.Nm EC_POINT_clear_free ,
58.Nm EC_POINT_copy , 24.Nm EC_POINT_copy ,
59.Nm EC_POINT_dup , 25.Nm EC_POINT_dup
60.Nm EC_POINT_set_to_infinity , 26.Nd allocate, free and copy elliptic curve points
61.Nm EC_POINT_set_affine_coordinates ,
62.Nm EC_POINT_set_affine_coordinates_GFp ,
63.Nm EC_POINT_get_affine_coordinates ,
64.Nm EC_POINT_get_affine_coordinates_GFp ,
65.Nm EC_POINT_set_compressed_coordinates ,
66.Nm EC_POINT_set_compressed_coordinates_GFp ,
67.Nm EC_POINT_point2oct ,
68.Nm EC_POINT_oct2point ,
69.Nm EC_POINT_point2bn ,
70.Nm EC_POINT_bn2point ,
71.Nm EC_POINT_point2hex ,
72.Nm EC_POINT_hex2point
73.Nd create, destroy, and manipulate EC_POINT objects
74.Sh SYNOPSIS 27.Sh SYNOPSIS
75.In openssl/ec.h 28.In openssl/ec.h
76.In openssl/bn.h 29.Pp
77.Ft EC_POINT * 30.Ft "EC_POINT *"
78.Fo EC_POINT_new 31.Fo EC_POINT_new
79.Fa "const EC_GROUP *group" 32.Fa "const EC_GROUP *group"
80.Fc 33.Fc
81.Ft void 34.Ft "void"
82.Fo EC_POINT_free 35.Fo EC_POINT_free
83.Fa "EC_POINT *point" 36.Fa "EC_POINT *point"
84.Fc 37.Fc
85.Ft void 38.Ft "void"
86.Fo EC_POINT_clear_free 39.Fo EC_POINT_clear_free
87.Fa "EC_POINT *point" 40.Fa "EC_POINT *point"
88.Fc 41.Fc
89.Ft int 42.Ft "int"
90.Fo EC_POINT_copy 43.Fo EC_POINT_copy
91.Fa "EC_POINT *dst" 44.Fa "EC_POINT *dst"
92.Fa "const EC_POINT *src" 45.Fa "const EC_POINT *src"
93.Fc 46.Fc
94.Ft EC_POINT * 47.Ft "EC_POINT *"
95.Fo EC_POINT_dup 48.Fo EC_POINT_dup
96.Fa "const EC_POINT *src" 49.Fa "const EC_POINT *point"
97.Fa "const EC_GROUP *group"
98.Fc
99.Ft int
100.Fo EC_POINT_set_to_infinity
101.Fa "const EC_GROUP *group"
102.Fa "EC_POINT *point"
103.Fc
104.Ft int
105.Fo EC_POINT_set_affine_coordinates
106.Fa "const EC_GROUP *group"
107.Fa "EC_POINT *p"
108.Fa "const BIGNUM *x"
109.Fa "const BIGNUM *y"
110.Fa "BN_CTX *ctx"
111.Fc
112.Ft int
113.Fo EC_POINT_set_affine_coordinates_GFp
114.Fa "const EC_GROUP *group"
115.Fa "EC_POINT *p"
116.Fa "const BIGNUM *x"
117.Fa "const BIGNUM *y"
118.Fa "BN_CTX *ctx"
119.Fc
120.Ft int
121.Fo EC_POINT_get_affine_coordinates
122.Fa "const EC_GROUP *group"
123.Fa "const EC_POINT *p"
124.Fa "BIGNUM *x"
125.Fa "BIGNUM *y"
126.Fa "BN_CTX *ctx"
127.Fc
128.Ft int
129.Fo EC_POINT_get_affine_coordinates_GFp
130.Fa "const EC_GROUP *group"
131.Fa "const EC_POINT *p"
132.Fa "BIGNUM *x"
133.Fa "BIGNUM *y"
134.Fa "BN_CTX *ctx"
135.Fc
136.Ft int
137.Fo EC_POINT_set_compressed_coordinates
138.Fa "const EC_GROUP *group"
139.Fa "EC_POINT *p"
140.Fa "const BIGNUM *x"
141.Fa "int y_bit"
142.Fa "BN_CTX *ctx"
143.Fc
144.Ft int
145.Fo EC_POINT_set_compressed_coordinates_GFp
146.Fa "const EC_GROUP *group"
147.Fa "EC_POINT *p"
148.Fa "const BIGNUM *x"
149.Fa "int y_bit"
150.Fa "BN_CTX *ctx"
151.Fc
152.Ft size_t
153.Fo EC_POINT_point2oct
154.Fa "const EC_GROUP *group" 50.Fa "const EC_GROUP *group"
155.Fa "const EC_POINT *p"
156.Fa "point_conversion_form_t form"
157.Fa "unsigned char *buf"
158.Fa "size_t len"
159.Fa "BN_CTX *ctx"
160.Fc
161.Ft int
162.Fo EC_POINT_oct2point
163.Fa "const EC_GROUP *group"
164.Fa "EC_POINT *p"
165.Fa "const unsigned char *buf"
166.Fa "size_t len"
167.Fa "BN_CTX *ctx"
168.Fc
169.Ft BIGNUM *
170.Fo EC_POINT_point2bn
171.Fa "const EC_GROUP *"
172.Fa "const EC_POINT *"
173.Fa "point_conversion_form_t form"
174.Fa "BIGNUM *"
175.Fa "BN_CTX *"
176.Fc
177.Ft EC_POINT *
178.Fo EC_POINT_bn2point
179.Fa "const EC_GROUP *"
180.Fa "const BIGNUM *"
181.Fa "EC_POINT *"
182.Fa "BN_CTX *"
183.Fc
184.Ft char *
185.Fo EC_POINT_point2hex
186.Fa "const EC_GROUP *"
187.Fa "const EC_POINT *"
188.Fa "point_conversion_form_t form"
189.Fa "BN_CTX *"
190.Fc
191.Ft EC_POINT *
192.Fo EC_POINT_hex2point
193.Fa "const EC_GROUP *"
194.Fa "const char *"
195.Fa "EC_POINT *"
196.Fa "BN_CTX *"
197.Fc 51.Fc
198.Sh DESCRIPTION 52.Sh DESCRIPTION
199An 53An
200.Vt EC_POINT 54.Vt EC_POINT
201represents a point on a curve. 55object holds a point on the elliptic curve represented by an
202A curve is represented by an 56.Vt EC_GROUP .
203.Vt EC_GROUP 57The details of the internal representation depend on the group
204object created by the functions described in 58and should never be an application's concern since the EC library
205.Xr EC_GROUP_new 3 . 59has API to set a point's coordinates,
60.Xr EC_POINT_set_affine_coordinates 3 .
206.Pp 61.Pp
207A new point is constructed by calling the function
208.Fn EC_POINT_new 62.Fn EC_POINT_new
209and providing the 63allocates and initializes an
210.Fa group 64.Vt EC_POINT
211object that the point relates to. 65object to be used with the
66.Fa group .
67Before explicitly setting its coordinates, the returned
68.Vt EC_POINT
69is invalid.
212.Pp 70.Pp
213.Fn EC_POINT_free 71.Fn EC_POINT_free
214frees the memory associated with the 72frees
215.Vt EC_POINT . 73.Fa point
74and all memory associated with it.
216If 75If
217.Fa point 76.Fa point
218is a 77is a
@@ -220,236 +79,129 @@ is a
220pointer, no action occurs. 79pointer, no action occurs.
221.Pp 80.Pp
222.Fn EC_POINT_clear_free 81.Fn EC_POINT_clear_free
223destroys any sensitive data held within the 82is intended to destroy sensitive data held in
224.Vt EC_POINT
225and then frees its memory.
226If
227.Fa point 83.Fa point
228is a 84in addition to freeing all memory associated with it.
229.Dv NULL 85Since elliptic curve points usually hold public data, this
230pointer, no action occurs. 86is rarely needed.
87In LibreSSL,
88.Fn EC_POINT_free
89and
90.Fn EC_POINT_clear_free
91behave identically.
231.Pp 92.Pp
232.Fn EC_POINT_copy 93.Fn EC_POINT_copy
233copies the point 94copies the internal representation of
234.Fa src 95.Fa src
235into 96into
236.Fa dst . 97.Fa dst .
237Both 98If
238.Fa src 99.Fa src
239and 100and
240.Fa dst 101.Fa dst
241must use the same 102are identical, no action occurs.
242.Vt EC_METHOD . 103Both
243.Pp
244.Fn EC_POINT_dup
245creates a new
246.Vt EC_POINT
247object and copies the content from
248.Fa src 104.Fa src
249to the newly created
250.Vt EC_POINT
251object.
252.Pp
253A valid point on a curve is the special point at infinity.
254A point is set to be at infinity by calling
255.Fn EC_POINT_set_to_infinity .
256.Pp
257The affine coordinates for a point describe a point in terms of its
258.Fa x
259and
260.Fa y
261position.
262The function
263.Fn EC_POINT_set_affine_coordinates
264sets the
265.Fa x
266and
267.Fa y
268coordinates for the point
269.Fa p
270defined over the curve given in
271.Fa group .
272The function
273.Fn EC_POINT_get_affine_coordinates
274sets
275.Fa x
276and
277.Fa y ,
278either of which may be
279.Dv NULL ,
280to the corresponding coordinates of
281.Fa p .
282.Pp
283The functions
284.Fn EC_POINT_set_affine_coordinates_GFp
285is a deprecated synonym for
286.Fn EC_POINT_set_affine_coordinates
287and the function
288.Fn EC_POINT_get_affine_coordinates_GFp
289is a deprecated synonym for
290.Fn EC_POINT_get_affine_coordinates .
291.Pp
292Points can also be described in terms of their compressed coordinates.
293For a point
294.Pq Fa x , y ,
295for any given value for
296.Fa x
297such that the point is on the curve, there will only ever be two
298possible values for
299.Fa y .
300Therefore, a point can be set using the
301.Fn EC_POINT_set_compressed_coordinates
302function where
303.Fa x
304is the x coordinate and
305.Fa y_bit
306is a value 0 or 1 to identify which of the two possible values for y
307should be used.
308.Pp
309The functions
310.Fn EC_POINT_set_compressed_coordinates_GFp
311is a deprecated synonym for
312.Fn EC_POINT_set_compressed_coordinates .
313.Pp
314In addition
315.Vt EC_POINT Ns s
316can be converted to and from various external representations.
317Supported representations are octet strings,
318.Vt BIGNUM Ns s ,
319and hexadecimal.
320The format of the external representation is described by the
321point_conversion_form.
322See
323.Xr EC_GROUP_copy 3
324for a description of point_conversion_form.
325Octet strings are stored in a buffer along with an associated buffer
326length.
327A point held in a
328.Vt BIGNUM
329is calculated by converting the point to an octet string and then
330converting that octet string into a
331.Vt BIGNUM
332integer.
333Points in hexadecimal format are stored in a NUL terminated character
334string where each character is one of the printable values 0-9 or A-F
335(or a-f).
336.Pp
337The functions
338.Fn EC_POINT_point2oct ,
339.Fn EC_POINT_oct2point ,
340.Fn EC_POINT_point2bn ,
341.Fn EC_POINT_bn2point ,
342.Fn EC_POINT_point2hex ,
343and 105and
344.Fn EC_POINT_hex2point 106.Fa dst
345convert from and to 107should be the result of
346.Vt EC_POINT Ns s 108.Fn EC_POINT_new
347for the formats octet string, 109with the same
348.Vt BIGNUM , 110.Fa group
349and hexadecimal, respectively. 111argument, although
350.Pp 112.Fn EC_POINT_copy
351The function 113cannot check that.
352.Fn EC_POINT_point2oct
353must be supplied with a
354.Fa buf
355long enough to store the octet string.
356The return value provides the number of octets stored.
357Calling the function with a
358.Dv NULL
359.Fa buf
360will not perform the conversion but will still return the required
361buffer length.
362.Pp 114.Pp
363The function 115.Fn EC_POINT_dup
364.Fn EC_POINT_point2hex 116creates a deep copy of
365will allocate sufficient memory to store the hexadecimal string. 117.Fa point
366It is the caller's responsibility to free this memory with a subsequent 118by combining
367call to 119.Fn EC_POINT_new
368.Xr free 3 . 120with
121.Fn EC_GROUP_copy .
369.Sh RETURN VALUES 122.Sh RETURN VALUES
370.Fn EC_POINT_new 123.Fn EC_POINT_new
371and 124returns a newly allocated
372.Fn EC_POINT_dup
373return the newly allocated
374.Vt EC_POINT 125.Vt EC_POINT
375or 126or
376.Dv NULL 127.Dv NULL
377on error. 128on memory allocation failure.
378.Pp 129.Pp
379The following functions return 1 on success or 0 on error: 130.Fn EC_POINT_copy
380.Fn EC_POINT_copy , 131returns 1 on success or 0 on error.
381.Fn EC_POINT_set_to_infinity , 132Error conditions include memory allocation failure and that
382.Fn EC_POINT_set_affine_coordinates , 133.Fa dst
383.Fn EC_POINT_set_affine_coordinates_GFp , 134is incompatible with the group on which
384.Fn EC_POINT_get_affine_coordinates , 135.Fa src
385.Fn EC_POINT_get_affine_coordinates_GFp , 136is defined.
386.Fn EC_POINT_set_compressed_coordinates ,
387.Fn EC_POINT_set_compressed_coordinates_GFp ,
388and
389.Fn EC_POINT_oct2point .
390.Pp
391.Fn EC_POINT_point2oct
392returns the length of the required buffer, or 0 on error.
393.Pp
394.Fn EC_POINT_point2bn
395returns the pointer to the
396.Vt BIGNUM
397supplied or
398.Dv NULL
399on error.
400.Pp
401.Fn EC_POINT_bn2point
402returns the pointer to the
403.Vt EC_POINT
404supplied or
405.Dv NULL
406on error.
407.Pp
408.Fn EC_POINT_point2hex
409returns a pointer to the hex string or
410.Dv NULL
411on error.
412.Pp 137.Pp
413.Fn EC_POINT_hex2point 138.Fn EC_POINT_dup
414returns the pointer to the 139returns a newly allocated
415.Vt EC_POINT 140.Vt EC_POINT
416supplied or 141or
417.Dv NULL 142.Dv NULL
418on error. 143on failure.
144Error conditions include memory allocation failure or that
145.Fa group
146is incompatible with
147.Fa src .
419.Sh SEE ALSO 148.Sh SEE ALSO
149.Xr BN_CTX_new 3 ,
150.Xr BN_is_zero 3 ,
151.Xr crypto 3 ,
420.Xr d2i_ECPKParameters 3 , 152.Xr d2i_ECPKParameters 3 ,
421.Xr EC_GROUP_copy 3 , 153.Xr EC_GROUP_check 3 ,
422.Xr EC_GROUP_new 3 , 154.Xr EC_GROUP_get_curve_name 3 ,
155.Xr EC_GROUP_new_by_curve_name 3 ,
156.Xr EC_GROUP_new_curve_GFp 3 ,
157.Xr EC_KEY_METHOD_new 3 ,
423.Xr EC_KEY_new 3 , 158.Xr EC_KEY_new 3 ,
424.Xr EC_POINT_add 3 , 159.Xr EC_POINT_add 3 ,
425.Xr ECDH_compute_key 3 160.Xr EC_POINT_get_affine_coordinates 3 ,
161.Xr EC_POINT_point2oct 3 ,
162.Xr ECDH_compute_key 3 ,
163.Xr ECDSA_SIG_new 3
426.Sh HISTORY 164.Sh HISTORY
427.Fn EC_POINT_new , 165.Fn EC_POINT_new ,
428.Fn EC_POINT_free , 166.Fn EC_POINT_free ,
429.Fn EC_POINT_clear_free , 167.Fn EC_POINT_clear_free ,
430.Fn EC_POINT_copy ,
431.Fn EC_POINT_set_to_infinity ,
432.Fn EC_POINT_set_affine_coordinates_GFp ,
433.Fn EC_POINT_get_affine_coordinates_GFp ,
434.Fn EC_POINT_set_compressed_coordinates_GFp ,
435.Fn EC_POINT_point2oct ,
436and 168and
437.Fn EC_POINT_oct2point 169.Fn EC_POINT_copy
438first appeared in OpenSSL 0.9.7 and have been available since 170first appeared in OpenSSL 0.9.7 and have been available since
439.Ox 3.2 . 171.Ox 3.2 .
440.Pp 172.Pp
441.Fn EC_POINT_dup , 173.Fn EC_POINT_dup
442.Fn EC_POINT_point2bn , 174first appeared in OpenSSL 0.9.8 and has been available since
443.Fn EC_POINT_bn2point ,
444.Fn EC_POINT_point2hex ,
445and
446.Fn EC_POINT_hex2point
447first appeared in OpenSSL 0.9.8 and have been available since
448.Ox 4.5 . 175.Ox 4.5 .
449.Pp 176.Sh BUGS
450.Fn EC_POINT_set_affine_coordinates , 177A fundamental flaw in the OpenSSL API toolkit is that
451.Fn EC_POINT_get_affine_coordinates , 178.Fn *_new
179functions usually create invalid objects that are tricky to
180turn into valid objects.
181A fundamental flaw in the EC library is that
182.Vt EC_POINT
183objects do not hold a reference to the group they live on
184despite the fact that
185.Fn EC_POINT_new
186has a
187.Fa group
188argument.
189This is difficult to fix because
190.Vt EC_GROUP
191objects are not reference counted and
192because of const qualifiers in the API.
193This is the root cause for various contortions in the EC library
194and API.
195This has security implications because not
196only does the library not know whether an
197.Fa EC_POINT
198object represents a valid point,
199even if it did know that it would not know on what curve.
200.Pp
201The signature of
202.Fn EC_GROUP_dup
203is bizarre and the order of
204.Fa point
452and 205and
453.Fn EC_POINT_set_compressed_coordinates 206.Fa group
454first appeared in OpenSSL 1.1.1 and have been available since 207is inconsistent with the rest of the EC API.
455.Ox 7.0 .