summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EC_KEY_new.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/EC_KEY_new.3')
-rw-r--r--src/lib/libcrypto/man/EC_KEY_new.3411
1 files changed, 411 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EC_KEY_new.3 b/src/lib/libcrypto/man/EC_KEY_new.3
new file mode 100644
index 0000000000..dcc55fa973
--- /dev/null
+++ b/src/lib/libcrypto/man/EC_KEY_new.3
@@ -0,0 +1,411 @@
1.Dd $Mdocdate: November 2 2016 $
2.Dt EC_KEY_NEW 3
3.Os
4.Sh NAME
5.Nm EC_KEY_new ,
6.Nm EC_KEY_get_flags ,
7.Nm EC_KEY_set_flags ,
8.Nm EC_KEY_clear_flags ,
9.Nm EC_KEY_new_by_curve_name ,
10.Nm EC_KEY_free ,
11.Nm EC_KEY_copy ,
12.Nm EC_KEY_dup ,
13.Nm EC_KEY_up_ref ,
14.Nm EC_KEY_get0_group ,
15.Nm EC_KEY_set_group ,
16.Nm EC_KEY_get0_private_key ,
17.Nm EC_KEY_set_private_key ,
18.Nm EC_KEY_get0_public_key ,
19.Nm EC_KEY_set_public_key ,
20.Nm EC_KEY_get_enc_flags ,
21.Nm EC_KEY_set_enc_flags ,
22.Nm EC_KEY_get_conv_form ,
23.Nm EC_KEY_set_conv_form ,
24.Nm EC_KEY_get_key_method_data ,
25.Nm EC_KEY_insert_key_method_data ,
26.Nm EC_KEY_set_asn1_flag ,
27.Nm EC_KEY_precompute_mult ,
28.Nm EC_KEY_generate_key ,
29.Nm EC_KEY_check_key ,
30.Nm EC_KEY_set_public_key_affine_coordinates
31.Nd create, destroy and manipulate EC_KEY objects
32.Sh SYNOPSIS
33.In openssl/ec.h
34.In openssl/bn.h
35.Ft EC_KEY *
36.Fn EC_KEY_new void
37.Ft int
38.Fo EC_KEY_get_flags
39.Fa "const EC_KEY *key"
40.Fc
41.Ft void
42.Fo EC_KEY_set_flags
43.Fa "EC_KEY *key"
44.Fa "int flags"
45.Fc
46.Ft void
47.Fo EC_KEY_clear_flags
48.Fa "EC_KEY *key"
49.Fa "int flags"
50.Fc
51.Ft EC_KEY *
52.Fo EC_KEY_new_by_curve_name
53.Fa "int nid"
54.Fc
55.Ft void
56.Fo EC_KEY_free
57.Fa "EC_KEY *key"
58.Fc
59.Ft EC_KEY *
60.Fo EC_KEY_copy
61.Fa "EC_KEY *dst"
62.Fa "const EC_KEY *src"
63.Fc
64.Ft EC_KEY *
65.Fo EC_KEY_dup
66.Fa "const EC_KEY *src"
67.Fc
68.Ft int
69.Fo EC_KEY_up_ref
70.Fa "EC_KEY *key"
71.Fc
72.Ft const EC_GROUP *
73.Fo EC_KEY_get0_group
74.Fa "const EC_KEY *key"
75.Fc
76.Ft int
77.Fo EC_KEY_set_group
78.Fa "EC_KEY *key"
79.Fa "const EC_GROUP *group"
80.Fc
81.Ft const BIGNUM *
82.Fo EC_KEY_get0_private_key
83.Fa "const EC_KEY *key"
84.Fc
85.Ft int
86.Fo EC_KEY_set_private_key
87.Fa "EC_KEY *key"
88.Fa "const BIGNUM *prv"
89.Fc
90.Ft const EC_POINT *
91.Fo EC_KEY_get0_public_key
92.Fa "const EC_KEY *key"
93.Fc
94.Ft int
95.Fo EC_KEY_set_public_key
96.Fa "EC_KEY *key"
97.Fa "const EC_POINT *pub"
98.Fc
99.Ft unsigned int
100.Fo EC_KEY_get_enc_flags
101.Fa "const EC_KEY *key"
102.Fc
103.Ft void
104.Fo EC_KEY_set_enc_flags
105.Fa "EC_KEY *key"
106.Fa "unsigned int flags"
107.Fc
108.Ft point_conversion_form_t
109.Fo EC_KEY_get_conv_form
110.Fa "const EC_KEY *key"
111.Fc
112.Ft void
113.Fo EC_KEY_set_conv_form
114.Fa "EC_KEY *key"
115.Fa "point_conversion_form_t cform"
116.Fc
117.Ft void *
118.Fo EC_KEY_get_key_method_data
119.Fa "EC_KEY *key"
120.Fa "void *(*dup_func)(void *)"
121.Fa "void (*free_func)(void *)"
122.Fa "void (*clear_free_func)(void *)"
123.Fc
124.Ft void
125.Fo EC_KEY_insert_key_method_data
126.Fa "EC_KEY *key"
127.Fa "void *data"
128.Fa "void *(*dup_func)(void *)"
129.Fa "void (*free_func)(void *)"
130.Fa "void (*clear_free_func)(void *)"
131.Fc
132.Ft void
133.Fo EC_KEY_set_asn1_flag
134.Fa "EC_KEY *key"
135.Fa "int asn1_flag"
136.Fc
137.Ft int
138.Fo EC_KEY_precompute_mult
139.Fa "EC_KEY *key"
140.Fa "BN_CTX *ctx"
141.Fc
142.Ft int
143.Fo EC_KEY_generate_key
144.Fa "EC_KEY *key"
145.Fc
146.Ft int
147.Fo EC_KEY_check_key
148.Fa "const EC_KEY *key"
149.Fc
150.Ft int
151.Fo EC_KEY_set_public_key_affine_coordinates
152.Fa "EC_KEY *key"
153.Fa "BIGNUM *x"
154.Fa "BIGNUM *y"
155.Fc
156.Sh DESCRIPTION
157An
158.Vt EC_KEY
159represents a public key and (optionally) an associated private key.
160A new
161.Vt EC_KEY
162(with no associated curve) can be constructed by calling
163.Fn EC_KEY_new .
164The reference count for the newly created
165.Vt EC_KEY
166is initially set to 1.
167A curve can be associated with the
168.Vt EC_KEY
169by calling
170.Fn EC_KEY_set_group .
171.Pp
172Alternatively a new
173.Vt EC_KEY
174can be constructed by calling
175.Fn EC_KEY_new_by_curve_name
176and supplying the
177.Fa nid
178of the associated curve.
179Refer to
180.Xr EC_GROUP_new 3
181for a description of curve names.
182This function simply wraps calls to
183.Fn EC_KEY_new
184and
185.Fn EC_GROUP_new_by_curve_name .
186.Pp
187Calling
188.Fn EC_KEY_free
189decrements the reference count for the
190.Vt EC_KEY
191object, and if it has dropped to zero, then frees the memory associated
192with it.
193.Pp
194.Fn EC_KEY_copy
195copies the contents of the
196.Vt EC_KEY
197in
198.Fa src
199into
200.Fa dst .
201.Pp
202.Fn EC_KEY_dup
203creates a new
204.Vt EC_KEY
205object and copies
206.Fa src
207into it.
208.Pp
209.Fn EC_KEY_up_ref
210increments the reference count associated with the
211.Vt EC_KEY
212object.
213.Pp
214.Fn EC_KEY_generate_key
215generates a new public and private key for the supplied
216.Fa key
217object.
218.Fa key
219must have an
220.Vt EC_GROUP
221object associated with it before calling this function.
222The private key is a random integer (0 < priv_key < order, where order
223is the order of the
224.Vt EC_GROUP
225object).
226The public key is an
227.Vt EC_POINT
228on the curve calculated by multiplying the generator for the curve
229by the private key.
230.Pp
231.Fn EC_KEY_check_key
232performs various sanity checks on the
233.Vt EC_KEY
234object to confirm that it is valid.
235.Pp
236.Fn EC_KEY_set_public_key_affine_coordinates
237sets the public key for
238.Fa key
239based on its affine coordinates, i.e. it constructs an
240.Vt EC_POINT
241object based on the supplied
242.Fa x
243and
244.Fa y
245values and sets the public key to be this
246.Vt EC_POINT .
247It also performs certain sanity checks on the key to confirm that
248it is valid.
249.Pp
250The functions
251.Fn EC_KEY_get0_group ,
252.Fn EC_KEY_set_group ,
253.Fn EC_KEY_get0_private_key ,
254.Fn EC_KEY_set_private_key ,
255.Fn EC_KEY_get0_public_key ,
256and
257.Fn EC_KEY_set_public_key
258get and set the
259.Vt EC_GROUP
260object, the private key and the
261.Vt EC_POINT
262public key for the
263.Fa key ,
264respectively.
265.Pp
266The functions
267.Fn EC_KEY_get_enc_flags
268and
269.Fn EC_KEY_set_enc_flags
270get and set the value of the encoding flags for the
271.Fa key .
272There are two encoding flags currently defined:
273.Dv EC_PKEY_NO_PARAMETERS
274and
275.Dv EC_PKEY_NO_PUBKEY .
276These flags define the behaviour of how the
277.Fa key
278is converted into ASN1 in a call to
279.Fn i2d_ECPrivateKey .
280If
281.Dv EC_PKEY_NO_PARAMETERS
282is set then the public parameters for the curve
283are not encoded along with the private key.
284If
285.Dv EC_PKEY_NO_PUBKEY
286is set then the public key is not encoded along with the private
287key.
288.Pp
289The functions
290.Fn EC_KEY_get_conv_form
291and
292.Fn EC_KEY_set_conv_form
293get and set the point_conversion_form for the
294.Fa key .
295For a description of point_conversion_forms please refer to
296.Xr EC_POINT_new 3 .
297.Pp
298.Fn EC_KEY_insert_key_method_data
299and
300.Fn EC_KEY_get_key_method_data
301enable the caller to associate arbitrary additional data specific
302to the elliptic curve scheme being used with the
303.Vt EC_KEY
304object.
305This data is treated as a "black box" by the ec library.
306The data to be stored by
307.Fn EC_KEY_insert_key_method_data
308is provided in the
309.Fa data
310parameter, which must have associated functions for duplicating, freeing
311and "clear_freeing" the data item.
312If a subsequent
313.Fn EC_KEY_get_key_method_data
314call is issued, the functions for duplicating, freeing and
315"clear_freeing" the data item must be provided again, and they must
316be the same as they were when the data item was inserted.
317.Pp
318.Fn EC_KEY_set_flags
319sets the flags in the
320.Fa flags
321parameter on the
322.Vt EC_KEY
323object.
324Any flags that are already set are left set.
325The currently defined standard flags are
326.Dv EC_FLAG_NON_FIPS_ALLOW
327and
328.Dv EC_FLAG_FIPS_CHECKED .
329In addition there is the flag
330.Dv EC_FLAG_COFACTOR_ECDH
331which is specific to ECDH and is defined in
332.In openssl/ecdh.h .
333.Fn EC_KEY_get_flags
334returns the current flags that are set for this
335.Vt EC_KEY .
336.Fn EC_KEY_clear_flags
337clears the flags indicated by the
338.Fa flags
339parameter.
340All other flags are left in their existing state.
341.Pp
342.Fn EC_KEY_set_asn1_flag
343sets the asn1_flag on the underlying
344.Vt EC_GROUP
345object (if set).
346Refer to
347.Xr EC_GROUP_copy 3
348for further information on the asn1_flag.
349.Pp
350.Fn EC_KEY_precompute_mult
351stores multiples of the underlying
352.Vt EC_GROUP
353generator for faster point multiplication.
354See also
355.Xr EC_POINT_add 3 .
356.Sh RETURN VALUES
357.Fn EC_KEY_new ,
358.Fn EC_KEY_new_by_curve_name ,
359and
360.Fn EC_KEY_dup
361return a pointer to the newly created
362.Vt EC_KEY object or
363.Dv NULL
364on error.
365.Pp
366.Fn EC_KEY_get_flags
367returns the flags associated with the
368.Vt EC_KEY object.
369.Pp
370.Fn EC_KEY_copy
371returns a pointer to the destination key or
372.Dv NULL
373on error.
374.Pp
375.Fn EC_KEY_up_ref ,
376.Fn EC_KEY_set_group ,
377.Fn EC_KEY_set_private_key ,
378.Fn EC_KEY_set_public_key ,
379.Fn EC_KEY_precompute_mult ,
380.Fn EC_KEY_generate_key ,
381.Fn EC_KEY_check_key ,
382and
383.Fn EC_KEY_set_public_key_affine_coordinates
384return 1 on success or 0 on error.
385.Pp
386.Fn EC_KEY_get0_group
387returns the
388.Vt EC_GROUP
389associated with the
390.Vt EC_KEY .
391.Pp
392.Fn EC_KEY_get0_private_key
393returns the private key associated with the
394.Vt EC_KEY .
395.Pp
396.Fn EC_KEY_get_enc_flags
397returns the value of the current encoding flags for the
398.Vt EC_KEY .
399.Pp
400.Fn EC_KEY_get_conv_form
401returns the point_conversion_form for the
402.Vt EC_KEY .
403.Sh SEE ALSO
404.Xr crypto 3 ,
405.Xr d2i_ECPKParameters 3 ,
406.Xr ec 3 ,
407.Xr EC_GFp_simple_method 3 ,
408.Xr EC_GROUP_copy 3 ,
409.Xr EC_GROUP_new 3 ,
410.Xr EC_POINT_add 3 ,
411.Xr EC_POINT_new 3