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