xref: /freebsd/crypto/openssl/doc/man3/SMIME_read_CMS.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5*b077aed3SPierre ProncherySMIME_read_CMS_ex, SMIME_read_CMS - parse S/MIME message
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/cms.h>
10e71b7053SJung-uk Kim
11*b077aed3SPierre Pronchery CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont,
12*b077aed3SPierre Pronchery                                    CMS_ContentInfo **cms);
13e71b7053SJung-uk Kim CMS_ContentInfo *SMIME_read_CMS(BIO *in, BIO **bcont);
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim=head1 DESCRIPTION
16e71b7053SJung-uk Kim
17e71b7053SJung-uk KimSMIME_read_CMS() parses a message in S/MIME format.
18e71b7053SJung-uk Kim
19e71b7053SJung-uk KimB<in> is a BIO to read the message from.
20e71b7053SJung-uk Kim
21e71b7053SJung-uk KimIf cleartext signing is used then the content is saved in a memory bio which is
22e71b7053SJung-uk Kimwritten to B<*bcont>, otherwise B<*bcont> is set to NULL.
23e71b7053SJung-uk Kim
24e71b7053SJung-uk KimThe parsed CMS_ContentInfo structure is returned or NULL if an
25e71b7053SJung-uk Kimerror occurred.
26e71b7053SJung-uk Kim
27*b077aed3SPierre ProncherySMIME_read_CMS_ex() is similar to SMIME_read_CMS() but optionally a previously
28*b077aed3SPierre Proncherycreated I<cms> CMS_ContentInfo object can be supplied as well as some I<flags>.
29*b077aed3SPierre ProncheryTo create a I<cms> object use L<CMS_ContentInfo_new_ex(3)>.
30*b077aed3SPierre ProncheryIf the I<flags> argument contains B<CMS_BINARY> then the input is assumed to be
31*b077aed3SPierre Proncheryin binary format and is not translated to canonical form.
32*b077aed3SPierre ProncheryIf in addition B<SMIME_ASCIICRLF> is set then the binary input is assumed
33*b077aed3SPierre Proncheryto be followed by B<CR> and B<LF> characters, else only by an B<LF> character.
34*b077aed3SPierre ProncheryIf I<flags> is 0 and I<cms> is NULL then it is identical to SMIME_read_CMS().
35*b077aed3SPierre Pronchery
36e71b7053SJung-uk Kim=head1 NOTES
37e71b7053SJung-uk Kim
38e71b7053SJung-uk KimIf B<*bcont> is not NULL then the message is clear text signed. B<*bcont> can
39e71b7053SJung-uk Kimthen be passed to CMS_verify() with the B<CMS_DETACHED> flag set.
40e71b7053SJung-uk Kim
41e71b7053SJung-uk KimOtherwise the type of the returned structure can be determined
42e71b7053SJung-uk Kimusing CMS_get0_type().
43e71b7053SJung-uk Kim
44e71b7053SJung-uk KimTo support future functionality if B<bcont> is not NULL B<*bcont> should be
45e71b7053SJung-uk Kiminitialized to NULL. For example:
46e71b7053SJung-uk Kim
47e71b7053SJung-uk Kim BIO *cont = NULL;
48e71b7053SJung-uk Kim CMS_ContentInfo *cms;
49e71b7053SJung-uk Kim
50e71b7053SJung-uk Kim cms = SMIME_read_CMS(in, &cont);
51e71b7053SJung-uk Kim
52e71b7053SJung-uk Kim=head1 BUGS
53e71b7053SJung-uk Kim
54e71b7053SJung-uk KimThe MIME parser used by SMIME_read_CMS() is somewhat primitive.  While it will
55e71b7053SJung-uk Kimhandle most S/MIME messages more complex compound formats may not work.
56e71b7053SJung-uk Kim
57e71b7053SJung-uk KimThe parser assumes that the CMS_ContentInfo structure is always base64 encoded
58e71b7053SJung-uk Kimand will not handle the case where it is in binary format or uses quoted
59e71b7053SJung-uk Kimprintable format.
60e71b7053SJung-uk Kim
61e71b7053SJung-uk KimThe use of a memory BIO to hold the signed content limits the size of message
62e71b7053SJung-uk Kimwhich can be processed due to memory restraints: a streaming single pass option
63e71b7053SJung-uk Kimshould be available.
64e71b7053SJung-uk Kim
65e71b7053SJung-uk Kim=head1 RETURN VALUES
66e71b7053SJung-uk Kim
67*b077aed3SPierre ProncherySMIME_read_CMS_ex() and SMIME_read_CMS() return a valid B<CMS_ContentInfo>
68*b077aed3SPierre Proncherystructure or B<NULL> if an error occurred. The error can be obtained from
69*b077aed3SPierre ProncheryERR_get_error(3).
70e71b7053SJung-uk Kim
71e71b7053SJung-uk Kim=head1 SEE ALSO
72e71b7053SJung-uk Kim
73*b077aed3SPierre ProncheryL<ERR_get_error(3)>,
74*b077aed3SPierre ProncheryL<CMS_sign(3)>,
75*b077aed3SPierre ProncheryL<CMS_verify(3)>,
76*b077aed3SPierre ProncheryL<CMS_encrypt(3)>,
77e71b7053SJung-uk KimL<CMS_decrypt(3)>
78e71b7053SJung-uk Kim
79*b077aed3SPierre Pronchery=head1 HISTORY
80*b077aed3SPierre Pronchery
81*b077aed3SPierre ProncheryThe function SMIME_read_CMS_ex() was added in OpenSSL 3.0.
82*b077aed3SPierre Pronchery
83e71b7053SJung-uk Kim=head1 COPYRIGHT
84e71b7053SJung-uk Kim
85*b077aed3SPierre ProncheryCopyright 2008-2021 The OpenSSL Project Authors. All Rights Reserved.
86e71b7053SJung-uk Kim
87*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
88e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
89e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
90e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
91e71b7053SJung-uk Kim
92e71b7053SJung-uk Kim=cut
93