1 .\" $OpenBSD: EC_GROUP_new.3,v 1.6 2016/12/11 14:22:43 schwarze Exp $
2 .\" OpenSSL 9b86974e Mon Aug 17 15:21:33 2015 -0400
4 .\" This file was written by Matt Caswell <matt@openssl.org>.
5 .\" Copyright (c) 2013 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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.
51 .Dd $Mdocdate: December 11 2016 $
57 .Nm EC_GROUP_clear_free ,
58 .Nm EC_GROUP_new_curve_GFp ,
59 .Nm EC_GROUP_new_curve_GF2m ,
60 .Nm EC_GROUP_new_by_curve_name ,
61 .Nm EC_GROUP_set_curve_GFp ,
62 .Nm EC_GROUP_get_curve_GFp ,
63 .Nm EC_GROUP_set_curve_GF2m ,
64 .Nm EC_GROUP_get_curve_GF2m ,
65 .Nm EC_get_builtin_curves
66 .Nd create and destroy EC_GROUP objects
72 .Fa "const EC_METHOD *meth"
79 .Fo EC_GROUP_clear_free
83 .Fo EC_GROUP_new_curve_GFp
90 .Fo EC_GROUP_new_curve_GF2m
97 .Fo EC_GROUP_new_by_curve_name
101 .Fo EC_GROUP_set_curve_GFp
102 .Fa "EC_GROUP *group"
103 .Fa "const BIGNUM *p"
104 .Fa "const BIGNUM *a"
105 .Fa "const BIGNUM *b"
109 .Fo EC_GROUP_get_curve_GFp
110 .Fa "const EC_GROUP *group"
117 .Fo EC_GROUP_set_curve_GF2m
118 .Fa "EC_GROUP *group"
119 .Fa "const BIGNUM *p"
120 .Fa "const BIGNUM *a"
121 .Fa "const BIGNUM *b"
125 .Fo EC_GROUP_get_curve_GF2m
126 .Fa "const EC_GROUP *group"
133 .Fo EC_get_builtin_curves
134 .Fa "EC_builtin_curve *r"
138 The EC library provides functions for performing operations on
139 elliptic curves over finite fields.
140 In general, an elliptic curve satisfies an equation of the form:
142 .Dl y^2 = x^3 + ax + b
144 Within the library there are two forms of elliptic curves that are of
146 The first form is those defined over the prime field Fp.
147 The elements of Fp are the integers 0 to p-1, where
150 This gives us a revised elliptic curve equation as follows:
152 .Dl y^2 mod p = x^3 + ax + b mod p
154 The second form is those defined over a binary field F2^m where the
155 elements of the field are integers of length at most m bits.
156 For this form the elliptic curve equation is modified to:
158 .Dl y^2 + xy = x^3 + ax^2 + b (where b != 0)
160 Operations in a binary field are performed relative to an irreducible
162 All such curves with OpenSSL use a trinomial or a pentanomial for this
167 structure is used to represent the definition of an elliptic curve.
168 A new curve can be constructed by calling
170 using the implementation provided by
173 .Xr EC_GFp_simple_method 3 ) .
174 It is then necessary to call either
175 .Fn EC_GROUP_set_curve_GFp
177 .Fn EC_GROUP_set_curve_GF2m
178 as appropriate to create a curve defined over Fp or over F2^m, respectively.
180 .Fn EC_GROUP_set_curve_GFp
181 sets the curve parameters
186 for a curve over Fp stored in
188 .Fn EC_group_get_curve_GFp
189 obtains the previously set curve parameters.
191 .Fn EC_GROUP_set_curve_GF2m
192 sets the equivalent curve parameters for a curve over F2^m.
195 represents the irreducible polynomial - each bit represents a term in
197 Therefore there will either be three or five bits set dependent on
198 whether the polynomial is a trinomial or a pentanomial.
199 .Fn EC_group_get_curve_GF2m
200 obtains the previously set curve parameters.
203 .Fn EC_GROUP_new_curve_GFp
205 .Fn EC_GROUP_new_curve_GF2m
206 are shortcuts for calling
209 .Fn EC_GROUP_set_curve_*
211 An appropriate default implementation method will be used.
213 Whilst the library can be used to create any curve using the functions
214 described above, there are also a number of predefined curves that are
216 In order to obtain a list of all of the predefined curves, call the
218 .Fn EC_get_builtin_curves .
221 should be an array of
225 The function will populate the
227 array with information about the builtin curves.
230 is less than the total number of curves available, then the first
232 curves will be returned.
233 Otherwise the total number of curves will be provided.
234 The return value is the total number of curves available (whether that
235 number has been populated in
243 to 0, will do nothing other than return the total number of curves
247 structure is defined as follows:
257 item has a unique integer ID
259 and a human readable comment string describing the curve.
261 In order to construct a builtin curve use the function
262 .Fn EC_GROUP_new_by_curve_name
265 of the curve to be constructed.
268 frees the memory associated with the
274 pointer, no action occurs.
276 .Fn EC_GROUP_clear_free
277 destroys any sensitive data held within the
279 and then frees its memory.
284 pointer, no action occurs.
288 functions return a pointer to the newly constructed group or
292 .Fn EC_get_builtin_curves
293 returns the number of builtin curves that are available.
295 .Fn EC_GROUP_set_curve_GFp ,
296 .Fn EC_GROUP_get_curve_GFp ,
297 .Fn EC_GROUP_set_curve_GF2m ,
299 .Fn EC_GROUP_get_curve_GF2m
300 return 1 on success or 0 on error.
302 .Xr d2i_ECPKParameters 3 ,
303 .Xr EC_GFp_simple_method 3 ,
304 .Xr EC_GROUP_copy 3 ,