1 .\" $OpenBSD: d2i_PKCS7.3,v 1.5 2018/03/21 00:54:31 schwarze Exp $
3 .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: March 21 2018 $
28 .Nm d2i_PKCS7_DIGEST ,
29 .Nm i2d_PKCS7_DIGEST ,
30 .Nm d2i_PKCS7_ENCRYPT ,
31 .Nm i2d_PKCS7_ENCRYPT ,
32 .Nm d2i_PKCS7_ENC_CONTENT ,
33 .Nm i2d_PKCS7_ENC_CONTENT ,
34 .Nm d2i_PKCS7_ENVELOPE ,
35 .Nm i2d_PKCS7_ENVELOPE ,
36 .Nm d2i_PKCS7_ISSUER_AND_SERIAL ,
37 .Nm i2d_PKCS7_ISSUER_AND_SERIAL ,
38 .Nm d2i_PKCS7_RECIP_INFO ,
39 .Nm i2d_PKCS7_RECIP_INFO ,
40 .Nm d2i_PKCS7_SIGNED ,
41 .Nm i2d_PKCS7_SIGNED ,
42 .Nm d2i_PKCS7_SIGNER_INFO ,
43 .Nm i2d_PKCS7_SIGNER_INFO ,
44 .Nm d2i_PKCS7_SIGN_ENVELOPE ,
45 .Nm i2d_PKCS7_SIGN_ENVELOPE
46 .Nd decode and encode PKCS#7 data structures
52 .Fa "const unsigned char **der_in"
58 .Fa "unsigned char **der_out"
83 .Fa "unsigned char **ber_out"
87 .Fa "PKCS7_DIGEST **val_out"
88 .Fa "const unsigned char **der_in"
93 .Fa "PKCS7_DIGEST *val_in"
94 .Fa "unsigned char **der_out"
98 .Fa "PKCS7_ENCRYPT **val_out"
99 .Fa "const unsigned char **der_in"
103 .Fo i2d_PKCS7_ENCRYPT
104 .Fa "PKCS7_ENCRYPT *val_in"
105 .Fa "unsigned char **der_out"
107 .Ft PKCS7_ENC_CONTENT *
108 .Fo d2i_PKCS7_ENC_CONTENT
109 .Fa "PKCS7_ENC_CONTENT **val_out"
110 .Fa "const unsigned char **der_in"
114 .Fo i2d_PKCS7_ENC_CONTENT
115 .Fa "PKCS7_ENC_CONTENT *val_in"
116 .Fa "unsigned char **der_out"
119 .Fo d2i_PKCS7_ENVELOPE
120 .Fa "PKCS7_ENVELOPE **val_out"
121 .Fa "const unsigned char **der_in"
125 .Fo i2d_PKCS7_ENVELOPE
126 .Fa "PKCS7_ENVELOPE *val_in"
127 .Fa "unsigned char **der_out"
129 .Ft PKCS7_ISSUER_AND_SERIAL *
130 .Fo d2i_PKCS7_ISSUER_AND_SERIAL
131 .Fa "PKCS7_ISSUER_AND_SERIAL **val_out"
132 .Fa "const unsigned char **der_in"
136 .Fo i2d_PKCS7_ISSUER_AND_SERIAL
137 .Fa "PKCS7_ISSUER_AND_SERIAL *val_in"
138 .Fa "unsigned char **der_out"
140 .Ft PKCS7_RECIP_INFO *
141 .Fo d2i_PKCS7_RECIP_INFO
142 .Fa "PKCS7_RECIP_INFO **val_out"
143 .Fa "const unsigned char **der_in"
147 .Fo i2d_PKCS7_RECIP_INFO
148 .Fa "PKCS7_RECIP_INFO *val_in"
149 .Fa "unsigned char **der_out"
153 .Fa "PKCS7_SIGNED **val_out"
154 .Fa "const unsigned char **der_in"
159 .Fa "PKCS7_SIGNED *val_in"
160 .Fa "unsigned char **der_out"
162 .Ft PKCS7_SIGNER_INFO *
163 .Fo d2i_PKCS7_SIGNER_INFO
164 .Fa "PKCS7_SIGNER_INFO **val_out"
165 .Fa "const unsigned char **der_in"
169 .Fo i2d_PKCS7_SIGNER_INFO
170 .Fa "PKCS7_SIGNER_INFO *val_in"
171 .Fa "unsigned char **der_out"
173 .Ft PKCS7_SIGN_ENVELOPE *
174 .Fo d2i_PKCS7_SIGN_ENVELOPE
175 .Fa "PKCS7_SIGN_ENVELOPE **val_out"
176 .Fa "const unsigned char **der_in"
180 .Fo i2d_PKCS7_SIGN_ENVELOPE
181 .Fa "PKCS7_SIGN_ENVELOPE *val_in"
182 .Fa "unsigned char **der_out"
185 These functions decode and encode PKCS#7 data structures.
186 For details about the semantics, examples, caveats, and bugs, see
187 .Xr ASN1_item_d2i 3 .
192 decode and encode an ASN.1
194 structure defined in RFC 2315 section 7.
200 are similar except that they decode or encode using a
209 except that it encodes using BER rather than DER, using the indefinite
210 length form where appropriate.
215 decode and encode an ASN.1
217 structure defined in RFC 2315 section 12.
219 .Fn d2i_PKCS7_ENCRYPT
221 .Fn i2d_PKCS7_ENCRYPT
222 decode and encode an ASN.1
224 structure defined in RFC 2315 section 13.
226 .Fn d2i_PKCS7_ENC_CONTENT
228 .Fn i2d_PKCS7_ENC_CONTENT
229 decode and encode an ASN.1
230 .Vt EncryptedContentInfo
231 structure defined in RFC 2315 section 10.1.
233 .Fn d2i_PKCS7_ENVELOPE
235 .Fn i2d_PKCS7_ENVELOPE
236 decode and encode an ASN.1
238 structure defined in RFC 2315 section 10.
240 .Fn d2i_PKCS7_ISSUER_AND_SERIAL
242 .Fn i2d_PKCS7_ISSUER_AND_SERIAL
243 decode and encode an ASN.1
244 .Vt IssuerAndSerialNumber
245 structure defined in RFC 2315 section 6.7.
247 .Fn d2i_PKCS7_RECIP_INFO
249 .Fn i2d_PKCS7_RECIP_INFO
250 decode and encode an ASN.1
252 structure defined in RFC 2315 section 10.2.
257 decode and encode an ASN.1
259 structure defined in RFC 2315 section 9.
261 .Fn d2i_PKCS7_SIGNER_INFO
263 .Fn i2d_PKCS7_SIGNER_INFO
264 decode and encode an ASN.1
266 structure defined in RFC 2315 section 9.2.
268 .Fn d2i_PKCS7_SIGN_ENVELOPE
270 .Fn i2d_PKCS7_SIGN_ENVELOPE
271 decode and encode an ASN.1
272 .Vt SignedAndEnvelopedData
273 structure defined in RFC 2315 section 11.
285 .Fn d2i_PKCS7_DIGEST ,
286 .Fn d2i_PKCS7_ENCRYPT ,
287 .Fn d2i_PKCS7_ENC_CONTENT ,
288 .Fn d2i_PKCS7_ENVELOPE ,
289 .Fn d2i_PKCS7_ISSUER_AND_SERIAL ,
290 .Fn d2i_PKCS7_RECIP_INFO ,
291 .Fn d2i_PKCS7_SIGNED ,
292 .Fn d2i_PKCS7_SIGNER_INFO ,
294 .Fn d2i_PKCS7_SIGN_ENVELOPE
295 return an object of the respective type or
301 .Fn i2d_PKCS7_DIGEST ,
302 .Fn i2d_PKCS7_ENCRYPT ,
303 .Fn i2d_PKCS7_ENC_CONTENT ,
304 .Fn i2d_PKCS7_ENVELOPE ,
305 .Fn i2d_PKCS7_ISSUER_AND_SERIAL ,
306 .Fn i2d_PKCS7_RECIP_INFO ,
307 .Fn i2d_PKCS7_SIGNED ,
308 .Fn i2d_PKCS7_SIGNER_INFO ,
310 .Fn i2d_PKCS7_SIGN_ENVELOPE
311 return the number of bytes successfully encoded or a negative value
317 return 1 for success or 0 if an error occurs.
319 .Xr ASN1_item_d2i 3 ,
320 .Xr i2d_PKCS7_bio_stream 3 ,
321 .Xr PEM_write_bio_PKCS7_stream 3 ,
322 .Xr PEM_write_PKCS7 3 ,
324 .Xr SMIME_write_PKCS7 3
326 RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
334 .Fn d2i_PKCS7_DIGEST ,
335 .Fn i2d_PKCS7_DIGEST ,
336 .Fn d2i_PKCS7_ENCRYPT ,
337 .Fn i2d_PKCS7_ENCRYPT ,
338 .Fn d2i_PKCS7_ENC_CONTENT ,
339 .Fn i2d_PKCS7_ENC_CONTENT ,
340 .Fn d2i_PKCS7_ENVELOPE ,
341 .Fn i2d_PKCS7_ENVELOPE ,
342 .Fn d2i_PKCS7_ISSUER_AND_SERIAL ,
343 .Fn i2d_PKCS7_ISSUER_AND_SERIAL ,
344 .Fn d2i_PKCS7_RECIP_INFO ,
345 .Fn i2d_PKCS7_RECIP_INFO ,
346 .Fn d2i_PKCS7_SIGNED ,
347 .Fn i2d_PKCS7_SIGNED ,
348 .Fn d2i_PKCS7_SIGNER_INFO ,
349 .Fn i2d_PKCS7_SIGNER_INFO ,
350 .Fn d2i_PKCS7_SIGN_ENVELOPE ,
352 .Fn i2d_PKCS7_SIGN_ENVELOPE
353 appeared in SSLeay 0.8.1b or earlier and have been available since