]>
Commit | Line | Data |
---|---|---|
aafbe1cc MC |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
de34e45a MC |
5 | EC_GROUP_get_ecparameters, |
6 | EC_GROUP_get_ecpkparameters, | |
f585cefc | 7 | EC_GROUP_new_ex, |
de34e45a MC |
8 | EC_GROUP_new, |
9 | EC_GROUP_new_from_ecparameters, | |
60b350a3 | 10 | EC_GROUP_new_from_ecpkparameters, |
de34e45a MC |
11 | EC_GROUP_free, |
12 | EC_GROUP_clear_free, | |
13 | EC_GROUP_new_curve_GFp, | |
14 | EC_GROUP_new_curve_GF2m, | |
f585cefc | 15 | EC_GROUP_new_by_curve_name_ex, |
de34e45a MC |
16 | EC_GROUP_new_by_curve_name, |
17 | EC_GROUP_set_curve, | |
18 | EC_GROUP_get_curve, | |
19 | EC_GROUP_set_curve_GFp, | |
20 | EC_GROUP_get_curve_GFp, | |
21 | EC_GROUP_set_curve_GF2m, | |
22 | EC_GROUP_get_curve_GF2m, | |
bb9ad09e RS |
23 | EC_get_builtin_curves - Functions for creating and destroying EC_GROUP |
24 | objects | |
aafbe1cc MC |
25 | |
26 | =head1 SYNOPSIS | |
27 | ||
28 | #include <openssl/ec.h> | |
aafbe1cc | 29 | |
f585cefc | 30 | EC_GROUP *EC_GROUP_new_ex(OPENSSL_CTX *libctx, const EC_METHOD *meth); |
aafbe1cc | 31 | EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); |
60b350a3 RS |
32 | EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) |
33 | EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params) | |
aafbe1cc | 34 | void EC_GROUP_free(EC_GROUP *group); |
aafbe1cc | 35 | |
e9b77246 BB |
36 | EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, |
37 | const BIGNUM *b, BN_CTX *ctx); | |
38 | EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, | |
39 | const BIGNUM *b, BN_CTX *ctx); | |
f585cefc | 40 | EC_GROUP *EC_GROUP_new_by_curve_name_ex(OPENSSL_CTX *libctx, int nid); |
aafbe1cc MC |
41 | EC_GROUP *EC_GROUP_new_by_curve_name(int nid); |
42 | ||
de34e45a MC |
43 | int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, |
44 | const BIGNUM *b, BN_CTX *ctx); | |
45 | int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, | |
46 | BN_CTX *ctx); | |
e9b77246 BB |
47 | int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, |
48 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | |
49 | int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, | |
50 | BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | |
51 | int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, | |
52 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); | |
53 | int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, | |
54 | BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | |
aafbe1cc | 55 | |
60b350a3 RS |
56 | ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, ECPARAMETERS *params) |
57 | ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, ECPKPARAMETERS *params) | |
58 | ||
aafbe1cc MC |
59 | size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); |
60 | ||
4a7a4972 NT |
61 | Deprecated since OpenSSL 3.0, can be hidden entirely by defining |
62 | B<OPENSSL_API_COMPAT> with a suitable version value, see | |
63 | L<openssl_user_macros(7)>: | |
64 | ||
65 | void EC_GROUP_clear_free(EC_GROUP *group); | |
66 | ||
aafbe1cc MC |
67 | =head1 DESCRIPTION |
68 | ||
4fc55c1d NT |
69 | Within the library there are two forms of elliptic curve that are of interest. |
70 | The first form is those defined over the prime field Fp. The elements of Fp are | |
71 | the integers 0 to p-1, where p is a prime number. This gives us a revised | |
aafbe1cc MC |
72 | elliptic curve equation as follows: |
73 | ||
74 | y^2 mod p = x^3 +ax + b mod p | |
75 | ||
4fc55c1d NT |
76 | The second form is those defined over a binary field F2^m where the elements of |
77 | the field are integers of length at most m bits. For this form the elliptic | |
78 | curve equation is modified to: | |
aafbe1cc MC |
79 | |
80 | y^2 + xy = x^3 + ax^2 + b (where b != 0) | |
81 | ||
4fc55c1d NT |
82 | Operations in a binary field are performed relative to an |
83 | B<irreducible polynomial>. All such curves with OpenSSL use a trinomial or a | |
84 | pentanomial for this parameter. | |
aafbe1cc | 85 | |
4fc55c1d NT |
86 | A new curve can be constructed by calling EC_GROUP_new_ex(), using the |
87 | implementation provided by B<meth> (see L<EC_GFp_simple_method(3)>) and | |
88 | associated with the library context B<ctx> (see L<OPENSSL_CTX(3)>). | |
89 | The B<ctx> parameter may be NULL in which case the default library context is | |
90 | used. | |
f585cefc | 91 | It is then necessary to call EC_GROUP_set_curve() to set the curve parameters. |
60b350a3 RS |
92 | EC_GROUP_new_from_ecparameters() will create a group from the |
93 | specified B<params> and | |
4fc55c1d NT |
94 | EC_GROUP_new_from_ecpkparameters() will create a group from the specific PK |
95 | B<params>. | |
aafbe1cc | 96 | |
4fc55c1d | 97 | EC_GROUP_new() is the same as EC_GROUP_new_ex() except that the library context |
f585cefc MC |
98 | used is always the default library context. |
99 | ||
4fc55c1d | 100 | EC_GROUP_set_curve() sets the curve parameters B<p>, B<a> and B<b>. For a curve |
eb2ff040 | 101 | over Fp B<p> is the prime for the field. For a curve over F2^m B<p> represents |
4fc55c1d NT |
102 | the irreducible polynomial - each bit represents a term in the polynomial. |
103 | Therefore there will either be three or five bits set dependent on whether the | |
104 | polynomial is a trinomial or a pentanomial. | |
eb2ff040 NT |
105 | In either case, B<a> and B<b> represents the coefficients a and b from the |
106 | relevant equation introduced above. | |
aafbe1cc | 107 | |
de34e45a | 108 | EC_group_get_curve() obtains the previously set curve parameters. |
aafbe1cc | 109 | |
4fc55c1d NT |
110 | EC_GROUP_set_curve_GFp() and EC_GROUP_set_curve_GF2m() are synonyms for |
111 | EC_GROUP_set_curve(). They are defined for backwards compatibility only and | |
112 | should not be used. | |
113 | ||
114 | EC_GROUP_get_curve_GFp() and EC_GROUP_get_curve_GF2m() are synonyms for | |
115 | EC_GROUP_get_curve(). They are defined for backwards compatibility only and | |
116 | should not be used. | |
117 | ||
118 | The functions EC_GROUP_new_curve_GFp() and EC_GROUP_new_curve_GF2m() are | |
119 | shortcuts for calling EC_GROUP_new() and then the EC_GROUP_set_curve() function. | |
120 | An appropriate default implementation method will be used. | |
121 | ||
122 | Whilst the library can be used to create any curve using the functions described | |
123 | above, there are also a number of predefined curves that are available. In order | |
124 | to obtain a list of all of the predefined curves, call the function | |
125 | EC_get_builtin_curves(). The parameter B<r> should be an array of | |
126 | EC_builtin_curve structures of size B<nitems>. The function will populate the | |
127 | B<r> array with information about the built-in curves. If B<nitems> is less than | |
128 | the total number of curves available, then the first B<nitems> curves will be | |
129 | returned. Otherwise the total number of curves will be provided. The return | |
130 | value is the total number of curves available (whether that number has been | |
131 | populated in B<r> or not). Passing a NULL B<r>, or setting B<nitems> to 0 will | |
132 | do nothing other than return the total number of curves available. | |
aafbe1cc MC |
133 | The EC_builtin_curve structure is defined as follows: |
134 | ||
1bc74519 RS |
135 | typedef struct { |
136 | int nid; | |
137 | const char *comment; | |
138 | } EC_builtin_curve; | |
aafbe1cc | 139 | |
4fc55c1d NT |
140 | Each EC_builtin_curve item has a unique integer id (B<nid>), and a human |
141 | readable comment string describing the curve. | |
aafbe1cc | 142 | |
4fc55c1d NT |
143 | In order to construct a built-in curve use the function |
144 | EC_GROUP_new_by_curve_name_ex() and provide the B<nid> of the curve to be | |
145 | constructed and the associated library context to be used in B<ctx> (see | |
146 | L<OPENSSL_CTX(3)>). The B<ctx> value may be NULL in which case the default | |
147 | library context is used. | |
f585cefc | 148 | |
4fc55c1d NT |
149 | EC_GROUP_new_by_curve_name() is the same as EC_GROUP_new_by_curve_name_ex() |
150 | except that the default library context is always used. | |
aafbe1cc | 151 | |
4fc55c1d | 152 | EC_GROUP_free() frees the memory associated with the EC_GROUP. |
8fdc3734 | 153 | If B<group> is NULL nothing is done. |
aafbe1cc | 154 | |
4fc55c1d | 155 | EC_GROUP_clear_free() is deprecated: it was meant to destroy any sensitive data |
4a7a4972 NT |
156 | held within the EC_GROUP and then free its memory, but since all the data stored |
157 | in the EC_GROUP is public anyway, this function is unnecessary. | |
4fc55c1d | 158 | Its use can be safely replaced with EC_GROUP_free(). |
8fdc3734 | 159 | If B<group> is NULL nothing is done. |
aafbe1cc MC |
160 | |
161 | =head1 RETURN VALUES | |
162 | ||
4fc55c1d NT |
163 | All EC_GROUP_new* functions return a pointer to the newly constructed group, or |
164 | NULL on error. | |
aafbe1cc | 165 | |
4fc55c1d NT |
166 | EC_get_builtin_curves() returns the number of built-in curves that are |
167 | available. | |
aafbe1cc | 168 | |
4fc55c1d NT |
169 | EC_GROUP_set_curve_GFp(), EC_GROUP_get_curve_GFp(), EC_GROUP_set_curve_GF2m(), |
170 | EC_GROUP_get_curve_GF2m() return 1 on success or 0 on error. | |
aafbe1cc MC |
171 | |
172 | =head1 SEE ALSO | |
173 | ||
9e183d22 | 174 | L<crypto(7)>, L<EC_GROUP_copy(3)>, |
9b86974e | 175 | L<EC_POINT_new(3)>, L<EC_POINT_add(3)>, L<EC_KEY_new(3)>, |
f585cefc MC |
176 | L<EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)>, |
177 | L<OPENSSL_CTX(3)> | |
178 | ||
179 | =head1 HISTORY | |
180 | ||
4a7a4972 NT |
181 | =over 2 |
182 | ||
183 | =item * | |
184 | ||
4fc55c1d | 185 | EC_GROUP_new_ex() and EC_GROUP_new_by_curve_name_ex() were added in OpenSSL 3.0. |
aafbe1cc | 186 | |
4a7a4972 NT |
187 | =item * |
188 | ||
4fc55c1d NT |
189 | EC_GROUP_clear_free() was deprecated in OpenSSL 3.0; use EC_GROUP_free() |
190 | instead. | |
4a7a4972 NT |
191 | |
192 | =back | |
193 | ||
e2f92610 RS |
194 | =head1 COPYRIGHT |
195 | ||
1212818e | 196 | Copyright 2013-2018 The OpenSSL Project Authors. All Rights Reserved. |
e2f92610 | 197 | |
4746f25a | 198 | Licensed under the Apache License 2.0 (the "License"). You may not use |
e2f92610 RS |
199 | this file except in compliance with the License. You can obtain a copy |
200 | in the file LICENSE in the source distribution or at | |
201 | L<https://www.openssl.org/source/license.html>. | |
202 | ||
203 | =cut |