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