]> git.ipfire.org Git - thirdparty/openssl.git/blob - doc/man3/EC_POINT_new.pod
Move EC_METHOD to internal-only
[thirdparty/openssl.git] / doc / man3 / EC_POINT_new.pod
1 =pod
2
3 =head1 NAME
4
5 EC_POINT_set_Jprojective_coordinates_GFp,
6 EC_POINT_point2buf,
7 EC_POINT_new,
8 EC_POINT_free,
9 EC_POINT_clear_free,
10 EC_POINT_copy,
11 EC_POINT_dup,
12 EC_POINT_method_of,
13 EC_POINT_set_to_infinity,
14 EC_POINT_get_Jprojective_coordinates_GFp,
15 EC_POINT_set_affine_coordinates,
16 EC_POINT_get_affine_coordinates,
17 EC_POINT_set_compressed_coordinates,
18 EC_POINT_set_affine_coordinates_GFp,
19 EC_POINT_get_affine_coordinates_GFp,
20 EC_POINT_set_compressed_coordinates_GFp,
21 EC_POINT_set_affine_coordinates_GF2m,
22 EC_POINT_get_affine_coordinates_GF2m,
23 EC_POINT_set_compressed_coordinates_GF2m,
24 EC_POINT_point2oct,
25 EC_POINT_oct2point,
26 EC_POINT_point2bn,
27 EC_POINT_bn2point,
28 EC_POINT_point2hex,
29 EC_POINT_hex2point
30 - Functions for creating, destroying and manipulating EC_POINT objects
31
32 =head1 SYNOPSIS
33
34 #include <openssl/ec.h>
35
36 EC_POINT *EC_POINT_new(const EC_GROUP *group);
37 void EC_POINT_free(EC_POINT *point);
38 void EC_POINT_clear_free(EC_POINT *point);
39 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
40 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
41 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
42 int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,
43 const BIGNUM *x, const BIGNUM *y,
44 BN_CTX *ctx);
45 int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,
46 BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
47 int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,
48 const BIGNUM *x, int y_bit,
49 BN_CTX *ctx);
50 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
51 point_conversion_form_t form,
52 unsigned char *buf, size_t len, BN_CTX *ctx);
53 size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
54 point_conversion_form_t form,
55 unsigned char **pbuf, BN_CTX *ctx);
56 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
57 const unsigned char *buf, size_t len, BN_CTX *ctx);
58 BIGNUM *EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *p,
59 point_conversion_form_t form, BIGNUM *bn,
60 BN_CTX *ctx);
61 EC_POINT *EC_POINT_bn2point(const EC_GROUP *group, const BIGNUM *bn,
62 EC_POINT *p, BN_CTX *ctx);
63 char *EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *p,
64 point_conversion_form_t form, BN_CTX *ctx);
65 EC_POINT *EC_POINT_hex2point(const EC_GROUP *group, const char *hex,
66 EC_POINT *p, BN_CTX *ctx);
67
68 Deprecated since OpenSSL 3.0:
69
70 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
71 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,
72 EC_POINT *p,
73 const BIGNUM *x, const BIGNUM *y,
74 const BIGNUM *z, BN_CTX *ctx);
75 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
76 const EC_POINT *p,
77 BIGNUM *x, BIGNUM *y, BIGNUM *z,
78 BN_CTX *ctx);
79 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
80 const BIGNUM *x, const BIGNUM *y,
81 BN_CTX *ctx);
82 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
83 const EC_POINT *p,
84 BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
85 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
86 EC_POINT *p,
87 const BIGNUM *x, int y_bit,
88 BN_CTX *ctx);
89 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
90 const BIGNUM *x, const BIGNUM *y,
91 BN_CTX *ctx);
92 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
93 const EC_POINT *p,
94 BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
95 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
96 EC_POINT *p,
97 const BIGNUM *x, int y_bit,
98 BN_CTX *ctx);
99
100 =head1 DESCRIPTION
101
102 An B<EC_POINT> structure represents a point on a curve. A new point is
103 constructed by calling the function EC_POINT_new() and providing the
104 B<group> object that the point relates to.
105
106 EC_POINT_free() frees the memory associated with the B<EC_POINT>.
107 if B<point> is NULL nothing is done.
108
109 EC_POINT_clear_free() destroys any sensitive data held within the EC_POINT and
110 then frees its memory. If B<point> is NULL nothing is done.
111
112 EC_POINT_copy() copies the point B<src> into B<dst>. Both B<src> and B<dst>
113 must use the same B<EC_METHOD>.
114
115 EC_POINT_dup() creates a new B<EC_POINT> object and copies the content from
116 B<src> to the newly created B<EC_POINT> object.
117
118 EC_POINT_method_of() obtains the B<EC_METHOD> associated with B<point>.
119 This function was deprecated in OpenSSL 3.0, since EC_METHOD is no longer a
120 public concept.
121
122 A valid point on a curve is the special point at infinity. A point is set to
123 be at infinity by calling EC_POINT_set_to_infinity().
124
125 The affine co-ordinates for a point describe a point in terms of its x and y
126 position. The function EC_POINT_set_affine_coordinates() sets the B<x> and B<y>
127 co-ordinates for the point B<p> defined over the curve given in B<group>. The
128 function EC_POINT_get_affine_coordinates() sets B<x> and B<y>, either of which
129 may be NULL, to the corresponding coordinates of B<p>.
130
131 The functions EC_POINT_set_affine_coordinates_GFp() and
132 EC_POINT_set_affine_coordinates_GF2m() are synonyms for
133 EC_POINT_set_affine_coordinates(). They are defined for backwards compatibility
134 only and should not be used.
135
136 The functions EC_POINT_get_affine_coordinates_GFp() and
137 EC_POINT_get_affine_coordinates_GF2m() are synonyms for
138 EC_POINT_get_affine_coordinates(). They are defined for backwards compatibility
139 only and should not be used.
140
141 As well as the affine co-ordinates, a point can alternatively be described in
142 terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian
143 projective co-ordinates are expressed as three values x, y and z. Working in
144 this co-ordinate system provides more efficient point multiplication
145 operations. A mapping exists between Jacobian projective co-ordinates and
146 affine co-ordinates. A Jacobian projective co-ordinate (x, y, z) can be written
147 as an affine co-ordinate as (x/(z^2), y/(z^3)). Conversion to Jacobian
148 projective from affine co-ordinates is simple. The co-ordinate (x, y) is mapped
149 to (x, y, 1). Although deprecated in OpenSSL 3.0 and should no longer be used,
150 to set or get the projective co-ordinates in older versions use
151 EC_POINT_set_Jprojective_coordinates_GFp() and
152 EC_POINT_get_Jprojective_coordinates_GFp() respectively.
153 Modern versions should instead use EC_POINT_set_affine_coordinates() and
154 EC_POINT_get_affine_coordinates(), performing the conversion manually using the
155 above maps in such rare circumstances.
156
157 Points can also be described in terms of their compressed co-ordinates. For a
158 point (x, y), for any given value for x such that the point is on the curve
159 there will only ever be two possible values for y. Therefore a point can be set
160 using the EC_POINT_set_compressed_coordinates() function where B<x> is the x
161 co-ordinate and B<y_bit> is a value 0 or 1 to identify which of the two
162 possible values for y should be used.
163
164 The functions EC_POINT_set_compressed_coordinates_GFp() and
165 EC_POINT_set_compressed_coordinates_GF2m() are synonyms for
166 EC_POINT_set_compressed_coordinates(). They are defined for backwards
167 compatibility only and should not be used.
168
169 In addition B<EC_POINT> can be converted to and from various external
170 representations. The octet form is the binary encoding of the B<ECPoint>
171 structure (as defined in RFC5480 and used in certificates and TLS records):
172 only the content octets are present, the B<OCTET STRING> tag and length are
173 not included. B<BIGNUM> form is the octet form interpreted as a big endian
174 integer converted to a B<BIGNUM> structure. Hexadecimal form is the octet
175 form converted to a NULL terminated character string where each character
176 is one of the printable values 0-9 or A-F (or a-f).
177
178 The functions EC_POINT_point2oct(), EC_POINT_oct2point(), EC_POINT_point2bn(),
179 EC_POINT_bn2point(), EC_POINT_point2hex() and EC_POINT_hex2point() convert from
180 and to EC_POINTs for the formats: octet, BIGNUM and hexadecimal respectively.
181
182 The function EC_POINT_point2oct() encodes the given curve point B<p> as an
183 octet string into the buffer B<buf> of size B<len>, using the specified
184 conversion form B<form>.
185 The encoding conforms with Sec. 2.3.3 of the SECG SEC 1 ("Elliptic Curve
186 Cryptography") standard.
187 Similarly the function EC_POINT_oct2point() decodes a curve point into B<p> from
188 the octet string contained in the given buffer B<buf> of size B<len>, conforming
189 to Sec. 2.3.4 of the SECG SEC 1 ("Elliptic Curve Cryptography") standard.
190
191 The functions EC_POINT_point2hex() and EC_POINT_point2bn() convert a point B<p>,
192 respectively, to the hexadecimal or BIGNUM representation of the same
193 encoding of the function EC_POINT_point2oct().
194 Vice versa, similarly to the function EC_POINT_oct2point(), the functions
195 EC_POINT_hex2point() and EC_POINT_point2bn() decode the hexadecimal or
196 BIGNUM representation into the EC_POINT B<p>.
197
198 Notice that, according to the standard, the octet string encoding of the point
199 at infinity for a given curve is fixed to a single octet of value zero and that,
200 vice versa, a single octet of size zero is decoded as the point at infinity.
201
202 The function EC_POINT_point2oct() must be supplied with a buffer long enough to
203 store the octet form. The return value provides the number of octets stored.
204 Calling the function with a NULL buffer will not perform the conversion but
205 will still return the required buffer length.
206
207 The function EC_POINT_point2buf() allocates a buffer of suitable length and
208 writes an EC_POINT to it in octet format. The allocated buffer is written to
209 B<*pbuf> and its length is returned. The caller must free up the allocated
210 buffer with a call to OPENSSL_free(). Since the allocated buffer value is
211 written to B<*pbuf> the B<pbuf> parameter B<MUST NOT> be B<NULL>.
212
213 The function EC_POINT_point2hex() will allocate sufficient memory to store the
214 hexadecimal string. It is the caller's responsibility to free this memory with
215 a subsequent call to OPENSSL_free().
216
217 =head1 RETURN VALUES
218
219 EC_POINT_new() and EC_POINT_dup() return the newly allocated EC_POINT or NULL
220 on error.
221
222 The following functions return 1 on success or 0 on error: EC_POINT_copy(),
223 EC_POINT_set_to_infinity(), EC_POINT_set_Jprojective_coordinates_GFp(),
224 EC_POINT_get_Jprojective_coordinates_GFp(),
225 EC_POINT_set_affine_coordinates_GFp(), EC_POINT_get_affine_coordinates_GFp(),
226 EC_POINT_set_compressed_coordinates_GFp(),
227 EC_POINT_set_affine_coordinates_GF2m(), EC_POINT_get_affine_coordinates_GF2m(),
228 EC_POINT_set_compressed_coordinates_GF2m() and EC_POINT_oct2point().
229
230 EC_POINT_method_of returns the EC_METHOD associated with the supplied EC_POINT.
231
232 EC_POINT_point2oct() and EC_POINT_point2buf() return the length of the required
233 buffer or 0 on error.
234
235 EC_POINT_point2bn() returns the pointer to the BIGNUM supplied, or NULL on
236 error.
237
238 EC_POINT_bn2point() returns the pointer to the EC_POINT supplied, or NULL on
239 error.
240
241 EC_POINT_point2hex() returns a pointer to the hex string, or NULL on error.
242
243 EC_POINT_hex2point() returns the pointer to the EC_POINT supplied, or NULL on
244 error.
245
246 =head1 SEE ALSO
247
248 L<crypto(7)>, L<EC_GROUP_new(3)>, L<EC_GROUP_copy(3)>,
249 L<EC_POINT_add(3)>, L<EC_KEY_new(3)>,
250 L<EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)>
251
252 =head1 HISTORY
253
254 EC_POINT_method_of(),
255 EC_POINT_set_Jprojective_coordinates_GFp(),
256 EC_POINT_get_Jprojective_coordinates_GFp(),
257 EC_POINT_set_affine_coordinates_GFp(), EC_POINT_get_affine_coordinates_GFp(),
258 EC_POINT_set_compressed_coordinates_GFp(),
259 EC_POINT_set_affine_coordinates_GF2m(), EC_POINT_get_affine_coordinates_GF2m(),
260 EC_POINT_set_compressed_coordinates_GF2m() were deprecated in OpenSSL 3.0.
261
262 B<EC_POINT_set_affine_coordinates>, B<EC_POINT_get_affine_coordinates>,
263 and B<EC_POINT_set_compressed_coordinates> were
264 added in OpenSSL 1.1.1.
265
266 =head1 COPYRIGHT
267
268 Copyright 2013-2020 The OpenSSL Project Authors. All Rights Reserved.
269
270 Licensed under the Apache License 2.0 (the "License"). You may not use
271 this file except in compliance with the License. You can obtain a copy
272 in the file LICENSE in the source distribution or at
273 L<https://www.openssl.org/source/license.html>.
274
275 =cut