1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
.\" $OpenBSD: d2i_PKCS8_PRIV_KEY_INFO.3,v 1.1 2016/12/28 00:55:05 schwarze Exp $
.\"
.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: December 28 2016 $
.Dt D2I_PKCS8_PRIV_KEY_INFO 3
.Os
.Sh NAME
.Nm d2i_PKCS8_PRIV_KEY_INFO ,
.Nm i2d_PKCS8_PRIV_KEY_INFO ,
.Nm d2i_PKCS8_PRIV_KEY_INFO_bio ,
.Nm i2d_PKCS8_PRIV_KEY_INFO_bio ,
.Nm d2i_PKCS8_PRIV_KEY_INFO_fp ,
.Nm i2d_PKCS8_PRIV_KEY_INFO_fp
.Nd decode and encode PKCS#8 private key
.Sh SYNOPSIS
.In openssl/x509.h
.Ft PKCS8_PRIV_KEY_INFO *
.Fo d2i_PKCS8_PRIV_KEY_INFO
.Fa "PKCS8_PRIV_KEY_INFO **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_PKCS8_PRIV_KEY_INFO
.Fa "PKCS8_PRIV_KEY_INFO *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft PKCS8_PRIV_KEY_INFO *
.Fo d2i_PKCS8_PRIV_KEY_INFO_bio
.Fa "BIO *in_bio"
.Fa "PKCS8_PRIV_KEY_INFO **val_out"
.Fc
.Ft int
.Fo i2d_PKCS8_PRIV_KEY_INFO_bio
.Fa "BIO *out_bio"
.Fa "PKCS8_PRIV_KEY_INFO *val_in"
.Fc
.Ft PKCS8_PRIV_KEY_INFO *
.Fo d2i_PKCS8_PRIV_KEY_INFO_fp
.Fa "FILE *in_fp"
.Fa "PKCS8_PRIV_KEY_INFO **val_out"
.Fc
.Ft int
.Fo i2d_PKCS8_PRIV_KEY_INFO_fp
.Fa "BIO *out_fp"
.Fa "PKCS8_PRIV_KEY_INFO *val_in"
.Fc
.Sh DESCRIPTION
.Fn d2i_PKCS8_PRIV_KEY_INFO
and
.Fn i2d_PKCS8_PRIV_KEY_INFO
decode and encode an ASN.1
.Vt PrivateKeyInfo
structure defined in RFC 5208 section 5.
.Pp
.Fn d2i_PKCS8_PRIV_KEY_INFO_bio ,
.Fn i2d_PKCS8_PRIV_KEY_INFO_bio ,
.Fn d2i_PKCS8_PRIV_KEY_INFO_fp ,
and
.Fn i2d_PKCS8_PRIV_KEY_INFO_fp
are similar except that they decode or encode using a
.Vt BIO
or
.Vt FILE
pointer.
.Pp
For details about the semantics, examples, caveats, and bugs, see
.Xr ASN1_item_d2i 3 .
.Pp
These functions all use unencrypted DER format.
To store private keys in encrypted form, consider
.Xr d2i_PKCS8PrivateKey_bio 3
or
.Xr PEM_write_PKCS8PrivateKey 3 .
.Sh RETURN VALUES
.Fn d2i_PKCS8_PRIV_KEY_INFO ,
.Fn d2i_PKCS8_PRIV_KEY_INFO_bio ,
and
.Fn d2i_PKCS8_PRIV_KEY_INFO_fp
return a
.Vt PKCS8_PRIV_KEY_INFO
object or
.Dv NULL
if an error occurs.
.Pp
.Fn i2d_PKCS8_PRIV_KEY_INFO
returns the number of bytes successfully encoded or a negative value
if an error occurs.
.Pp
.Fn i2d_PKCS8_PRIV_KEY_INFO_bio
and
.Fn i2d_PKCS8_PRIV_KEY_INFO_fp
return 1 for success or 0 if an error occurs.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr d2i_PKCS8PrivateKey_bio 3 ,
.Xr d2i_PrivateKey 3 ,
.Xr PEM_write_PKCS8_PRIV_KEY_INFO 3 ,
.Xr PKCS8_PRIV_KEY_INFO_new 3
.Sh STANDARDS
RFC 5208: PKCS#8: Private-Key Information Syntax Specification
|