summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EC_POINT_new.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/man/EC_POINT_new.3497
1 files changed, 125 insertions, 372 deletions
diff --git a/src/lib/libcrypto/man/EC_POINT_new.3 b/src/lib/libcrypto/man/EC_POINT_new.3
index db6280fce7..0a797f8bc9 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.21 2025/06/13 18:34:00 schwarze 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: June 13 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,24 +22,12 @@
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
28.Lb libcrypto
75.In openssl/ec.h 29.In openssl/ec.h
76.In openssl/bn.h 30.Pp
77.Ft EC_POINT * 31.Ft EC_POINT *
78.Fo EC_POINT_new 32.Fo EC_POINT_new
79.Fa "const EC_GROUP *group" 33.Fa "const EC_GROUP *group"
@@ -93,126 +47,32 @@
93.Fc 47.Fc
94.Ft EC_POINT * 48.Ft EC_POINT *
95.Fo EC_POINT_dup 49.Fo EC_POINT_dup
96.Fa "const EC_POINT *src" 50.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" 51.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"
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 52.Fc
198.Sh DESCRIPTION 53.Sh DESCRIPTION
199An 54An
200.Vt EC_POINT 55.Vt EC_POINT
201represents a point on a curve. 56object holds a point on the elliptic curve represented by an
202A curve is represented by an 57.Vt EC_GROUP .
203.Vt EC_GROUP 58The details of the internal representation depend on the group
204object created by the functions described in 59and should never be an application's concern since the EC library
205.Xr EC_GROUP_new 3 . 60has API to set a point's coordinates,
61.Xr EC_POINT_set_affine_coordinates 3 .
206.Pp 62.Pp
207A new point is constructed by calling the function
208.Fn EC_POINT_new 63.Fn EC_POINT_new
209and providing the 64allocates and initializes an
210.Fa group 65.Vt EC_POINT
211object that the point relates to. 66object to be used with the
67.Fa group .
68Before explicitly setting its coordinates, the returned
69.Vt EC_POINT
70is invalid.
212.Pp 71.Pp
213.Fn EC_POINT_free 72.Fn EC_POINT_free
214frees the memory associated with the 73frees
215.Vt EC_POINT . 74.Fa point
75and all memory associated with it.
216If 76If
217.Fa point 77.Fa point
218is a 78is a
@@ -220,236 +80,129 @@ is a
220pointer, no action occurs. 80pointer, no action occurs.
221.Pp 81.Pp
222.Fn EC_POINT_clear_free 82.Fn EC_POINT_clear_free
223destroys any sensitive data held within the 83is intended to destroy sensitive data held in
224.Vt EC_POINT
225and then frees its memory.
226If
227.Fa point 84.Fa point
228is a 85in addition to freeing all memory associated with it.
229.Dv NULL 86Since elliptic curve points usually hold public data, this
230pointer, no action occurs. 87is rarely needed.
88In LibreSSL,
89.Fn EC_POINT_free
90and
91.Fn EC_POINT_clear_free
92behave identically.
231.Pp 93.Pp
232.Fn EC_POINT_copy 94.Fn EC_POINT_copy
233copies the point 95copies the internal representation of
234.Fa src 96.Fa src
235into 97into
236.Fa dst . 98.Fa dst .
237Both 99If
238.Fa src 100.Fa src
239and 101and
240.Fa dst 102.Fa dst
241must use the same 103are identical, no action occurs.
242.Vt EC_METHOD . 104Both
243.Pp
244.Fn EC_POINT_dup
245creates a new
246.Vt EC_POINT
247object and copies the content from
248.Fa src 105.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 106and
260.Fa y 107.Fa dst
261position. 108should be the result of
262The function 109.Fn EC_POINT_new
263.Fn EC_POINT_set_affine_coordinates 110with the same
264sets the 111.Fa group
265.Fa x 112argument, although
266and 113.Fn EC_POINT_copy
267.Fa y 114cannot check that.
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
344.Fn EC_POINT_hex2point
345convert from and to
346.Vt EC_POINT Ns s
347for the formats octet string,
348.Vt BIGNUM ,
349and hexadecimal, respectively.
350.Pp
351The function
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 115.Pp
363The function 116.Fn EC_POINT_dup
364.Fn EC_POINT_point2hex 117creates a deep copy of
365will allocate sufficient memory to store the hexadecimal string. 118.Fa point
366It is the caller's responsibility to free this memory with a subsequent 119by combining
367call to 120.Fn EC_POINT_new
368.Xr free 3 . 121with
122.Fn EC_GROUP_copy .
369.Sh RETURN VALUES 123.Sh RETURN VALUES
370.Fn EC_POINT_new 124.Fn EC_POINT_new
371and 125returns a newly allocated
372.Fn EC_POINT_dup
373return the newly allocated
374.Vt EC_POINT 126.Vt EC_POINT
375or 127or
376.Dv NULL 128.Dv NULL
377on error. 129on memory allocation failure.
378.Pp
379The following functions return 1 on success or 0 on error:
380.Fn EC_POINT_copy ,
381.Fn EC_POINT_set_to_infinity ,
382.Fn EC_POINT_set_affine_coordinates ,
383.Fn EC_POINT_set_affine_coordinates_GFp ,
384.Fn EC_POINT_get_affine_coordinates ,
385.Fn EC_POINT_get_affine_coordinates_GFp ,
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 130.Pp
401.Fn EC_POINT_bn2point 131.Fn EC_POINT_copy
402returns the pointer to the 132returns 1 on success or 0 on error.
403.Vt EC_POINT 133Error conditions include memory allocation failure and that
404supplied or 134.Fa dst
405.Dv NULL 135is incompatible with the group on which
406on error. 136.Fa src
407.Pp 137is defined.
408.Fn EC_POINT_point2hex
409returns a pointer to the hex string or
410.Dv NULL
411on error.
412.Pp 138.Pp
413.Fn EC_POINT_hex2point 139.Fn EC_POINT_dup
414returns the pointer to the 140returns a newly allocated
415.Vt EC_POINT 141.Vt EC_POINT
416supplied or 142or
417.Dv NULL 143.Dv NULL
418on error. 144on failure.
145Error conditions include memory allocation failure or that
146.Fa group
147is incompatible with
148.Fa src .
419.Sh SEE ALSO 149.Sh SEE ALSO
150.Xr BN_CTX_new 3 ,
151.Xr BN_is_zero 3 ,
152.Xr crypto 3 ,
420.Xr d2i_ECPKParameters 3 , 153.Xr d2i_ECPKParameters 3 ,
421.Xr EC_GROUP_copy 3 , 154.Xr EC_GROUP_check 3 ,
422.Xr EC_GROUP_new 3 , 155.Xr EC_GROUP_get_curve_name 3 ,
156.Xr EC_GROUP_new_by_curve_name 3 ,
157.Xr EC_GROUP_new_curve_GFp 3 ,
158.Xr EC_KEY_METHOD_new 3 ,
423.Xr EC_KEY_new 3 , 159.Xr EC_KEY_new 3 ,
424.Xr EC_POINT_add 3 , 160.Xr EC_POINT_add 3 ,
425.Xr ECDH_compute_key 3 161.Xr EC_POINT_get_affine_coordinates 3 ,
162.Xr EC_POINT_point2oct 3 ,
163.Xr ECDH_compute_key 3 ,
164.Xr ECDSA_SIG_new 3
426.Sh HISTORY 165.Sh HISTORY
427.Fn EC_POINT_new , 166.Fn EC_POINT_new ,
428.Fn EC_POINT_free , 167.Fn EC_POINT_free ,
429.Fn EC_POINT_clear_free , 168.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 169and
437.Fn EC_POINT_oct2point 170.Fn EC_POINT_copy
438first appeared in OpenSSL 0.9.7 and have been available since 171first appeared in OpenSSL 0.9.7 and have been available since
439.Ox 3.2 . 172.Ox 3.2 .
440.Pp 173.Pp
441.Fn EC_POINT_dup , 174.Fn EC_POINT_dup
442.Fn EC_POINT_point2bn , 175first 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 . 176.Ox 4.5 .
449.Pp 177.Sh BUGS
450.Fn EC_POINT_set_affine_coordinates , 178A fundamental flaw in the OpenSSL API toolkit is that
451.Fn EC_POINT_get_affine_coordinates , 179.Fn *_new
180functions usually create invalid objects that are tricky to
181turn into valid objects.
182One specific flaw in the EC library internals is that
183.Vt EC_POINT
184objects do not hold a reference to the group they live on
185despite the fact that
186.Fn EC_POINT_new
187has a
188.Fa group
189argument.
190This is difficult to fix because
191.Vt EC_GROUP
192objects are not reference counted and
193because of const qualifiers in the API.
194This is the root cause for various contortions in the EC library
195and API and
196there are security implications because not
197only does the library not know whether an
198.Fa EC_POINT
199object represents a valid point,
200even if it did know that it would still not know on what curve.
201.Pp
202The signature of
203.Fn EC_GROUP_dup
204is bizarre and the order of
205.Fa point
452and 206and
453.Fn EC_POINT_set_compressed_coordinates 207.Fa group
454first appeared in OpenSSL 1.1.1 and have been available since 208is inconsistent with the rest of the EC API.
455.Ox 7.0 .