xref: /openbsd-src/lib/libcrypto/man/SMIME_read_CMS.3 (revision 3d955ecadc561a1cd05817d1e07b58a2548ef32a)
1*3d955ecaSschwarze.\" $OpenBSD: SMIME_read_CMS.3,v 1.7 2021/12/14 14:30:50 schwarze Exp $
254c85986Sschwarze.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
354c85986Sschwarze.\"
454c85986Sschwarze.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
554c85986Sschwarze.\" Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
654c85986Sschwarze.\"
754c85986Sschwarze.\" Redistribution and use in source and binary forms, with or without
854c85986Sschwarze.\" modification, are permitted provided that the following conditions
954c85986Sschwarze.\" are met:
1054c85986Sschwarze.\"
1154c85986Sschwarze.\" 1. Redistributions of source code must retain the above copyright
1254c85986Sschwarze.\"    notice, this list of conditions and the following disclaimer.
1354c85986Sschwarze.\"
1454c85986Sschwarze.\" 2. Redistributions in binary form must reproduce the above copyright
1554c85986Sschwarze.\"    notice, this list of conditions and the following disclaimer in
1654c85986Sschwarze.\"    the documentation and/or other materials provided with the
1754c85986Sschwarze.\"    distribution.
1854c85986Sschwarze.\"
1954c85986Sschwarze.\" 3. All advertising materials mentioning features or use of this
2054c85986Sschwarze.\"    software must display the following acknowledgment:
2154c85986Sschwarze.\"    "This product includes software developed by the OpenSSL Project
2254c85986Sschwarze.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
2354c85986Sschwarze.\"
2454c85986Sschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
2554c85986Sschwarze.\"    endorse or promote products derived from this software without
2654c85986Sschwarze.\"    prior written permission. For written permission, please contact
2754c85986Sschwarze.\"    openssl-core@openssl.org.
2854c85986Sschwarze.\"
2954c85986Sschwarze.\" 5. Products derived from this software may not be called "OpenSSL"
3054c85986Sschwarze.\"    nor may "OpenSSL" appear in their names without prior written
3154c85986Sschwarze.\"    permission of the OpenSSL Project.
3254c85986Sschwarze.\"
3354c85986Sschwarze.\" 6. Redistributions of any form whatsoever must retain the following
3454c85986Sschwarze.\"    acknowledgment:
3554c85986Sschwarze.\"    "This product includes software developed by the OpenSSL Project
3654c85986Sschwarze.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
3754c85986Sschwarze.\"
3854c85986Sschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
3954c85986Sschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4054c85986Sschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4154c85986Sschwarze.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
4254c85986Sschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4354c85986Sschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
4454c85986Sschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
4554c85986Sschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4654c85986Sschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4754c85986Sschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4854c85986Sschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4954c85986Sschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE.
5054c85986Sschwarze.\"
51*3d955ecaSschwarze.Dd $Mdocdate: December 14 2021 $
5254c85986Sschwarze.Dt SMIME_READ_CMS 3
5354c85986Sschwarze.Os
5454c85986Sschwarze.Sh NAME
5554c85986Sschwarze.Nm SMIME_read_CMS
56*3d955ecaSschwarze.Nd extract CMS ContentInfo from an S/MIME message
5754c85986Sschwarze.Sh SYNOPSIS
5854c85986Sschwarze.In openssl/cms.h
5954c85986Sschwarze.Ft CMS_ContentInfo *
6054c85986Sschwarze.Fo SMIME_read_CMS
6154c85986Sschwarze.Fa "BIO *in"
6254c85986Sschwarze.Fa "BIO **bcont"
6354c85986Sschwarze.Fc
6454c85986Sschwarze.Sh DESCRIPTION
6554c85986Sschwarze.Fn SMIME_read_CMS
663ecda961Sschwarzeparses a message in S/MIME format from
673ecda961Sschwarze.Fa in .
6854c85986Sschwarze.Pp
693ecda961SschwarzeIf the message uses cleartext signing, the content is saved in a memory BIO
7054c85986Sschwarzewhich is written to
7154c85986Sschwarze.Pf * Fa bcont
723ecda961Sschwarzeand which can then be passed to
7354c85986Sschwarze.Xr CMS_verify 3
7454c85986Sschwarzewith the
7554c85986Sschwarze.Dv CMS_DETACHED
7654c85986Sschwarzeflag set.
773ecda961SschwarzeOtherwise,
783ecda961Sschwarze.Pf * Fa bcont
793ecda961Sschwarzeis set to
803ecda961Sschwarze.Dv NULL
813ecda961Sschwarzeand the type of the returned structure can be determined using
8254c85986Sschwarze.Xr CMS_get0_type 3 .
8354c85986Sschwarze.Pp
8454c85986SschwarzeTo support future functionality if
8554c85986Sschwarze.Fa bcont
8654c85986Sschwarzeis not
8754c85986Sschwarze.Dv NULL ,
8854c85986Sschwarze.Pf * Fa bcont
8954c85986Sschwarzeshould be initialized to
903ecda961Sschwarze.Dv NULL ,
913ecda961Sschwarzefor example:
9254c85986Sschwarze.Bd -literal -offset indent
9354c85986SschwarzeBIO *cont = NULL;
943ecda961SschwarzeCMS_ContentInfo *cms = SMIME_read_CMS(in, &cont);
9554c85986Sschwarze.Ed
9654c85986Sschwarze.Sh RETURN VALUES
9754c85986Sschwarze.Fn SMIME_read_CMS
9854c85986Sschwarzereturns a valid
9954c85986Sschwarze.Vt CMS_ContentInfo
10054c85986Sschwarzestructure or
10154c85986Sschwarze.Dv NULL
10254c85986Sschwarzeif an error occurred.
10354c85986SschwarzeThe error can be obtained from
10454c85986Sschwarze.Xr ERR_get_error 3 .
10554c85986Sschwarze.Sh SEE ALSO
10685bbda65Sschwarze.Xr CMS_ContentInfo_new 3 ,
10754c85986Sschwarze.Xr CMS_decrypt 3 ,
108df213d14Sschwarze.Xr CMS_get0_type 3 ,
10954c85986Sschwarze.Xr CMS_verify 3 ,
11085bbda65Sschwarze.Xr d2i_CMS_ContentInfo 3 ,
111*3d955ecaSschwarze.Xr SMIME_read_ASN1 3 ,
11254c85986Sschwarze.Xr SMIME_write_CMS 3
11366a3cb98Sschwarze.Sh HISTORY
11466a3cb98Sschwarze.Fn SMIME_read_CMS
11566a3cb98Sschwarzefirst appeared in OpenSSL 0.9.8h
11666a3cb98Sschwarzeand has been available since
117569a59c8Sschwarze.Ox 6.7 .
11854c85986Sschwarze.Sh BUGS
11954c85986SschwarzeThe MIME parser used by
12054c85986Sschwarze.Fn SMIME_read_CMS
12154c85986Sschwarzeis somewhat primitive.
12254c85986SschwarzeWhile it will handle most S/MIME messages, more complex compound formats
12354c85986Sschwarzemay not work.
12454c85986Sschwarze.Pp
12554c85986SschwarzeThe parser assumes that the
12654c85986Sschwarze.Vt CMS_ContentInfo
12754c85986Sschwarzestructure is always base64 encoded and will not handle the case
12854c85986Sschwarzewhere it is in binary format or uses quoted printable format.
12954c85986Sschwarze.Pp
13054c85986SschwarzeThe use of a memory BIO to hold the signed content limits the size of
1313ecda961Sschwarzethe message which can be processed due to memory restraints: a streaming
13254c85986Sschwarzesingle pass option should be available.
133