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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
.\" $OpenBSD: d2i_X509_SIG.3,v 1.9 2018/03/27 17:35:50 schwarze Exp $
.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400
.\"
.\" 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: March 27 2018 $
.Dt D2I_X509_SIG 3
.Os
.Sh NAME
.Nm d2i_X509_SIG ,
.Nm i2d_X509_SIG ,
.Nm d2i_PKCS8_bio ,
.Nm i2d_PKCS8_bio ,
.Nm d2i_PKCS8_fp ,
.Nm i2d_PKCS8_fp
.\" In the next line, the number "7" is not a typo.
.\" These functions are misnamed.
.Nd decode and encode PKCS#7 digest information
.Sh SYNOPSIS
.In openssl/x509.h
.Ft X509_SIG *
.Fo d2i_X509_SIG
.Fa "X509_SIG **val_out"
.Fa "unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_X509_SIG
.Fa "X509_SIG *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft X509_SIG *
.Fo d2i_PKCS8_bio
.Fa "BIO *in_bio"
.Fa "X509_SIG **val_out"
.Fc
.Ft int
.Fo i2d_PKCS8_bio
.Fa "BIO *out_bio"
.Fa "X509_SIG *val_in"
.Fc
.Ft X509_SIG *
.Fo d2i_PKCS8_fp
.Fa "FILE *in_fp"
.Fa "X509_SIG **val_out"
.Fc
.Ft int
.Fo i2d_PKCS8_fp
.Fa "FILE *out_fp"
.Fa "X509_SIG *val_in"
.Fc
.Sh DESCRIPTION
.Fn d2i_X509_SIG
and
.Fn i2d_X509_SIG
decode and encode an ASN.1
.Vt DigestInfo
structure defined in RFC 2315 section 9.4
and equivalently in RFC 8017 section 9.2.
For details about the semantics, examples, caveats, and bugs, see
.Xr ASN1_item_d2i 3 .
.Pp
.Fn d2i_PKCS8_bio
and
.Fn d2i_PKCS8_fp
are similar to
.Fn d2i_X509_SIG
except that they read from a
.Vt BIO
or
.Vt FILE
pointer.
.Pp
.Fn i2d_PKCS8_bio
and
.Fn i2d_PKCS8_fp
are similar to
.Fn i2d_X509_SIG
except that they write to a
.Vt BIO
or
.Vt FILE
pointer.
.Sh RETURN VALUES
.Fn d2i_X509_SIG ,
.Fn d2i_PKCS8_bio ,
and
.Fn d2i_PKCS8_fp
return a
.Vt X509_SIG
object or
.Dv NULL
if an error occurs.
.Pp
.Fn i2d_X509_SIG
returns the number of bytes successfully encoded or a negative value
if an error occurs.
.Pp
.Fn i2d_PKCS8_bio
and
.Fn i2d_PKCS8_fp
return 1 for success or 0 if an error occurs.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr PKCS7_new 3 ,
.Xr RSA_sign 3 ,
.Xr X509_SIG_new 3
.Sh STANDARDS
RFC 2315: PKCS #7: Cryptographic Message Syntax,
section 9: Signed-data content type
.Pp
RFC 8017: PKCS #1: RSA Cryptography Specifications,
section 9: Encoding Methods for Signatures
.Sh HISTORY
.Fn d2i_X509_SIG
and
.Fn i2d_X509_SIG
first appeared in SSLeay 0.5.1 and have been available since
.Ox 2.4 .
.Pp
.Fn d2i_PKCS8_bio ,
.Fn i2d_PKCS8_bio ,
.Fn d2i_PKCS8_fp ,
and
.Fn i2d_PKCS8_fp
first appeared in OpenSSL 0.9.4 and have been available since
.Ox 2.6 .
.Sh BUGS
.Fn d2i_PKCS8_bio ,
.Fn i2d_PKCS8_bio ,
.Fn d2i_PKCS8_fp ,
and
.Fn i2d_PKCS8_fp
are severely misnamed and should have been called
.Dq d2i_X509_SIG_bio
and so on.
.Pp
Or arguably, the
.Vt X509_SIG
object is misnamed itself, considering that it represents
.Vt DigestInfo
from PKCS#7 and PKCS#1.
Then again, calling it
.Dq PKCS8
instead clearly isn't an improvement.
.Pp
Either way, these names just don't fit.
|