1.\" $OpenBSD: PKCS7_set_content.3,v 1.2 2020/05/24 12:37:30 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
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.
8.\"
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.
16.\"
17.Dd $Mdocdate: May 24 2020 $
18.Dt PKCS7_SET_CONTENT 3
19.Os
20.Sh NAME
21.Nm PKCS7_set_content ,
22.Nm PKCS7_content_new
23.Nd set the nested contentInfo in a PKCS#7 structure
24.Sh SYNOPSIS
25.In openssl/pkcs7.h
26.Ft int
27.Fo PKCS7_set_content
28.Fa "PKCS7 *outer"
29.Fa "PKCS7 *inner"
30.Fc
31.Ft int
32.Fo PKCS7_content_new
33.Fa "PKCS7 *outer"
34.Fa "int inner_type"
35.Fc
36.Sh DESCRIPTION
37If the
38.Fa contentType
39of the
40.Fa outer
41PKCS7 structure is
42.Vt SignedData
43or
44.Vt DigestedData ,
45.Fn PKCS7_set_content
46sets the
47.Fa contentInfo
48field of the
49.Fa content
50field of
51.Fa outer
52to
53.Fa inner ,
54without copying
55.Fa inner .
56If there was previous
57.Fa contentInfo ,
58it is freed rather than overwritten.
59The rest of the internal state of
60.Fa outer
61and of its
62.Fa content
63remains unchanged.
64.Pp
65.Fn PKCS7_content_new
66is similar except that it first allocates and initializes a new, empty
67.Fa inner
68object of the given
69.Fa inner_type
70using
71.Xr PKCS7_new 3
72and
73.Xr PKCS7_set_type 3 .
74The
75.Fa inner_type
76can be any of the NIDs listed in the
77.Xr PKCS7_set_type 3
78manual.
79.Sh RETURN VALUES
80These functions return 1 on success or 0 on failure.
81They fail if the
82.Fa contentType
83of
84.Fa outer
85is unsupported.
86.Fn PKCS7_content_new
87can also fail when memory is exhausted.
88In case of failure,
89.Fa outer
90remains unchanged.
91.Sh SEE ALSO
92.Xr PKCS7_dataInit 3 ,
93.Xr PKCS7_new 3 ,
94.Xr PKCS7_set_type 3 ,
95.Xr PKCS7_sign 3
96.Sh STANDARDS
97RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5
98.Bl -bullet -compact -offset 1n -width 1n
99.It
100Section 7. General syntax
101.It
102Section 9. Signed-data content type
103.It
104Section 12.\& Digested-data content type
105.El
106.Sh HISTORY
107These functions first appeared in SSLeay 0.8.1
108and have been available since
109.Ox 2.4 .
110.Sh CAVEATS
111Despite the function names, these functions do not set the
112.Fa content
113field of
114.Fa outer ,
115but only the
116.Fa contentInfo
117field inside it.
118The rest of the
119.Fa content
120remains unchanged.
121