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