summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EC_GROUP_new.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/EC_GROUP_new.3')
-rw-r--r--src/lib/libcrypto/man/EC_GROUP_new.3240
1 files changed, 240 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EC_GROUP_new.3 b/src/lib/libcrypto/man/EC_GROUP_new.3
new file mode 100644
index 0000000000..00690dfc07
--- /dev/null
+++ b/src/lib/libcrypto/man/EC_GROUP_new.3
@@ -0,0 +1,240 @@
1.Dd $Mdocdate: November 2 2016 $
2.Dt EC_GROUP_NEW 3
3.Os
4.Sh NAME
5.Nm EC_GROUP_new ,
6.Nm EC_GROUP_free ,
7.Nm EC_GROUP_clear_free ,
8.Nm EC_GROUP_new_curve_GFp ,
9.Nm EC_GROUP_new_curve_GF2m ,
10.Nm EC_GROUP_new_by_curve_name ,
11.Nm EC_GROUP_set_curve_GFp ,
12.Nm EC_GROUP_get_curve_GFp ,
13.Nm EC_GROUP_set_curve_GF2m ,
14.Nm EC_GROUP_get_curve_GF2m ,
15.Nm EC_get_builtin_curves
16.Nd create and destroy EC_GROUP objects
17.Sh SYNOPSIS
18.In openssl/ec.h
19.In openssl/bn.h
20.Ft EC_GROUP *
21.Fo EC_GROUP_new
22.Fa "const EC_METHOD *meth"
23.Fc
24.Ft void
25.Fo EC_GROUP_free
26.Fa "EC_GROUP *group"
27.Fc
28.Ft void
29.Fo EC_GROUP_clear_free
30.Fa "EC_GROUP *group"
31.Fc
32.Ft EC_GROUP *
33.Fo EC_GROUP_new_curve_GFp
34.Fa "const BIGNUM *p"
35.Fa "const BIGNUM *a"
36.Fa "const BIGNUM *b"
37.Fa "BN_CTX *ctx"
38.Fc
39.Ft EC_GROUP *
40.Fo EC_GROUP_new_curve_GF2m
41.Fa "const BIGNUM *p"
42.Fa "const BIGNUM *a"
43.Fa "const BIGNUM *b"
44.Fa "BN_CTX *ctx"
45.Fc
46.Ft EC_GROUP *
47.Fo EC_GROUP_new_by_curve_name
48.Fa "int nid"
49.Fc
50.Ft int
51.Fo EC_GROUP_set_curve_GFp
52.Fa "EC_GROUP *group"
53.Fa "const BIGNUM *p"
54.Fa "const BIGNUM *a"
55.Fa "const BIGNUM *b"
56.Fa "BN_CTX *ctx"
57.Fc
58.Ft int
59.Fo EC_GROUP_get_curve_GFp
60.Fa "const EC_GROUP *group"
61.Fa "BIGNUM *p"
62.Fa "BIGNUM *a"
63.Fa "BIGNUM *b"
64.Fa "BN_CTX *ctx"
65.Fc
66.Ft int
67.Fo EC_GROUP_set_curve_GF2m
68.Fa "EC_GROUP *group"
69.Fa "const BIGNUM *p"
70.Fa "const BIGNUM *a"
71.Fa "const BIGNUM *b"
72.Fa "BN_CTX *ctx"
73.Fc
74.Ft int
75.Fo EC_GROUP_get_curve_GF2m
76.Fa "const EC_GROUP *group"
77.Fa "BIGNUM *p"
78.Fa "BIGNUM *a"
79.Fa "BIGNUM *b"
80.Fa "BN_CTX *ctx"
81.Fc
82.Ft size_t
83.Fo EC_get_builtin_curves
84.Fa "EC_builtin_curve *r"
85.Fa "size_t nitems"
86.Fc
87.Sh DESCRIPTION
88Within the library there are two forms of elliptic curves that are of
89interest.
90The first form is those defined over the prime field Fp.
91The elements of Fp are the integers 0 to p-1, where
92.Fa p
93is a prime number.
94This gives us a revised elliptic curve equation as follows:
95.Pp
96.Dl y^2 mod p = x^3 +ax + b mod p
97.Pp
98The second form is those defined over a binary field F2^m where the
99elements of the field are integers of length at most m bits.
100For this form the elliptic curve equation is modified to:
101.Pp
102.Dl y^2 + xy = x^3 + ax^2 + b (where b != 0)
103.Pp
104Operations in a binary field are performed relative to an irreducible
105polynomial.
106All such curves with OpenSSL use a trinomial or a pentanomial for this
107parameter.
108.Pp
109A new curve can be constructed by calling
110.Fn EC_GROUP_new ,
111using the implementation provided by
112.Fa meth
113(see
114.Xr EC_GFp_simple_method 3 ) .
115It is then necessary to call either
116.Fn EC_GROUP_set_curve_GFp
117or
118.Fn EC_GROUP_set_curve_GF2m
119as appropriate to create a curve defined over Fp or over F2^m, respectively.
120.Pp
121.Fn EC_GROUP_set_curve_GFp
122sets the curve parameters
123.Fa p ,
124.Fa a ,
125and
126.Fa b
127for a curve over Fp stored in
128.Fa group .
129.Fn EC_group_get_curve_GFp
130obtains the previously set curve parameters.
131.Pp
132.Fn EC_GROUP_set_curve_GF2m
133sets the equivalent curve parameters for a curve over F2^m.
134In this case
135.Fa p
136represents the irreducible polynomial - each bit represents a term in
137the polynomial.
138Therefore there will either be three or five bits set dependent on
139whether the polynomial is a trinomial or a pentanomial.
140.Fn EC_group_get_curve_GF2m
141obtains the previously set curve parameters.
142.Pp
143The functions
144.Fn EC_GROUP_new_curve_GFp
145and
146.Fn EC_GROUP_new_curve_GF2m
147are shortcuts for calling
148.Fn EC_GROUP_new
149and the appropriate
150.Fn EC_GROUP_set_curve_*
151function.
152An appropriate default implementation method will be used.
153.Pp
154Whilst the library can be used to create any curve using the functions
155described above, there are also a number of predefined curves that are
156available.
157In order to obtain a list of all of the predefined curves, call the
158function
159.Fn EC_get_builtin_curves .
160The parameter
161.Fa r
162should be an array of
163.Vt EC_builtin_cure
164structures of size
165.Fa nitems .
166The function will populate the
167.Fa r
168array with information about the builtin curves.
169If
170.Fa nitems
171is less than the total number of curves available, then the first
172.Fa nitems
173curves will be returned.
174Otherwise the total number of curves will be provided.
175The return value is the total number of curves available (whether that
176number has been populated in
177.Fa r
178or not).
179Passing a
180.Dv NULL
181.Fa r ,
182or setting
183.Fa nitems
184to 0, will do nothing other than return the total number of curves
185available.
186The
187.Vt EC_builtin_curve
188structure is defined as follows:
189.Bd -literal
190typedef struct {
191 int nid;
192 const char *comment;
193} EC_builtin_curve;
194.Ed
195.Pp
196Each
197.Vt EC_builtin_curve
198item has a unique integer id
199.Pq Fa nid
200and a human readable comment string describing the curve.
201.Pp
202In order to construct a builtin curve use the function
203.Fn EC_GROUP_new_by_curve_name
204and provide the
205.Fa nid
206of the curve to be constructed.
207.Pp
208.Fn EC_GROUP_free
209frees the memory associated with the
210.Vt EC_GROUP .
211.Pp
212.Fn EC_GROUP_clear_free
213destroys any sensitive data held within the
214.Vt EC_GROUP
215and then frees its memory.
216.Sh RETURN VALUES
217All
218.Fn EC_GROUP_new*
219functions return a pointer to the newly constructed group or
220.Dv NULL
221on error.
222.Pp
223.Fn EC_get_builtin_curves
224returns the number of builtin curves that are available.
225.Pp
226.Fn EC_GROUP_set_curve_GFp ,
227.Fn EC_GROUP_get_curve_GFp ,
228.Fn EC_GROUP_set_curve_GF2m ,
229and
230.Fn EC_GROUP_get_curve_GF2m
231return 1 on success or 0 on error.
232.Sh SEE ALSO
233.Xr crypto 3 ,
234.Xr d2i_ECPKParameters 3 ,
235.Xr ec 3 ,
236.Xr EC_GFp_simple_method 3 ,
237.Xr EC_GROUP_copy 3 ,
238.Xr EC_KEY_new 3 ,
239.Xr EC_POINT_add 3 ,
240.Xr EC_POINT_new 3