diff options
Diffstat (limited to 'src/lib/libcrypto/man/EC_KEY_new.3')
-rw-r--r-- | src/lib/libcrypto/man/EC_KEY_new.3 | 411 |
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 | ||
157 | An | ||
158 | .Vt EC_KEY | ||
159 | represents a public key and (optionally) an associated private key. | ||
160 | A new | ||
161 | .Vt EC_KEY | ||
162 | (with no associated curve) can be constructed by calling | ||
163 | .Fn EC_KEY_new . | ||
164 | The reference count for the newly created | ||
165 | .Vt EC_KEY | ||
166 | is initially set to 1. | ||
167 | A curve can be associated with the | ||
168 | .Vt EC_KEY | ||
169 | by calling | ||
170 | .Fn EC_KEY_set_group . | ||
171 | .Pp | ||
172 | Alternatively a new | ||
173 | .Vt EC_KEY | ||
174 | can be constructed by calling | ||
175 | .Fn EC_KEY_new_by_curve_name | ||
176 | and supplying the | ||
177 | .Fa nid | ||
178 | of the associated curve. | ||
179 | Refer to | ||
180 | .Xr EC_GROUP_new 3 | ||
181 | for a description of curve names. | ||
182 | This function simply wraps calls to | ||
183 | .Fn EC_KEY_new | ||
184 | and | ||
185 | .Fn EC_GROUP_new_by_curve_name . | ||
186 | .Pp | ||
187 | Calling | ||
188 | .Fn EC_KEY_free | ||
189 | decrements the reference count for the | ||
190 | .Vt EC_KEY | ||
191 | object, and if it has dropped to zero, then frees the memory associated | ||
192 | with it. | ||
193 | .Pp | ||
194 | .Fn EC_KEY_copy | ||
195 | copies the contents of the | ||
196 | .Vt EC_KEY | ||
197 | in | ||
198 | .Fa src | ||
199 | into | ||
200 | .Fa dst . | ||
201 | .Pp | ||
202 | .Fn EC_KEY_dup | ||
203 | creates a new | ||
204 | .Vt EC_KEY | ||
205 | object and copies | ||
206 | .Fa src | ||
207 | into it. | ||
208 | .Pp | ||
209 | .Fn EC_KEY_up_ref | ||
210 | increments the reference count associated with the | ||
211 | .Vt EC_KEY | ||
212 | object. | ||
213 | .Pp | ||
214 | .Fn EC_KEY_generate_key | ||
215 | generates a new public and private key for the supplied | ||
216 | .Fa key | ||
217 | object. | ||
218 | .Fa key | ||
219 | must have an | ||
220 | .Vt EC_GROUP | ||
221 | object associated with it before calling this function. | ||
222 | The private key is a random integer (0 < priv_key < order, where order | ||
223 | is the order of the | ||
224 | .Vt EC_GROUP | ||
225 | object). | ||
226 | The public key is an | ||
227 | .Vt EC_POINT | ||
228 | on the curve calculated by multiplying the generator for the curve | ||
229 | by the private key. | ||
230 | .Pp | ||
231 | .Fn EC_KEY_check_key | ||
232 | performs various sanity checks on the | ||
233 | .Vt EC_KEY | ||
234 | object to confirm that it is valid. | ||
235 | .Pp | ||
236 | .Fn EC_KEY_set_public_key_affine_coordinates | ||
237 | sets the public key for | ||
238 | .Fa key | ||
239 | based on its affine coordinates, i.e. it constructs an | ||
240 | .Vt EC_POINT | ||
241 | object based on the supplied | ||
242 | .Fa x | ||
243 | and | ||
244 | .Fa y | ||
245 | values and sets the public key to be this | ||
246 | .Vt EC_POINT . | ||
247 | It also performs certain sanity checks on the key to confirm that | ||
248 | it is valid. | ||
249 | .Pp | ||
250 | The 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 , | ||
256 | and | ||
257 | .Fn EC_KEY_set_public_key | ||
258 | get and set the | ||
259 | .Vt EC_GROUP | ||
260 | object, the private key and the | ||
261 | .Vt EC_POINT | ||
262 | public key for the | ||
263 | .Fa key , | ||
264 | respectively. | ||
265 | .Pp | ||
266 | The functions | ||
267 | .Fn EC_KEY_get_enc_flags | ||
268 | and | ||
269 | .Fn EC_KEY_set_enc_flags | ||
270 | get and set the value of the encoding flags for the | ||
271 | .Fa key . | ||
272 | There are two encoding flags currently defined: | ||
273 | .Dv EC_PKEY_NO_PARAMETERS | ||
274 | and | ||
275 | .Dv EC_PKEY_NO_PUBKEY . | ||
276 | These flags define the behaviour of how the | ||
277 | .Fa key | ||
278 | is converted into ASN1 in a call to | ||
279 | .Fn i2d_ECPrivateKey . | ||
280 | If | ||
281 | .Dv EC_PKEY_NO_PARAMETERS | ||
282 | is set then the public parameters for the curve | ||
283 | are not encoded along with the private key. | ||
284 | If | ||
285 | .Dv EC_PKEY_NO_PUBKEY | ||
286 | is set then the public key is not encoded along with the private | ||
287 | key. | ||
288 | .Pp | ||
289 | The functions | ||
290 | .Fn EC_KEY_get_conv_form | ||
291 | and | ||
292 | .Fn EC_KEY_set_conv_form | ||
293 | get and set the point_conversion_form for the | ||
294 | .Fa key . | ||
295 | For 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 | ||
299 | and | ||
300 | .Fn EC_KEY_get_key_method_data | ||
301 | enable the caller to associate arbitrary additional data specific | ||
302 | to the elliptic curve scheme being used with the | ||
303 | .Vt EC_KEY | ||
304 | object. | ||
305 | This data is treated as a "black box" by the ec library. | ||
306 | The data to be stored by | ||
307 | .Fn EC_KEY_insert_key_method_data | ||
308 | is provided in the | ||
309 | .Fa data | ||
310 | parameter, which must have associated functions for duplicating, freeing | ||
311 | and "clear_freeing" the data item. | ||
312 | If a subsequent | ||
313 | .Fn EC_KEY_get_key_method_data | ||
314 | call is issued, the functions for duplicating, freeing and | ||
315 | "clear_freeing" the data item must be provided again, and they must | ||
316 | be the same as they were when the data item was inserted. | ||
317 | .Pp | ||
318 | .Fn EC_KEY_set_flags | ||
319 | sets the flags in the | ||
320 | .Fa flags | ||
321 | parameter on the | ||
322 | .Vt EC_KEY | ||
323 | object. | ||
324 | Any flags that are already set are left set. | ||
325 | The currently defined standard flags are | ||
326 | .Dv EC_FLAG_NON_FIPS_ALLOW | ||
327 | and | ||
328 | .Dv EC_FLAG_FIPS_CHECKED . | ||
329 | In addition there is the flag | ||
330 | .Dv EC_FLAG_COFACTOR_ECDH | ||
331 | which is specific to ECDH and is defined in | ||
332 | .In openssl/ecdh.h . | ||
333 | .Fn EC_KEY_get_flags | ||
334 | returns the current flags that are set for this | ||
335 | .Vt EC_KEY . | ||
336 | .Fn EC_KEY_clear_flags | ||
337 | clears the flags indicated by the | ||
338 | .Fa flags | ||
339 | parameter. | ||
340 | All other flags are left in their existing state. | ||
341 | .Pp | ||
342 | .Fn EC_KEY_set_asn1_flag | ||
343 | sets the asn1_flag on the underlying | ||
344 | .Vt EC_GROUP | ||
345 | object (if set). | ||
346 | Refer to | ||
347 | .Xr EC_GROUP_copy 3 | ||
348 | for further information on the asn1_flag. | ||
349 | .Pp | ||
350 | .Fn EC_KEY_precompute_mult | ||
351 | stores multiples of the underlying | ||
352 | .Vt EC_GROUP | ||
353 | generator for faster point multiplication. | ||
354 | See also | ||
355 | .Xr EC_POINT_add 3 . | ||
356 | .Sh RETURN VALUES | ||
357 | .Fn EC_KEY_new , | ||
358 | .Fn EC_KEY_new_by_curve_name , | ||
359 | and | ||
360 | .Fn EC_KEY_dup | ||
361 | return a pointer to the newly created | ||
362 | .Vt EC_KEY object or | ||
363 | .Dv NULL | ||
364 | on error. | ||
365 | .Pp | ||
366 | .Fn EC_KEY_get_flags | ||
367 | returns the flags associated with the | ||
368 | .Vt EC_KEY object. | ||
369 | .Pp | ||
370 | .Fn EC_KEY_copy | ||
371 | returns a pointer to the destination key or | ||
372 | .Dv NULL | ||
373 | on 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 , | ||
382 | and | ||
383 | .Fn EC_KEY_set_public_key_affine_coordinates | ||
384 | return 1 on success or 0 on error. | ||
385 | .Pp | ||
386 | .Fn EC_KEY_get0_group | ||
387 | returns the | ||
388 | .Vt EC_GROUP | ||
389 | associated with the | ||
390 | .Vt EC_KEY . | ||
391 | .Pp | ||
392 | .Fn EC_KEY_get0_private_key | ||
393 | returns the private key associated with the | ||
394 | .Vt EC_KEY . | ||
395 | .Pp | ||
396 | .Fn EC_KEY_get_enc_flags | ||
397 | returns the value of the current encoding flags for the | ||
398 | .Vt EC_KEY . | ||
399 | .Pp | ||
400 | .Fn EC_KEY_get_conv_form | ||
401 | returns 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 | ||