]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/EC_GROUP_new.pod
CAPI engine: add support for RSA_NO_PADDING
[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,
14EC_GROUP_new_by_curve_name,
15EC_GROUP_set_curve,
16EC_GROUP_get_curve,
17EC_GROUP_set_curve_GFp,
18EC_GROUP_get_curve_GFp,
19EC_GROUP_set_curve_GF2m,
20EC_GROUP_get_curve_GF2m,
bb9ad09e
RS
21EC_get_builtin_curves - Functions for creating and destroying EC_GROUP
22objects
aafbe1cc
MC
23
24=head1 SYNOPSIS
25
26 #include <openssl/ec.h>
aafbe1cc
MC
27
28 EC_GROUP *EC_GROUP_new(const EC_METHOD *meth);
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
MC
31 void EC_GROUP_free(EC_GROUP *group);
32 void EC_GROUP_clear_free(EC_GROUP *group);
33
e9b77246
BB
34 EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,
35 const BIGNUM *b, BN_CTX *ctx);
36 EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,
37 const BIGNUM *b, BN_CTX *ctx);
aafbe1cc
MC
38 EC_GROUP *EC_GROUP_new_by_curve_name(int nid);
39
de34e45a
MC
40 int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
41 const BIGNUM *b, BN_CTX *ctx);
42 int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
43 BN_CTX *ctx);
e9b77246
BB
44 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
45 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
46 int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
47 BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
48 int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,
49 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
50 int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,
51 BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
aafbe1cc 52
60b350a3
RS
53 ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, ECPARAMETERS *params)
54 ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, ECPKPARAMETERS *params)
55
aafbe1cc
MC
56 size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);
57
58=head1 DESCRIPTION
59
60Within the library there are two forms of elliptic curve that are of interest. The first form is those defined over the
61prime field Fp. The elements of Fp are the integers 0 to p-1, where p is a prime number. This gives us a revised
62elliptic curve equation as follows:
63
64y^2 mod p = x^3 +ax + b mod p
65
66The second form is those defined over a binary field F2^m where the elements of the field are integers of length at
67most m bits. For this form the elliptic curve equation is modified to:
68
69y^2 + xy = x^3 + ax^2 + b (where b != 0)
70
71Operations in a binary field are performed relative to an B<irreducible polynomial>. All such curves with OpenSSL
72use a trinomial or a pentanomial for this parameter.
73
74A new curve can be constructed by calling EC_GROUP_new, using the implementation provided by B<meth> (see
de34e45a 75L<EC_GFp_simple_method(3)>). It is then necessary to call EC_GROUP_set_curve() to set the curve parameters.
60b350a3
RS
76EC_GROUP_new_from_ecparameters() will create a group from the
77specified B<params> and
78EC_GROUP_new_from_ecpkparameters() will create a group from the specific PK B<params>.
aafbe1cc 79
de34e45a
MC
80EC_GROUP_set_curve() sets the curve parameters B<p>, B<a> and B<b>. For a curve over Fp B<b>
81is the prime for the field. For a curve over F2^m B<p> represents the irreducible polynomial - each bit
82represents a term in the polynomial. Therefore there will either be three or five bits set dependent on whether
83the polynomial is a trinomial or a pentanomial.
aafbe1cc 84
de34e45a 85EC_group_get_curve() obtains the previously set curve parameters.
aafbe1cc 86
50db8163
MC
87EC_GROUP_set_curve_GFp() and EC_GROUP_set_curve_GF2m() are synonyms for EC_GROUP_set_curve(). They are defined for
88backwards compatibility only and should not be used.
de34e45a 89
50db8163
MC
90EC_GROUP_get_curve_GFp() and EC_GROUP_get_curve_GF2m() are synonyms for EC_GROUP_get_curve(). They are defined for
91backwards compatibility only and should not be used.
de34e45a
MC
92
93The functions EC_GROUP_new_curve_GFp and EC_GROUP_new_curve_GF2m are shortcuts for calling EC_GROUP_new and then the
94EC_GROUP_set_curve function. An appropriate default implementation method will be used.
aafbe1cc
MC
95
96Whilst the library can be used to create any curve using the functions described above, there are also a number of
97predefined curves that are available. In order to obtain a list of all of the predefined curves, call the function
98EC_get_builtin_curves. The parameter B<r> should be an array of EC_builtin_curve structures of size B<nitems>. The function
99will populate the B<r> array with information about the builtin curves. If B<nitems> is less than the total number of
100curves available, then the first B<nitems> curves will be returned. Otherwise the total number of curves will be
101provided. The return value is the total number of curves available (whether that number has been populated in B<r> or
102not). Passing a NULL B<r>, or setting B<nitems> to 0 will do nothing other than return the total number of curves available.
103The EC_builtin_curve structure is defined as follows:
104
1bc74519
RS
105 typedef struct {
106 int nid;
107 const char *comment;
108 } EC_builtin_curve;
aafbe1cc
MC
109
110Each EC_builtin_curve item has a unique integer id (B<nid>), and a human readable comment string describing the curve.
111
112In order to construct a builtin curve use the function EC_GROUP_new_by_curve_name and provide the B<nid> of the curve to
113be constructed.
114
115EC_GROUP_free frees the memory associated with the EC_GROUP.
8fdc3734 116If B<group> is NULL nothing is done.
aafbe1cc
MC
117
118EC_GROUP_clear_free destroys any sensitive data held within the EC_GROUP and then frees its memory.
8fdc3734 119If B<group> is NULL nothing is done.
aafbe1cc
MC
120
121=head1 RETURN VALUES
122
123All EC_GROUP_new* functions return a pointer to the newly constructed group, or NULL on error.
124
125EC_get_builtin_curves returns the number of builtin curves that are available.
126
127EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, EC_GROUP_set_curve_GF2m, EC_GROUP_get_curve_GF2m return 1 on success or 0 on error.
128
129=head1 SEE ALSO
130
9e183d22 131L<crypto(7)>, L<EC_GROUP_copy(3)>,
9b86974e
RS
132L<EC_POINT_new(3)>, L<EC_POINT_add(3)>, L<EC_KEY_new(3)>,
133L<EC_GFp_simple_method(3)>, L<d2i_ECPKParameters(3)>
aafbe1cc 134
e2f92610
RS
135=head1 COPYRIGHT
136
9e183d22 137Copyright 2013-2017 The OpenSSL Project Authors. All Rights Reserved.
e2f92610
RS
138
139Licensed under the OpenSSL license (the "License"). You may not use
140this file except in compliance with the License. You can obtain a copy
141in the file LICENSE in the source distribution or at
142L<https://www.openssl.org/source/license.html>.
143
144=cut