xref: /openbsd-src/lib/libcrypto/man/CMS_add0_cert.3 (revision 4e1ee0786f11cc571bd0be17d38e46f635c719fc)
1.\" $OpenBSD: CMS_add0_cert.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $
2.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2019 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 Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2008 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: November 2 2019 $
69.Dt CMS_ADD0_CERT 3
70.Os
71.Sh NAME
72.Nm CMS_add0_cert ,
73.Nm CMS_add1_cert ,
74.Nm CMS_get1_certs ,
75.Nm CMS_add0_crl ,
76.Nm CMS_add1_crl ,
77.Nm CMS_get1_crls
78.Nd CMS certificate and CRL utility functions
79.Sh SYNOPSIS
80.In openssl/cms.h
81.Ft int
82.Fo CMS_add0_cert
83.Fa "CMS_ContentInfo *cms"
84.Fa "X509 *certificate"
85.Fc
86.Ft int
87.Fo CMS_add1_cert
88.Fa "CMS_ContentInfo *cms"
89.Fa "X509 *certificate"
90.Fc
91.Ft STACK_OF(X509) *
92.Fo CMS_get1_certs
93.Fa "CMS_ContentInfo *cms"
94.Fc
95.Ft int
96.Fo CMS_add0_crl
97.Fa "CMS_ContentInfo *cms"
98.Fa "X509_CRL *crl"
99.Fc
100.Ft int
101.Fo CMS_add1_crl
102.Fa "CMS_ContentInfo *cms"
103.Fa "X509_CRL *crl"
104.Fc
105.Ft STACK_OF(X509_CRL) *
106.Fo CMS_get1_crls
107.Fa "CMS_ContentInfo *cms"
108.Fc
109.Sh DESCRIPTION
110.Fn CMS_add0_cert
111adds the
112.Fa certificate
113to the
114.Fa certificates
115field of
116.Fa cms
117if it is of the type
118.Vt SignedData
119or to the
120.Fa originatorInfo.certs
121field if it is of the type
122.Vt EnvelopedData .
123.Fn CMS_add1_cert
124does the same and also increments the reference count of the
125.Fa certificate
126with
127.Xr X509_up_ref 3
128in case of success.
129.Pp
130.Fn CMS_get1_certs
131returns all certificates in
132.Fa cms .
133.Pp
134.Fn CMS_add0_crl
135adds the
136.Fa crl
137to the
138.Fa crls
139field of
140.Fa cms
141if it is of the type
142.Vt SignedData
143or to the
144.Fa originatorInfo.crls
145field if it is of the type
146.Vt EnvelopedData .
147.Fn CMS_add1_crl
148does the same and also increments the reference count of the
149.Fa crl
150with
151.Xr X509_CRL_up_ref 3
152in case of success.
153.Pp
154.Fn CMS_get1_crls
155returns any CRLs in
156.Fa cms .
157.Pp
158An error occurs if
159.Fa cms
160is of any type other than
161.Vt SignedData
162or
163.Vt EnvelopedData .
164.Pp
165The same
166.Fa certificate
167or
168.Fa crl
169must not be added to the same
170.Fa cms
171structure more than once.
172.Sh RETURN VALUES
173.Fn CMS_add0_cert ,
174.Fn CMS_add1_cert ,
175.Fn CMS_add0_crl ,
176and
177.Fn CMS_add1_crl
178return 1 for success or 0 for failure.
179.Pp
180.Fn CMS_get1_certs
181and
182.Fn CMS_get1_crls
183return the STACK of certificates or CRLs or
184.Dv NULL
185if there are none or an error occurs.
186The only error which will occur in practice is if the
187.Fa cms
188type is invalid.
189.Sh SEE ALSO
190.Xr CMS_ContentInfo_new 3 ,
191.Xr CMS_encrypt 3 ,
192.Xr CMS_final 3 ,
193.Xr CMS_sign 3 ,
194.Xr ERR_get_error 3
195.Sh STANDARDS
196RFC 5652: Cryptographic Message Syntax
197.Bl -dash -compact -offset indent
198.It
199section 5.1: SignedData Type
200.It
201section 6.1: EnvelopedData Type
202.El
203.Sh HISTORY
204.Fn CMS_add0_cert ,
205.Fn CMS_add1_cert ,
206.Fn CMS_get1_certs ,
207.Fn CMS_add0_crl ,
208and
209.Fn CMS_get1_crls
210first appeared in OpenSSL 0.9.8h and
211.Fn CMS_add1_crl
212in OpenSSL 1.0.0.
213These functions have been available since
214.Ox 6.7 .
215