5 EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy, EC_POINT_dup,
6 EC_POINT_method_of, EC_POINT_set_to_infinity,
7 EC_POINT_set_Jprojective_coordinates, EC_POINT_get_Jprojective_coordinates_GFp,
8 EC_POINT_set_affine_coordinates_GFp, EC_POINT_get_affine_coordinates_GFp,
9 EC_POINT_set_compressed_coordinates_GFp, EC_POINT_set_affine_coordinates_GF2m,
10 EC_POINT_get_affine_coordinates_GF2m, EC_POINT_set_compressed_coordinates_GF2m,
11 EC_POINT_point2oct, EC_POINT_oct2point, EC_POINT_point2bn, EC_POINT_bn2point,
12 EC_POINT_point2hex, EC_POINT_hex2point - Functions for creating, destroying and
13 manipulating B<EC_POINT> objects.
17 #include <openssl/ec.h>
18 #include <openssl/bn.h>
20 EC_POINT *EC_POINT_new(const EC_GROUP *group);
21 void EC_POINT_free(EC_POINT *point);
22 void EC_POINT_clear_free(EC_POINT *point);
23 int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);
24 EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);
25 const EC_METHOD *EC_POINT_method_of(const EC_POINT *point);
26 int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
27 int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,
29 const BIGNUM *x, const BIGNUM *y,
30 const BIGNUM *z, BN_CTX *ctx);
31 int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
33 BIGNUM *x, BIGNUM *y, BIGNUM *z,
35 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
36 const BIGNUM *x, const BIGNUM *y,
38 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
40 BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
41 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
43 const BIGNUM *x, int y_bit,
45 int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p,
46 const BIGNUM *x, const BIGNUM *y,
48 int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
50 BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
51 int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
53 const BIGNUM *x, int y_bit,
55 size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,
56 point_conversion_form_t form,
57 unsigned char *buf, size_t len, BN_CTX *ctx);
58 size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
59 point_conversion_form_t form,
60 unsigned char **pbuf, BN_CTX *ctx);
61 int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,
62 const unsigned char *buf, size_t len, BN_CTX *ctx);
63 BIGNUM *EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *p,
64 point_conversion_form_t form, BIGNUM *bn,
66 EC_POINT *EC_POINT_bn2point(const EC_GROUP *group, const BIGNUM *bn,
67 EC_POINT *p, BN_CTX *ctx);
68 char *EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *p,
69 point_conversion_form_t form, BN_CTX *ctx);
70 EC_POINT *EC_POINT_hex2point(const EC_GROUP *group, const char *hex,
71 EC_POINT *p, BN_CTX *ctx);
76 An B<EC_POINT> structure represents a point on a curve. A new point is
77 constructed by calling the function EC_POINT_new() and providing the
78 B<group> object that the point relates to.
80 EC_POINT_free() frees the memory associated with the B<EC_POINT>.
81 if B<point> is NULL nothing is done.
83 EC_POINT_clear_free() destroys any sensitive data held within the EC_POINT and
84 then frees its memory. If B<point> is NULL nothing is done.
86 EC_POINT_copy() copies the point B<src> into B<dst>. Both B<src> and B<dst>
87 must use the same B<EC_METHOD>.
89 EC_POINT_dup() creates a new B<EC_POINT> object and copies the content from
90 B<src> to the newly created B<EC_POINT> object.
92 EC_POINT_method_of() obtains the B<EC_METHOD> associated with B<point>.
94 A valid point on a curve is the special point at infinity. A point is set to
95 be at infinity by calling EC_POINT_set_to_infinity().
97 The affine co-ordinates for a point describe a point in terms of its x and y
98 position. The functions EC_POINT_set_affine_coordinates_GFp() and
99 EC_POINT_set_affine_coordinates_GF2m() set the B<x> and B<y> co-ordinates for
100 the point B<p> defined over the curve given in B<group>.
102 As well as the affine co-ordinates, a point can alternatively be described in
103 terms of its Jacobian projective co-ordinates (for Fp curves only). Jacobian
104 projective co-ordinates are expressed as three values x, y and z. Working in
105 this co-ordinate system provides more efficient point multiplication
106 operations. A mapping exists between Jacobian projective co-ordinates and
107 affine co-ordinates. A Jacobian projective co-ordinate (x, y, z) can be written
108 as an affine co-ordinate as (x/(z^2), y/(z^3)). Conversion to Jacobian
109 projective to affine co-ordinates is simple. The co-ordinate (x, y) is mapped
110 to (x, y, 1). To set or get the projective co-ordinates use
111 EC_POINT_set_Jprojective_coordinates_GFp() and
112 EC_POINT_get_Jprojective_coordinates_GFp() respectively.
114 Points can also be described in terms of their compressed co-ordinates. For a
115 point (x, y), for any given value for x such that the point is on the curve
116 there will only ever be two possible values for y. Therefore a point can be set
117 using the EC_POINT_set_compressed_coordinates_GFp() and
118 EC_POINT_set_compressed_coordinates_GF2m() functions where B<x> is the x
119 co-ordinate and B<y_bit> is a value 0 or 1 to identify which of the two
120 possible values for y should be used.
122 In addition B<EC_POINT> can be converted to and from various external
123 representations. The octet form is the binary encoding of the B<ECPoint>
124 structure (as defined in RFC5480 and used in certificates and TLS records):
125 only the content octets are present, the B<OCTET STRING> tag and length are
126 not included. B<BIGNUM> form is the octet form interpreted as a big endian
127 integer converted to a B<BIGNUM> structure. Hexadecimal form is the octet
128 form converted to a NULL terminated character string where each character
129 is one of the printable values 0-9 or A-F (or a-f).
131 The functions EC_POINT_point2oct(), EC_POINT_oct2point(), EC_POINT_point2bn(),
132 EC_POINT_bn2point(), EC_POINT_point2hex() and EC_POINT_hex2point() convert from
133 and to EC_POINTs for the formats: octet, BIGNUM and hexadecimal respectively.
135 The function EC_POINT_point2oct() must be supplied with a buffer long enough to
136 store the octet form. The return value provides the number of octets stored.
137 Calling the function with a NULL buffer will not perform the conversion but
138 will still return the required buffer length.
140 The function EC_POINT_point2buf() allocates a buffer of suitable length and
141 writes an EC_POINT to it in octet format. The allocated buffer is written to
142 B<*pbuf> and its length is returned. The caller must free up the allocated
143 buffer with a call to OPENSSL_free(). Since the allocated buffer value is
144 written to B<*pbuf> the B<pbuf> parameter B<MUST NOT> be B<NULL>.
146 The function EC_POINT_point2hex() will allocate sufficient memory to store the
147 hexadecimal string. It is the caller's responsibility to free this memory with
148 a subsequent call to OPENSSL_free().
152 EC_POINT_new() and EC_POINT_dup() return the newly allocated EC_POINT or NULL
155 The following functions return 1 on success or 0 on error: EC_POINT_copy(),
156 EC_POINT_set_to_infinity(), EC_POINT_set_Jprojective_coordinates_GFp(),
157 EC_POINT_get_Jprojective_coordinates_GFp(),
158 EC_POINT_set_affine_coordinates_GFp(), EC_POINT_get_affine_coordinates_GFp(),
159 EC_POINT_set_compressed_coordinates_GFp(),
160 EC_POINT_set_affine_coordinates_GF2m(), EC_POINT_get_affine_coordinates_GF2m(),
161 EC_POINT_set_compressed_coordinates_GF2m() and EC_POINT_oct2point().
163 EC_POINT_method_of returns the EC_METHOD associated with the supplied EC_POINT.
165 EC_POINT_point2oct() and EC_point2buf() return the length of the required
166 buffer or 0 on error.
168 EC_POINT_point2bn() returns the pointer to the BIGNUM supplied, or NULL on
171 EC_POINT_bn2point() returns the pointer to the EC_POINT supplied, or NULL on
174 EC_POINT_point2hex() returns a pointer to the hex string, or NULL on error.
176 EC_POINT_hex2point() returns the pointer to the EC_POINT supplied, or NULL on
181 L<crypto(3)>, L<ec(3)>, L<EC_GROUP_new(3)>, L<EC_GROUP_copy(3)>,
182 L<EC_POINT_add(3)>, L<EC_KEY_new(3)>,
183 L<EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)>