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_GROUP_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_GROUP_new.3')
| -rw-r--r-- | src/lib/libcrypto/man/EC_GROUP_new.3 | 353 |
1 files changed, 0 insertions, 353 deletions
diff --git a/src/lib/libcrypto/man/EC_GROUP_new.3 b/src/lib/libcrypto/man/EC_GROUP_new.3 deleted file mode 100644 index 83e3e4c870..0000000000 --- a/src/lib/libcrypto/man/EC_GROUP_new.3 +++ /dev/null | |||
| @@ -1,353 +0,0 @@ | |||
| 1 | .\" $OpenBSD: EC_GROUP_new.3,v 1.18 2025/03/08 16:38:13 tb Exp $ | ||
| 2 | .\" OpenSSL 6328d367 Sat Jul 4 21:58:30 2020 +0200 | ||
| 3 | .\" | ||
| 4 | .\" This file was written by Matt Caswell <matt@openssl.org>. | ||
| 5 | .\" Copyright (c) 2013 The OpenSSL Project. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" | ||
| 11 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 12 | .\" notice, this list of conditions and the following disclaimer. | ||
| 13 | .\" | ||
| 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 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_GROUP_NEW 3 | ||
| 53 | .Os | ||
| 54 | .Sh NAME | ||
| 55 | .Nm EC_GROUP_new , | ||
| 56 | .Nm EC_GROUP_free , | ||
| 57 | .Nm EC_GROUP_clear_free , | ||
| 58 | .Nm EC_GROUP_new_curve_GFp , | ||
| 59 | .Nm EC_GROUP_new_by_curve_name , | ||
| 60 | .Nm EC_GROUP_set_curve , | ||
| 61 | .Nm EC_GROUP_get_curve , | ||
| 62 | .Nm EC_GROUP_set_curve_GFp , | ||
| 63 | .Nm EC_GROUP_get_curve_GFp , | ||
| 64 | .Nm EC_get_builtin_curves , | ||
| 65 | .Nm EC_curve_nid2nist , | ||
| 66 | .Nm EC_curve_nist2nid | ||
| 67 | .Nd create and destroy EC_GROUP objects | ||
| 68 | .Sh SYNOPSIS | ||
| 69 | .In openssl/ec.h | ||
| 70 | .In openssl/bn.h | ||
| 71 | .Ft EC_GROUP * | ||
| 72 | .Fo EC_GROUP_new | ||
| 73 | .Fa "const EC_METHOD *meth" | ||
| 74 | .Fc | ||
| 75 | .Ft void | ||
| 76 | .Fo EC_GROUP_free | ||
| 77 | .Fa "EC_GROUP *group" | ||
| 78 | .Fc | ||
| 79 | .Ft void | ||
| 80 | .Fo EC_GROUP_clear_free | ||
| 81 | .Fa "EC_GROUP *group" | ||
| 82 | .Fc | ||
| 83 | .Ft EC_GROUP * | ||
| 84 | .Fo EC_GROUP_new_curve_GFp | ||
| 85 | .Fa "const BIGNUM *p" | ||
| 86 | .Fa "const BIGNUM *a" | ||
| 87 | .Fa "const BIGNUM *b" | ||
| 88 | .Fa "BN_CTX *ctx" | ||
| 89 | .Fc | ||
| 90 | .Ft EC_GROUP * | ||
| 91 | .Fo EC_GROUP_new_by_curve_name | ||
| 92 | .Fa "int nid" | ||
| 93 | .Fc | ||
| 94 | .Ft int | ||
| 95 | .Fo EC_GROUP_set_curve | ||
| 96 | .Fa "EC_GROUP *group" | ||
| 97 | .Fa "const BIGNUM *p" | ||
| 98 | .Fa "const BIGNUM *a" | ||
| 99 | .Fa "const BIGNUM *b" | ||
| 100 | .Fa "BN_CTX *ctx" | ||
| 101 | .Fc | ||
| 102 | .Ft int | ||
| 103 | .Fo EC_GROUP_get_curve | ||
| 104 | .Fa "const EC_GROUP *group" | ||
| 105 | .Fa "BIGNUM *p" | ||
| 106 | .Fa "BIGNUM *a" | ||
| 107 | .Fa "BIGNUM *b" | ||
| 108 | .Fa "BN_CTX *ctx" | ||
| 109 | .Fc | ||
| 110 | .Ft int | ||
| 111 | .Fo EC_GROUP_set_curve_GFp | ||
| 112 | .Fa "EC_GROUP *group" | ||
| 113 | .Fa "const BIGNUM *p" | ||
| 114 | .Fa "const BIGNUM *a" | ||
| 115 | .Fa "const BIGNUM *b" | ||
| 116 | .Fa "BN_CTX *ctx" | ||
| 117 | .Fc | ||
| 118 | .Ft int | ||
| 119 | .Fo EC_GROUP_get_curve_GFp | ||
| 120 | .Fa "const EC_GROUP *group" | ||
| 121 | .Fa "BIGNUM *p" | ||
| 122 | .Fa "BIGNUM *a" | ||
| 123 | .Fa "BIGNUM *b" | ||
| 124 | .Fa "BN_CTX *ctx" | ||
| 125 | .Fc | ||
| 126 | .Ft size_t | ||
| 127 | .Fo EC_get_builtin_curves | ||
| 128 | .Fa "EC_builtin_curve *r" | ||
| 129 | .Fa "size_t nitems" | ||
| 130 | .Fc | ||
| 131 | .Ft "const char *" | ||
| 132 | .Fo EC_curve_nid2nist | ||
| 133 | .Fa "int nid" | ||
| 134 | .Fc | ||
| 135 | .Ft int | ||
| 136 | .Fo EC_curve_nist2nid | ||
| 137 | .Fa "const char *name" | ||
| 138 | .Fc | ||
| 139 | .Sh DESCRIPTION | ||
| 140 | The EC library provides functions for performing operations on | ||
| 141 | elliptic curves in Weierstrass form. | ||
| 142 | Such curves are defined over the prime field of order | ||
| 143 | .Fa p | ||
| 144 | and satisfy the Weierstrass equation with coefficients | ||
| 145 | .Fa a | ||
| 146 | and | ||
| 147 | .Fa b | ||
| 148 | .Pp | ||
| 149 | .Dl y^2 = x^3 + ax + b | ||
| 150 | .Pp | ||
| 151 | An | ||
| 152 | .Vt EC_GROUP | ||
| 153 | structure is used to represent the definition of an elliptic curve. | ||
| 154 | A new curve can be constructed by calling | ||
| 155 | .Fn EC_GROUP_new , | ||
| 156 | using the implementation provided by | ||
| 157 | .Fa meth . | ||
| 158 | It is then necessary to call | ||
| 159 | .Fn EC_GROUP_set_curve | ||
| 160 | to set the curve parameters. | ||
| 161 | .Pp | ||
| 162 | .Fn EC_GROUP_set_curve | ||
| 163 | sets the curve parameters | ||
| 164 | .Fa p , | ||
| 165 | .Fa a , | ||
| 166 | and | ||
| 167 | .Fa b , | ||
| 168 | where | ||
| 169 | .Fa a | ||
| 170 | and | ||
| 171 | .Fa b | ||
| 172 | represent the coefficients of the curve equation. | ||
| 173 | .Pp | ||
| 174 | .Fn EC_GROUP_set_curve_GFp | ||
| 175 | is a deprecated synonym for | ||
| 176 | .Fn EC_GROUP_set_curve . | ||
| 177 | .Pp | ||
| 178 | .Fn EC_GROUP_get_curve | ||
| 179 | obtains the previously set curve parameters. | ||
| 180 | .Pp | ||
| 181 | .Fn EC_GROUP_get_curve_GFp | ||
| 182 | is a deprecated synonym for | ||
| 183 | .Fn EC_GROUP_get_curve . | ||
| 184 | .Pp | ||
| 185 | The function | ||
| 186 | .Fn EC_GROUP_new_curve_GFp | ||
| 187 | is a shortcut for calling | ||
| 188 | .Fn EC_GROUP_new | ||
| 189 | and | ||
| 190 | .Fn EC_GROUP_set_curve . | ||
| 191 | An appropriate default implementation method will be used. | ||
| 192 | .Pp | ||
| 193 | Whilst the library can be used to create any curve using the functions | ||
| 194 | described above, there are also a number of predefined curves that are | ||
| 195 | available. | ||
| 196 | In order to obtain a list of all of the predefined curves, call the | ||
| 197 | function | ||
| 198 | .Fn EC_get_builtin_curves . | ||
| 199 | The parameter | ||
| 200 | .Fa r | ||
| 201 | should be an array of | ||
| 202 | .Vt EC_builtin_cure | ||
| 203 | structures of size | ||
| 204 | .Fa nitems . | ||
| 205 | The function will populate the | ||
| 206 | .Fa r | ||
| 207 | array with information about the builtin curves. | ||
| 208 | If | ||
| 209 | .Fa nitems | ||
| 210 | is less than the total number of curves available, then the first | ||
| 211 | .Fa nitems | ||
| 212 | curves will be returned. | ||
| 213 | Otherwise the total number of curves will be provided. | ||
| 214 | The return value is the total number of curves available (whether that | ||
| 215 | number has been populated in | ||
| 216 | .Fa r | ||
| 217 | or not). | ||
| 218 | Passing a | ||
| 219 | .Dv NULL | ||
| 220 | .Fa r , | ||
| 221 | or setting | ||
| 222 | .Fa nitems | ||
| 223 | to 0, will do nothing other than return the total number of curves | ||
| 224 | available. | ||
| 225 | The | ||
| 226 | .Vt EC_builtin_curve | ||
| 227 | structure is defined as follows: | ||
| 228 | .Bd -literal | ||
| 229 | typedef struct { | ||
| 230 | int nid; | ||
| 231 | const char *comment; | ||
| 232 | } EC_builtin_curve; | ||
| 233 | .Ed | ||
| 234 | .Pp | ||
| 235 | Each | ||
| 236 | .Vt EC_builtin_curve | ||
| 237 | item has a unique integer ID | ||
| 238 | .Pq Fa nid | ||
| 239 | and a human readable comment string describing the curve. | ||
| 240 | .Pp | ||
| 241 | In order to construct a builtin curve, use the function | ||
| 242 | .Fn EC_GROUP_new_by_curve_name | ||
| 243 | and provide the | ||
| 244 | .Fa nid | ||
| 245 | of the curve to be constructed. | ||
| 246 | .Pp | ||
| 247 | .Fn EC_GROUP_free | ||
| 248 | frees the memory associated with the | ||
| 249 | .Vt EC_GROUP . | ||
| 250 | If | ||
| 251 | .Fa group | ||
| 252 | is a | ||
| 253 | .Dv NULL | ||
| 254 | pointer, no action occurs. | ||
| 255 | .Pp | ||
| 256 | .Fn EC_GROUP_clear_free | ||
| 257 | destroys any sensitive data held within the | ||
| 258 | .Vt EC_GROUP | ||
| 259 | and then frees its memory. | ||
| 260 | If | ||
| 261 | .Fa group | ||
| 262 | is a | ||
| 263 | .Dv NULL | ||
| 264 | pointer, no action occurs. | ||
| 265 | .Pp | ||
| 266 | Some builtin curves can be identified by their NIST name | ||
| 267 | in addition to a numerical identifier (NID). | ||
| 268 | .Fn EC_curve_nid2nist | ||
| 269 | and | ||
| 270 | .Fn EC_curve_nist2nid | ||
| 271 | translate between the two. | ||
| 272 | The five built-in prime curves are: | ||
| 273 | .Pp | ||
| 274 | .Bl -column "NIST name" NID_X9_62_prime256v1 "deprecated in SP800-186" -compact | ||
| 275 | .It No NIST Fa name Ta Em ASN.1 NID Ta Em notes | ||
| 276 | .It Qq P-192 Ta Dv NID_X9_62_prime192v1 Ta No deprecated in SP800-186 | ||
| 277 | .It Qq P-224 Ta Dv NID_secp224r1 Ta | ||
| 278 | .It Qq P-256 Ta Dv NID_X9_62_prime256v1 Ta | ||
| 279 | .It Qq P-384 Ta Dv NID_secp384r1 Ta | ||
| 280 | .It Qq P-521 Ta Dv NID_secp521r1 Ta | ||
| 281 | .El | ||
| 282 | .Pp | ||
| 283 | .Fn EC_curve_nid2nist | ||
| 284 | and | ||
| 285 | .Fn EC_curve_nist2nid | ||
| 286 | also accept the ten binary curves defined in FIPS\& 186-4 | ||
| 287 | and deprecated in SP800-186, | ||
| 288 | although they no longer correspond to builtin curves in LibreSSL. | ||
| 289 | .Sh RETURN VALUES | ||
| 290 | All | ||
| 291 | .Fn EC_GROUP_new* | ||
| 292 | functions return a pointer to the newly constructed group or | ||
| 293 | .Dv NULL | ||
| 294 | on error. | ||
| 295 | .Pp | ||
| 296 | .Fn EC_get_builtin_curves | ||
| 297 | returns the number of builtin curves that are available. | ||
| 298 | .Pp | ||
| 299 | .Fn EC_curve_nid2nist | ||
| 300 | returns a string constant containing the NIST name if | ||
| 301 | .Fa nid | ||
| 302 | identifies a NIST curve or | ||
| 303 | .Dv NULL | ||
| 304 | otherwise. | ||
| 305 | .Pp | ||
| 306 | .Fn EC_curve_nist2nid | ||
| 307 | returns the NID corresponding to the NIST curve | ||
| 308 | .Fa name , | ||
| 309 | or | ||
| 310 | .Dv NID_undef . | ||
| 311 | .Pp | ||
| 312 | .Fn EC_GROUP_set_curve , | ||
| 313 | .Fn EC_GROUP_get_curve , | ||
| 314 | .Fn EC_GROUP_set_curve_GFp , | ||
| 315 | and | ||
| 316 | .Fn EC_GROUP_get_curve_GFp | ||
| 317 | return 1 on success or 0 on error. | ||
| 318 | .Sh SEE ALSO | ||
| 319 | .Xr crypto 3 , | ||
| 320 | .Xr d2i_ECPKParameters 3 , | ||
| 321 | .Xr EC_GROUP_copy 3 , | ||
| 322 | .Xr EC_KEY_new 3 , | ||
| 323 | .Xr EC_POINT_add 3 , | ||
| 324 | .Xr EC_POINT_new 3 , | ||
| 325 | .Xr ECDH_compute_key 3 , | ||
| 326 | .Xr ECDSA_SIG_new 3 | ||
| 327 | .Sh HISTORY | ||
| 328 | .Fn EC_GROUP_new , | ||
| 329 | .Fn EC_GROUP_free , | ||
| 330 | .Fn EC_GROUP_clear_free , | ||
| 331 | .Fn EC_GROUP_new_curve_GFp , | ||
| 332 | .Fn EC_GROUP_set_curve_GFp , | ||
| 333 | and | ||
| 334 | .Fn EC_GROUP_get_curve_GFp | ||
| 335 | first appeared in OpenSSL 0.9.7 and have been available since | ||
| 336 | .Ox 3.2 . | ||
| 337 | .Pp | ||
| 338 | .Fn EC_GROUP_new_by_curve_name | ||
| 339 | and | ||
| 340 | .Fn EC_get_builtin_curves | ||
| 341 | first appeared in OpenSSL 0.9.8 and have been available since | ||
| 342 | .Ox 4.5 . | ||
| 343 | .Fn EC_curve_nid2nist , | ||
| 344 | and | ||
| 345 | .Fn EC_curve_nist2nid | ||
| 346 | first appeared in OpenSSL 1.1.0 and have been available since | ||
| 347 | .Ox 5.8 . | ||
| 348 | .Pp | ||
| 349 | .Fn EC_GROUP_set_curve | ||
| 350 | and | ||
| 351 | .Fn EC_GROUP_get_curve | ||
| 352 | first appeared in OpenSSL 1.1.1 and have been available since | ||
| 353 | .Ox 7.0 . | ||
