update libressl to v2.7.4
[unleashed.git] / lib / libcrypto / man / d2i_ECPKParameters.3
blob3637786b6b255a870472f9242a611ad7ea92bcd4
1 .\"     $OpenBSD: d2i_ECPKParameters.3,v 1.11 2018/03/23 00:09:11 schwarze Exp $
2 .\"     OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3 .\"
4 .\" This file is a derived work.
5 .\" The changes are covered by the following Copyright and license:
6 .\"
7 .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8 .\"
9 .\" Permission to use, copy, modify, and distribute this software for any
10 .\" purpose with or without fee is hereby granted, provided that the above
11 .\" copyright notice and this permission notice appear in all copies.
12 .\"
13 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 .\"
21 .\" The original file was written by Matt Caswell <matt@openssl.org>.
22 .\" Copyright (c) 2013, 2015 The OpenSSL Project.  All rights reserved.
23 .\"
24 .\" Redistribution and use in source and binary forms, with or without
25 .\" modification, are permitted provided that the following conditions
26 .\" are met:
27 .\"
28 .\" 1. Redistributions of source code must retain the above copyright
29 .\"    notice, this list of conditions and the following disclaimer.
30 .\"
31 .\" 2. Redistributions in binary form must reproduce the above copyright
32 .\"    notice, this list of conditions and the following disclaimer in
33 .\"    the documentation and/or other materials provided with the
34 .\"    distribution.
35 .\"
36 .\" 3. All advertising materials mentioning features or use of this
37 .\"    software must display the following acknowledgment:
38 .\"    "This product includes software developed by the OpenSSL Project
39 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 .\"
41 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 .\"    endorse or promote products derived from this software without
43 .\"    prior written permission. For written permission, please contact
44 .\"    openssl-core@openssl.org.
45 .\"
46 .\" 5. Products derived from this software may not be called "OpenSSL"
47 .\"    nor may "OpenSSL" appear in their names without prior written
48 .\"    permission of the OpenSSL Project.
49 .\"
50 .\" 6. Redistributions of any form whatsoever must retain the following
51 .\"    acknowledgment:
52 .\"    "This product includes software developed by the OpenSSL Project
53 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 .\"
55 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
67 .\"
68 .Dd $Mdocdate: March 23 2018 $
69 .Dt D2I_ECPKPARAMETERS 3
70 .Os
71 .Sh NAME
72 .Nm d2i_ECPKParameters ,
73 .Nm i2d_ECPKParameters ,
74 .Nm d2i_ECPKParameters_bio ,
75 .Nm i2d_ECPKParameters_bio ,
76 .Nm d2i_ECPKParameters_fp ,
77 .Nm i2d_ECPKParameters_fp ,
78 .Nm d2i_ECParameters ,
79 .Nm i2d_ECParameters ,
80 .Nm ECParameters_dup ,
81 .Nm d2i_ECPrivateKey ,
82 .Nm i2d_ECPrivateKey ,
83 .Nm d2i_ECPrivateKey_bio ,
84 .Nm i2d_ECPrivateKey_bio ,
85 .Nm d2i_ECPrivateKey_fp ,
86 .Nm i2d_ECPrivateKey_fp ,
87 .Nm o2i_ECPublicKey ,
88 .Nm i2o_ECPublicKey ,
89 .Nm ECPKParameters_print ,
90 .Nm ECPKParameters_print_fp ,
91 .Nm ECParameters_print ,
92 .Nm ECParameters_print_fp ,
93 .Nm d2i_EC_PUBKEY ,
94 .Nm i2d_EC_PUBKEY ,
95 .Nm d2i_EC_PUBKEY_bio ,
96 .Nm i2d_EC_PUBKEY_bio ,
97 .Nm d2i_EC_PUBKEY_fp ,
98 .Nm i2d_EC_PUBKEY_fp
99 .Nd decode and encode ASN.1 representations of elliptic curve entities
100 .Sh SYNOPSIS
101 .In openssl/ec.h
102 .Ft EC_GROUP *
103 .Fo d2i_ECPKParameters
104 .Fa "EC_GROUP **val_out"
105 .Fa "const unsigned char **des_in"
106 .Fa "long length"
108 .Ft int
109 .Fo i2d_ECPKParameters
110 .Fa "const EC_GROUP *val_in"
111 .Fa "unsigned char **des_out"
113 .Ft EC_GROUP *
114 .Fo d2i_ECPKParameters_bio
115 .Fa "BIO *in_bio"
116 .Fa "EC_GROUP **val_out"
118 .Ft int
119 .Fo i2d_ECPKParameters_bio
120 .Fa "BIO *out_bio"
121 .Fa "EC_GROUP *val_in"
123 .Ft EC_GROUP *
124 .Fo d2i_ECPKParameters_fp
125 .Fa "FILE *in_fp"
126 .Fa "EC_GROUP **val_out"
128 .Ft int
129 .Fo i2d_ECPKParameters_fp
130 .Fa "FILE *out_fp"
131 .Fa "EC_GROUP *val_in"
133 .Ft EC_KEY *
134 .Fo d2i_ECParameters
135 .Fa "EC_KEY **val_out"
136 .Fa "const unsigned char **des_in"
137 .Fa "long length"
139 .Ft int
140 .Fo i2d_ECParameters
141 .Fa "EC_KEY *val_in"
142 .Fa "unsigned char **des_out"
144 .Ft EC_KEY *
145 .Fo ECParameters_dup
146 .Fa "EC_KEY *val_in"
148 .Ft EC_KEY *
149 .Fo d2i_ECPrivateKey
150 .Fa "EC_KEY **val_out"
151 .Fa "const unsigned char **des_in"
152 .Fa "long length"
154 .Ft int
155 .Fo i2d_ECPrivateKey
156 .Fa "EC_KEY *val_in"
157 .Fa "unsigned char **des_out"
159 .Ft EC_KEY *
160 .Fo d2i_ECPrivateKey_bio
161 .Fa "BIO *in_bio"
162 .Fa "EC_KEY **val_out"
164 .Ft int
165 .Fo i2d_ECPrivateKey_bio
166 .Fa "BIO *out_bio"
167 .Fa "EC_KEY *val_in"
169 .Ft EC_KEY *
170 .Fo d2i_ECPrivateKey_fp
171 .Fa "FILE *in_fp"
172 .Fa "EC_KEY **val_out"
174 .Ft int
175 .Fo i2d_ECPrivateKey_fp
176 .Fa "FILE *out_fp"
177 .Fa "EC_KEY *val_in"
179 .Ft EC_KEY *
180 .Fo o2i_ECPublicKey
181 .Fa "EC_KEY **val_out"
182 .Fa "const unsigned char **des_in"
183 .Fa "long length"
185 .Ft int
186 .Fo i2o_ECPublicKey
187 .Fa "EC_KEY *val_in"
188 .Fa "unsigned char **des_out"
190 .Ft int
191 .Fo ECPKParameters_print
192 .Fa "BIO *out_bio"
193 .Fa "const EC_GROUP *val_in"
194 .Fa "int indent"
196 .Ft int
197 .Fo ECPKParameters_print_fp
198 .Fa "FILE *out_fp"
199 .Fa "const EC_GROUP *val_in"
200 .Fa "int indent"
202 .Ft int
203 .Fo ECParameters_print
204 .Fa "BIO *out_bio"
205 .Fa "const EC_KEY *val_in"
207 .Ft int
208 .Fo ECParameters_print_fp
209 .Fa "FILE *out_fp"
210 .Fa "const EC_KEY *val_in"
212 .In openssl/x509.h
213 .Ft EC_KEY *
214 .Fo d2i_EC_PUBKEY
215 .Fa "EC_KEY **val_out"
216 .Fa "const unsigned char **des_in"
217 .Fa "long length"
219 .Ft int
220 .Fo i2d_EC_PUBKEY
221 .Fa "EC_KEY *val_in"
222 .Fa "unsigned char **des_out"
224 .Ft EC_KEY *
225 .Fo d2i_EC_PUBKEY_bio
226 .Fa "BIO *in_bio"
227 .Fa "EC_KEY **val_out"
229 .Ft int
230 .Fo i2d_EC_PUBKEY_bio
231 .Fa "BIO *out_bio"
232 .Fa "EC_KEY *val_in"
234 .Ft EC_KEY *
235 .Fo d2i_EC_PUBKEY_fp
236 .Fa "FILE *in_fp"
237 .Fa "EC_KEY **val_out"
239 .Ft int
240 .Fo i2d_EC_PUBKEY_fp
241 .Fa "FILE *out_fp"
242 .Fa "EC_KEY *val_in"
244 .Sh DESCRIPTION
245 These functions decode and encode elliptic curve keys and parameters.
246 For details about the semantics, examples, caveats, and bugs, see
247 .Xr ASN1_item_d2i 3 .
249 .Fn d2i_ECPKParameters
251 .Fn i2d_ECPKParameters
252 decode and encode the parameters of an elliptic curve.
253 .Fn d2i_ECPKParameters_bio ,
254 .Fn i2d_ECPKParameters_bio ,
255 .Fn d2i_ECPKParameters_fp ,
257 .Fn i2d_ECPKParameters_fp
258 are similar except that they decode or encode using a
259 .Vt BIO
261 .Vt FILE
262 pointer.
263 These four functions are currently implemented as macros.
265 .Fn d2i_ECParameters
266 does the same parsing as
267 .Fn d2i_ECPKParameters
268 but saves the result in the
269 .Fa group
270 field of an
271 .Vt EC_KEY
272 structure.
274 .Fn i2d_ECParameters
275 produces the same output as
276 .Fn i2d_ECPKParameters
277 but uses
278 .Fa val_in->group
279 for input instead of
280 .Fa val_in .
282 .Fn ECParameters_dup
283 allocates and initializes an empty
284 .Vt EC_KEY
285 object and copies the EC parameters from
286 .Fa val_in
287 to it by calling
288 .Fn i2d_ECParameters
290 .Fn d2i_ECParameters .
291 If a private or public key or any flags are present in
292 .Fa val_in ,
293 they are not copied.
295 .Fn d2i_ECPrivateKey
297 .Fn i2d_ECPrivateKey
298 decode and encode an EC private key using an ASN.1
299 .Vt ECPrivateKey
300 structure defined in RFC 5915 section 3 and used for the privateKey
301 field of the ASN.1
302 .Vt PrivateKeyInfo
303 structure defined in RFC 5208 section 5, see
304 .Xr PKCS8_PRIV_KEY_INFO_new 3 .
305 .Fn d2i_ECPrivateKey_bio ,
306 .Fn i2d_ECPrivateKey_bio ,
307 .Fn d2i_ECPrivateKey_fp ,
309 .Fn i2d_ECPrivateKey_fp
310 are similar except that they decode or encode using a
311 .Vt BIO
313 .Vt FILE
314 pointer.
316 .Fn o2i_ECPublicKey
318 .Fn i2o_ECPublicKey
319 decode and encode an EC public key.
320 In contrast to
321 .Xr ASN1_item_d2i 3 ,
322 .Fn o2i_ECPublicKey
323 requires
324 .Fa val_out ,
325 .Pf * Fa val_out ,
327 .Po Pf * Fa val_out Pc Ns -> Ns Fa group
328 to be
329 .Pf non- Dv NULL .
331 .Fn ECPKParameters_print
333 .Fn ECPKParameters_print_fp
334 print human-readable output of the public parameters of the
335 .Vt EC_GROUP
337 .Fa out_bio
339 .Fa out_fp .
340 The output lines are indented by
341 .Fa indent
342 spaces.
344 .Fn ECParameters_print
346 .Fn ECParameters_print_fp
347 print the parameter components of
348 .Fa val_in
350 .Fa out_bio
352 .Fa out_fp .
354 .Fn d2i_EC_PUBKEY
356 .Fn i2d_EC_PUBKEY
357 decode and encode an EC public key using an ASN.1
358 .Vt SubjectPublicKeyInfo
359 structure defined in RFC 5280 section 4.1 and documented in
360 .Xr X509_PUBKEY_new 3 .
361 .Fn d2i_EC_PUBKEY_bio ,
362 .Fn i2d_EC_PUBKEY_bio ,
363 .Fn d2i_EC_PUBKEY_fp ,
365 .Fn i2d_EC_PUBKEY_fp
366 are similar except that they decode or encode using a
367 .Vt BIO
369 .Vt FILE
370 pointer.
371 .Sh RETURN VALUES
372 .Fn d2i_ECPKParameters ,
373 .Fn d2i_ECPKParameters_bio ,
375 .Fn d2i_ECPKParameters_fp
376 return a valid
377 .Vt EC_GROUP
378 structure or
379 .Dv NULL
380 if an error occurs.
382 .Fn d2i_ECParameters ,
383 .Fn ECParameters_dup ,
384 .Fn d2i_ECPrivateKey ,
385 .Fn d2i_ECPrivateKey_bio ,
386 .Fn d2i_ECPrivateKey_fp ,
387 .Fn o2i_ECPublicKey ,
388 .Fn d2i_EC_PUBKEY ,
389 .Fn d2i_EC_PUBKEY_bio ,
391 .Fn d2i_EC_PUBKEY_fp
392 return a valid
393 .Vt EC_KEY
394 structure or
395 .Dv NULL
396 if an error occurs.
398 .Fn i2d_ECPKParameters ,
399 .Fn i2d_ECParameters ,
400 .Fn i2d_ECPrivateKey ,
401 .Fn i2o_ECPublicKey ,
403 .Fn i2d_EC_PUBKEY
404 return the number of bytes successfully encoded or a negative value if
405 an error occurs.
407 .Fn i2d_ECPKParameters_bio ,
408 .Fn i2d_ECPKParameters_fp ,
409 .Fn i2d_ECPrivateKey_bio ,
410 .Fn i2d_ECPrivateKey_fp ,
411 .Fn ECPKParameters_print ,
412 .Fn ECPKParameters_print_fp ,
413 .Fn ECParameters_print ,
414 .Fn ECParameters_print_fp ,
415 .Fn i2d_EC_PUBKEY_bio ,
417 .Fn i2d_EC_PUBKEY_fp
418 return 1 for success or 0 if an error occurs.
419 .Sh SEE ALSO
420 .Xr ASN1_item_d2i 3 ,
421 .Xr EC_GROUP_copy 3 ,
422 .Xr EC_GROUP_new 3 ,
423 .Xr EC_KEY_new 3 ,
424 .Xr EVP_PKEY_set1_EC_KEY 3 ,
425 .Xr PEM_write_ECPrivateKey 3 ,
426 .Xr PKCS8_PRIV_KEY_INFO_new 3 ,
427 .Xr X509_PUBKEY_new 3
428 .Sh STANDARDS
429 RFC 5915: Elliptic Curve Private Key Structure
431 RFC 5208: Public-Key Cryptography Standards (PKCS) #8:
432 Private-Key Information Syntax Specification
434 RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
435 Certificate Revocation List (CRL) Profile,
436 section 4.1: Basic Certificate Fields
437 .Sh HISTORY
438 .Fn d2i_ECPKParameters ,
439 .Fn i2d_ECPKParameters ,
440 .Fn d2i_ECPKParameters_bio ,
441 .Fn i2d_ECPKParameters_bio ,
442 .Fn d2i_ECPKParameters_fP ,
443 .Fn i2d_ECPKParameters_fp ,
444 .Fn d2i_ECParameters ,
445 .Fn i2d_ECParameters ,
446 .Fn ECParameters_dup ,
447 .Fn d2i_ECPrivateKey ,
448 .Fn i2d_ECPrivateKey ,
449 .Fn d2i_ECPrivateKey_bio ,
450 .Fn i2d_ECPrivateKey_bio ,
451 .Fn d2i_ECPrivateKey_fp ,
452 .Fn i2d_ECPrivateKey_fp ,
453 .Fn o2i_ECPublicKey ,
454 .Fn i2o_ECPublicKey ,
455 .Fn ECPKParameters_print ,
456 .Fn ECPKParameters_print_fp ,
457 .Fn ECParameters_print ,
458 .Fn ECParameters_print_fp ,
459 .Fn d2i_EC_PUBKEY ,
460 .Fn i2d_EC_PUBKEY ,
461 .Fn d2i_EC_PUBKEY_bio ,
462 .Fn i2d_EC_PUBKEY_bio ,
463 .Fn d2i_EC_PUBKEY_fp ,
465 .Fn i2d_EC_PUBKEY_fp
466 first appeared in OpenSSL 0.9.8 and have been available since
467 .Ox 4.5 .