diff options
| author | tb <> | 2025-04-25 19:57:12 +0000 |
|---|---|---|
| committer | tb <> | 2025-04-25 19:57:12 +0000 |
| commit | 60904c983d054a3655c2d3ac38828e2b8c9cc067 (patch) | |
| tree | 861ff688d2e1eb96feb6980c81276954e5ebafe4 /src/lib/libcrypto/man/EC_POINT_new.3 | |
| parent | d569ea3a7dd45ac021b0335a24722227abc9bd8d (diff) | |
| download | openbsd-60904c983d054a3655c2d3ac38828e2b8c9cc067.tar.gz openbsd-60904c983d054a3655c2d3ac38828e2b8c9cc067.tar.bz2 openbsd-60904c983d054a3655c2d3ac38828e2b8c9cc067.zip | |
Rework EC documentation
This replaces the giant, poor quality and outdated EC_GROUP_copy.3,
EC_GROUP_new.3, and EC_POINT_new.3 manuals with seven new manuals
written from scratch.
* EC_GROUP_new_by_curve_name() is the entry point for builtin curves,
* EC_GROUP_new_curve_GFp() describes lower level API that should not
usually be needed apart from a handful of accessors.
* EC_GROUP_check() contains two functions that applications should not
need because either you know for certain something is an elliptic
curve (so these checks are pointless) or you should not use it.
* EC_GROUP_get_curve_name() describes some low level ASN.1 footguns
and corresponding getters.
* EC_POINT_new() contains the simple EC_POINT allocation and freeing API
* EC_POINT_get_affine_coordinates() contains the coordinate accessors
* EC_POINT_point2oct() is about encoding elliptic curve points
While all this is quite far from perfect, the diff is getting too big
and it will be easier to improve this in tree. It is definitely more
repetitive than I would like it to be.
Reviews, tweaks and general feedback are of course welcome.
discussed with jsing
Diffstat (limited to 'src/lib/libcrypto/man/EC_POINT_new.3')
| -rw-r--r-- | src/lib/libcrypto/man/EC_POINT_new.3 | 506 |
1 files changed, 129 insertions, 377 deletions
diff --git a/src/lib/libcrypto/man/EC_POINT_new.3 b/src/lib/libcrypto/man/EC_POINT_new.3 index db6280fce7..cfc988f294 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.18 2025/04/25 19:57:12 tb 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: April 25 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,163 +22,56 @@ | |||
| 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 |
| 75 | .In openssl/ec.h | 28 | .In openssl/ec.h |
| 76 | .In openssl/bn.h | 29 | .Pp |
| 77 | .Ft EC_POINT * | 30 | .Ft "EC_POINT *" |
| 78 | .Fo EC_POINT_new | 31 | .Fo EC_POINT_new |
| 79 | .Fa "const EC_GROUP *group" | 32 | .Fa "const EC_GROUP *group" |
| 80 | .Fc | 33 | .Fc |
| 81 | .Ft void | 34 | .Ft "void" |
| 82 | .Fo EC_POINT_free | 35 | .Fo EC_POINT_free |
| 83 | .Fa "EC_POINT *point" | 36 | .Fa "EC_POINT *point" |
| 84 | .Fc | 37 | .Fc |
| 85 | .Ft void | 38 | .Ft "void" |
| 86 | .Fo EC_POINT_clear_free | 39 | .Fo EC_POINT_clear_free |
| 87 | .Fa "EC_POINT *point" | 40 | .Fa "EC_POINT *point" |
| 88 | .Fc | 41 | .Fc |
| 89 | .Ft int | 42 | .Ft "int" |
| 90 | .Fo EC_POINT_copy | 43 | .Fo EC_POINT_copy |
| 91 | .Fa "EC_POINT *dst" | 44 | .Fa "EC_POINT *dst" |
| 92 | .Fa "const EC_POINT *src" | 45 | .Fa "const EC_POINT *src" |
| 93 | .Fc | 46 | .Fc |
| 94 | .Ft EC_POINT * | 47 | .Ft "EC_POINT *" |
| 95 | .Fo EC_POINT_dup | 48 | .Fo EC_POINT_dup |
| 96 | .Fa "const EC_POINT *src" | 49 | .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" | ||
| 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" | 50 | .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 | 51 | .Fc |
| 198 | .Sh DESCRIPTION | 52 | .Sh DESCRIPTION |
| 199 | An | 53 | An |
| 200 | .Vt EC_POINT | 54 | .Vt EC_POINT |
| 201 | represents a point on a curve. | 55 | object holds a point on the elliptic curve represented by an |
| 202 | A curve is represented by an | 56 | .Vt EC_GROUP . |
| 203 | .Vt EC_GROUP | 57 | The details of the internal representation depend on the group |
| 204 | object created by the functions described in | 58 | and should never be an application's concern since the EC library |
| 205 | .Xr EC_GROUP_new 3 . | 59 | has API to set a point's coordinates, |
| 60 | .Xr EC_POINT_set_affine_coordinates 3 . | ||
| 206 | .Pp | 61 | .Pp |
| 207 | A new point is constructed by calling the function | ||
| 208 | .Fn EC_POINT_new | 62 | .Fn EC_POINT_new |
| 209 | and providing the | 63 | allocates and initializes an |
| 210 | .Fa group | 64 | .Vt EC_POINT |
| 211 | object that the point relates to. | 65 | object to be used with the |
| 66 | .Fa group . | ||
| 67 | Before explicitly setting its coordinates, the returned | ||
| 68 | .Vt EC_POINT | ||
| 69 | is invalid. | ||
| 212 | .Pp | 70 | .Pp |
| 213 | .Fn EC_POINT_free | 71 | .Fn EC_POINT_free |
| 214 | frees the memory associated with the | 72 | frees |
| 215 | .Vt EC_POINT . | 73 | .Fa point |
| 74 | and all memory associated with it. | ||
| 216 | If | 75 | If |
| 217 | .Fa point | 76 | .Fa point |
| 218 | is a | 77 | is a |
| @@ -220,236 +79,129 @@ is a | |||
| 220 | pointer, no action occurs. | 79 | pointer, no action occurs. |
| 221 | .Pp | 80 | .Pp |
| 222 | .Fn EC_POINT_clear_free | 81 | .Fn EC_POINT_clear_free |
| 223 | destroys any sensitive data held within the | 82 | is intended to destroy sensitive data held in |
| 224 | .Vt EC_POINT | ||
| 225 | and then frees its memory. | ||
| 226 | If | ||
| 227 | .Fa point | 83 | .Fa point |
| 228 | is a | 84 | in addition to freeing all memory associated with it. |
| 229 | .Dv NULL | 85 | Since elliptic curve points usually hold public data, this |
| 230 | pointer, no action occurs. | 86 | is rarely needed. |
| 87 | In LibreSSL, | ||
| 88 | .Fn EC_POINT_free | ||
| 89 | and | ||
| 90 | .Fn EC_POINT_clear_free | ||
| 91 | behave identically. | ||
| 231 | .Pp | 92 | .Pp |
| 232 | .Fn EC_POINT_copy | 93 | .Fn EC_POINT_copy |
| 233 | copies the point | 94 | copies the internal representation of |
| 234 | .Fa src | 95 | .Fa src |
| 235 | into | 96 | into |
| 236 | .Fa dst . | 97 | .Fa dst . |
| 237 | Both | 98 | If |
| 238 | .Fa src | 99 | .Fa src |
| 239 | and | 100 | and |
| 240 | .Fa dst | 101 | .Fa dst |
| 241 | must use the same | 102 | are identical, no action occurs. |
| 242 | .Vt EC_METHOD . | 103 | Both |
| 243 | .Pp | ||
| 244 | .Fn EC_POINT_dup | ||
| 245 | creates a new | ||
| 246 | .Vt EC_POINT | ||
| 247 | object and copies the content from | ||
| 248 | .Fa src | 104 | .Fa src |
| 249 | to the newly created | ||
| 250 | .Vt EC_POINT | ||
| 251 | object. | ||
| 252 | .Pp | ||
| 253 | A valid point on a curve is the special point at infinity. | ||
| 254 | A point is set to be at infinity by calling | ||
| 255 | .Fn EC_POINT_set_to_infinity . | ||
| 256 | .Pp | ||
| 257 | The affine coordinates for a point describe a point in terms of its | ||
| 258 | .Fa x | ||
| 259 | and | ||
| 260 | .Fa y | ||
| 261 | position. | ||
| 262 | The function | ||
| 263 | .Fn EC_POINT_set_affine_coordinates | ||
| 264 | sets the | ||
| 265 | .Fa x | ||
| 266 | and | ||
| 267 | .Fa y | ||
| 268 | coordinates for the point | ||
| 269 | .Fa p | ||
| 270 | defined over the curve given in | ||
| 271 | .Fa group . | ||
| 272 | The function | ||
| 273 | .Fn EC_POINT_get_affine_coordinates | ||
| 274 | sets | ||
| 275 | .Fa x | ||
| 276 | and | ||
| 277 | .Fa y , | ||
| 278 | either of which may be | ||
| 279 | .Dv NULL , | ||
| 280 | to the corresponding coordinates of | ||
| 281 | .Fa p . | ||
| 282 | .Pp | ||
| 283 | The functions | ||
| 284 | .Fn EC_POINT_set_affine_coordinates_GFp | ||
| 285 | is a deprecated synonym for | ||
| 286 | .Fn EC_POINT_set_affine_coordinates | ||
| 287 | and the function | ||
| 288 | .Fn EC_POINT_get_affine_coordinates_GFp | ||
| 289 | is a deprecated synonym for | ||
| 290 | .Fn EC_POINT_get_affine_coordinates . | ||
| 291 | .Pp | ||
| 292 | Points can also be described in terms of their compressed coordinates. | ||
| 293 | For a point | ||
| 294 | .Pq Fa x , y , | ||
| 295 | for any given value for | ||
| 296 | .Fa x | ||
| 297 | such that the point is on the curve, there will only ever be two | ||
| 298 | possible values for | ||
| 299 | .Fa y . | ||
| 300 | Therefore, a point can be set using the | ||
| 301 | .Fn EC_POINT_set_compressed_coordinates | ||
| 302 | function where | ||
| 303 | .Fa x | ||
| 304 | is the x coordinate and | ||
| 305 | .Fa y_bit | ||
| 306 | is a value 0 or 1 to identify which of the two possible values for y | ||
| 307 | should be used. | ||
| 308 | .Pp | ||
| 309 | The functions | ||
| 310 | .Fn EC_POINT_set_compressed_coordinates_GFp | ||
| 311 | is a deprecated synonym for | ||
| 312 | .Fn EC_POINT_set_compressed_coordinates . | ||
| 313 | .Pp | ||
| 314 | In addition | ||
| 315 | .Vt EC_POINT Ns s | ||
| 316 | can be converted to and from various external representations. | ||
| 317 | Supported representations are octet strings, | ||
| 318 | .Vt BIGNUM Ns s , | ||
| 319 | and hexadecimal. | ||
| 320 | The format of the external representation is described by the | ||
| 321 | point_conversion_form. | ||
| 322 | See | ||
| 323 | .Xr EC_GROUP_copy 3 | ||
| 324 | for a description of point_conversion_form. | ||
| 325 | Octet strings are stored in a buffer along with an associated buffer | ||
| 326 | length. | ||
| 327 | A point held in a | ||
| 328 | .Vt BIGNUM | ||
| 329 | is calculated by converting the point to an octet string and then | ||
| 330 | converting that octet string into a | ||
| 331 | .Vt BIGNUM | ||
| 332 | integer. | ||
| 333 | Points in hexadecimal format are stored in a NUL terminated character | ||
| 334 | string where each character is one of the printable values 0-9 or A-F | ||
| 335 | (or a-f). | ||
| 336 | .Pp | ||
| 337 | The 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 , | ||
| 343 | and | 105 | and |
| 344 | .Fn EC_POINT_hex2point | 106 | .Fa dst |
| 345 | convert from and to | 107 | should be the result of |
| 346 | .Vt EC_POINT Ns s | 108 | .Fn EC_POINT_new |
| 347 | for the formats octet string, | 109 | with the same |
| 348 | .Vt BIGNUM , | 110 | .Fa group |
| 349 | and hexadecimal, respectively. | 111 | argument, although |
| 350 | .Pp | 112 | .Fn EC_POINT_copy |
| 351 | The function | 113 | cannot check that. |
| 352 | .Fn EC_POINT_point2oct | ||
| 353 | must be supplied with a | ||
| 354 | .Fa buf | ||
| 355 | long enough to store the octet string. | ||
| 356 | The return value provides the number of octets stored. | ||
| 357 | Calling the function with a | ||
| 358 | .Dv NULL | ||
| 359 | .Fa buf | ||
| 360 | will not perform the conversion but will still return the required | ||
| 361 | buffer length. | ||
| 362 | .Pp | 114 | .Pp |
| 363 | The function | 115 | .Fn EC_POINT_dup |
| 364 | .Fn EC_POINT_point2hex | 116 | creates a deep copy of |
| 365 | will allocate sufficient memory to store the hexadecimal string. | 117 | .Fa point |
| 366 | It is the caller's responsibility to free this memory with a subsequent | 118 | by combining |
| 367 | call to | 119 | .Fn EC_POINT_new |
| 368 | .Xr free 3 . | 120 | with |
| 121 | .Fn EC_GROUP_copy . | ||
| 369 | .Sh RETURN VALUES | 122 | .Sh RETURN VALUES |
| 370 | .Fn EC_POINT_new | 123 | .Fn EC_POINT_new |
| 371 | and | 124 | returns a newly allocated |
| 372 | .Fn EC_POINT_dup | ||
| 373 | return the newly allocated | ||
| 374 | .Vt EC_POINT | 125 | .Vt EC_POINT |
| 375 | or | 126 | or |
| 376 | .Dv NULL | 127 | .Dv NULL |
| 377 | on error. | 128 | on memory allocation failure. |
| 378 | .Pp | 129 | .Pp |
| 379 | The following functions return 1 on success or 0 on error: | 130 | .Fn EC_POINT_copy |
| 380 | .Fn EC_POINT_copy , | 131 | returns 1 on success or 0 on error. |
| 381 | .Fn EC_POINT_set_to_infinity , | 132 | Error conditions include memory allocation failure and that |
| 382 | .Fn EC_POINT_set_affine_coordinates , | 133 | .Fa dst |
| 383 | .Fn EC_POINT_set_affine_coordinates_GFp , | 134 | is incompatible with the group on which |
| 384 | .Fn EC_POINT_get_affine_coordinates , | 135 | .Fa src |
| 385 | .Fn EC_POINT_get_affine_coordinates_GFp , | 136 | is defined. |
| 386 | .Fn EC_POINT_set_compressed_coordinates , | ||
| 387 | .Fn EC_POINT_set_compressed_coordinates_GFp , | ||
| 388 | and | ||
| 389 | .Fn EC_POINT_oct2point . | ||
| 390 | .Pp | ||
| 391 | .Fn EC_POINT_point2oct | ||
| 392 | returns the length of the required buffer, or 0 on error. | ||
| 393 | .Pp | ||
| 394 | .Fn EC_POINT_point2bn | ||
| 395 | returns the pointer to the | ||
| 396 | .Vt BIGNUM | ||
| 397 | supplied or | ||
| 398 | .Dv NULL | ||
| 399 | on error. | ||
| 400 | .Pp | ||
| 401 | .Fn EC_POINT_bn2point | ||
| 402 | returns the pointer to the | ||
| 403 | .Vt EC_POINT | ||
| 404 | supplied or | ||
| 405 | .Dv NULL | ||
| 406 | on error. | ||
| 407 | .Pp | ||
| 408 | .Fn EC_POINT_point2hex | ||
| 409 | returns a pointer to the hex string or | ||
| 410 | .Dv NULL | ||
| 411 | on error. | ||
| 412 | .Pp | 137 | .Pp |
| 413 | .Fn EC_POINT_hex2point | 138 | .Fn EC_POINT_dup |
| 414 | returns the pointer to the | 139 | returns a newly allocated |
| 415 | .Vt EC_POINT | 140 | .Vt EC_POINT |
| 416 | supplied or | 141 | or |
| 417 | .Dv NULL | 142 | .Dv NULL |
| 418 | on error. | 143 | on failure. |
| 144 | Error conditions include memory allocation failure or that | ||
| 145 | .Fa group | ||
| 146 | is incompatible with | ||
| 147 | .Fa src . | ||
| 419 | .Sh SEE ALSO | 148 | .Sh SEE ALSO |
| 149 | .Xr BN_CTX_new 3 , | ||
| 150 | .Xr BN_is_zero 3 , | ||
| 151 | .Xr crypto 3 , | ||
| 420 | .Xr d2i_ECPKParameters 3 , | 152 | .Xr d2i_ECPKParameters 3 , |
| 421 | .Xr EC_GROUP_copy 3 , | 153 | .Xr EC_GROUP_check 3 , |
| 422 | .Xr EC_GROUP_new 3 , | 154 | .Xr EC_GROUP_get_curve_name 3 , |
| 155 | .Xr EC_GROUP_new_by_curve_name 3 , | ||
| 156 | .Xr EC_GROUP_new_curve_GFp 3 , | ||
| 157 | .Xr EC_KEY_METHOD_new 3 , | ||
| 423 | .Xr EC_KEY_new 3 , | 158 | .Xr EC_KEY_new 3 , |
| 424 | .Xr EC_POINT_add 3 , | 159 | .Xr EC_POINT_add 3 , |
| 425 | .Xr ECDH_compute_key 3 | 160 | .Xr EC_POINT_get_affine_coordinates 3 , |
| 161 | .Xr EC_POINT_point2oct 3 , | ||
| 162 | .Xr ECDH_compute_key 3 , | ||
| 163 | .Xr ECDSA_SIG_new 3 | ||
| 426 | .Sh HISTORY | 164 | .Sh HISTORY |
| 427 | .Fn EC_POINT_new , | 165 | .Fn EC_POINT_new , |
| 428 | .Fn EC_POINT_free , | 166 | .Fn EC_POINT_free , |
| 429 | .Fn EC_POINT_clear_free , | 167 | .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 , | ||
| 436 | and | 168 | and |
| 437 | .Fn EC_POINT_oct2point | 169 | .Fn EC_POINT_copy |
| 438 | first appeared in OpenSSL 0.9.7 and have been available since | 170 | first appeared in OpenSSL 0.9.7 and have been available since |
| 439 | .Ox 3.2 . | 171 | .Ox 3.2 . |
| 440 | .Pp | 172 | .Pp |
| 441 | .Fn EC_POINT_dup , | 173 | .Fn EC_POINT_dup |
| 442 | .Fn EC_POINT_point2bn , | 174 | first appeared in OpenSSL 0.9.8 and has been available since |
| 443 | .Fn EC_POINT_bn2point , | ||
| 444 | .Fn EC_POINT_point2hex , | ||
| 445 | and | ||
| 446 | .Fn EC_POINT_hex2point | ||
| 447 | first appeared in OpenSSL 0.9.8 and have been available since | ||
| 448 | .Ox 4.5 . | 175 | .Ox 4.5 . |
| 449 | .Pp | 176 | .Sh BUGS |
| 450 | .Fn EC_POINT_set_affine_coordinates , | 177 | A fundamental flaw in the OpenSSL API toolkit is that |
| 451 | .Fn EC_POINT_get_affine_coordinates , | 178 | .Fn *_new |
| 179 | functions usually create invalid objects that are tricky to | ||
| 180 | turn into valid objects. | ||
| 181 | A fundamental flaw in the EC library is that | ||
| 182 | .Vt EC_POINT | ||
| 183 | objects do not hold a reference to the group they live on | ||
| 184 | despite the fact that | ||
| 185 | .Fn EC_POINT_new | ||
| 186 | has a | ||
| 187 | .Fa group | ||
| 188 | argument. | ||
| 189 | This is difficult to fix because | ||
| 190 | .Vt EC_GROUP | ||
| 191 | objects are not reference counted and | ||
| 192 | because of const qualifiers in the API. | ||
| 193 | This is the root cause for various contortions in the EC library | ||
| 194 | and API. | ||
| 195 | This has security implications because not | ||
| 196 | only does the library not know whether an | ||
| 197 | .Fa EC_POINT | ||
| 198 | object represents a valid point, | ||
| 199 | even if it did know that it would not know on what curve. | ||
| 200 | .Pp | ||
| 201 | The signature of | ||
| 202 | .Fn EC_GROUP_dup | ||
| 203 | is bizarre and the order of | ||
| 204 | .Fa point | ||
| 452 | and | 205 | and |
| 453 | .Fn EC_POINT_set_compressed_coordinates | 206 | .Fa group |
| 454 | first appeared in OpenSSL 1.1.1 and have been available since | 207 | is inconsistent with the rest of the EC API. |
| 455 | .Ox 7.0 . | ||
