xref: /freebsd/crypto/openssl/doc/man3/SMIME_read_PKCS7.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5*b077aed3SPierre ProncherySMIME_read_PKCS7_ex, SMIME_read_PKCS7 - parse S/MIME message
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/pkcs7.h>
10e71b7053SJung-uk Kim
11*b077aed3SPierre Pronchery PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7);
12e71b7053SJung-uk Kim PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont);
13e71b7053SJung-uk Kim
14e71b7053SJung-uk Kim=head1 DESCRIPTION
15e71b7053SJung-uk Kim
16e71b7053SJung-uk KimSMIME_read_PKCS7() parses a message in S/MIME format.
17e71b7053SJung-uk Kim
18e71b7053SJung-uk KimB<in> is a BIO to read the message from.
19e71b7053SJung-uk Kim
20e71b7053SJung-uk KimIf cleartext signing is used then the content is saved in
21e71b7053SJung-uk Kima memory bio which is written to B<*bcont>, otherwise
22e71b7053SJung-uk KimB<*bcont> is set to B<NULL>.
23e71b7053SJung-uk Kim
24e71b7053SJung-uk KimThe parsed PKCS#7 structure is returned or B<NULL> if an
25e71b7053SJung-uk Kimerror occurred.
26e71b7053SJung-uk Kim
27*b077aed3SPierre ProncherySMIME_read_PKCS7_ex() is similar to SMIME_read_PKCS7() but can optionally supply
28*b077aed3SPierre Proncherya previously created I<p7> PKCS#7 object. If I<p7> is NULL then it is identical
29*b077aed3SPierre Proncheryto SMIME_read_PKCS7().
30*b077aed3SPierre ProncheryTo create a I<p7> object use L<PKCS7_new_ex(3)>.
31*b077aed3SPierre Pronchery
32e71b7053SJung-uk Kim=head1 NOTES
33e71b7053SJung-uk Kim
34e71b7053SJung-uk KimIf B<*bcont> is not B<NULL> then the message is clear text
35e71b7053SJung-uk Kimsigned. B<*bcont> can then be passed to PKCS7_verify() with
36e71b7053SJung-uk Kimthe B<PKCS7_DETACHED> flag set.
37e71b7053SJung-uk Kim
38e71b7053SJung-uk KimOtherwise the type of the returned structure can be determined
39e71b7053SJung-uk Kimusing PKCS7_type_is_enveloped(), etc.
40e71b7053SJung-uk Kim
41e71b7053SJung-uk KimTo support future functionality if B<bcont> is not B<NULL>
42e71b7053SJung-uk KimB<*bcont> should be initialized to B<NULL>. For example:
43e71b7053SJung-uk Kim
44e71b7053SJung-uk Kim BIO *cont = NULL;
45e71b7053SJung-uk Kim PKCS7 *p7;
46e71b7053SJung-uk Kim
47e71b7053SJung-uk Kim p7 = SMIME_read_PKCS7(in, &cont);
48e71b7053SJung-uk Kim
49e71b7053SJung-uk Kim=head1 BUGS
50e71b7053SJung-uk Kim
51e71b7053SJung-uk KimThe MIME parser used by SMIME_read_PKCS7() is somewhat primitive.
52e71b7053SJung-uk KimWhile it will handle most S/MIME messages more complex compound
53e71b7053SJung-uk Kimformats may not work.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk KimThe parser assumes that the PKCS7 structure is always base64
56e71b7053SJung-uk Kimencoded and will not handle the case where it is in binary format
57e71b7053SJung-uk Kimor uses quoted printable format.
58e71b7053SJung-uk Kim
59e71b7053SJung-uk KimThe use of a memory BIO to hold the signed content limits the size
60e71b7053SJung-uk Kimof message which can be processed due to memory restraints: a
61e71b7053SJung-uk Kimstreaming single pass option should be available.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk Kim=head1 RETURN VALUES
64e71b7053SJung-uk Kim
65*b077aed3SPierre ProncherySMIME_read_PKCS7_ex() and SMIME_read_PKCS7() return a valid B<PKCS7> structure
66*b077aed3SPierre Proncheryor B<NULL> if an error occurred. The error can be obtained from ERR_get_error(3).
67e71b7053SJung-uk Kim
68e71b7053SJung-uk Kim=head1 SEE ALSO
69e71b7053SJung-uk Kim
70e71b7053SJung-uk KimL<ERR_get_error(3)>,
71e71b7053SJung-uk KimL<SMIME_read_PKCS7(3)>, L<PKCS7_sign(3)>,
72e71b7053SJung-uk KimL<PKCS7_verify(3)>, L<PKCS7_encrypt(3)>
73e71b7053SJung-uk KimL<PKCS7_decrypt(3)>
74e71b7053SJung-uk Kim
75*b077aed3SPierre Pronchery=head1 HISTORY
76*b077aed3SPierre Pronchery
77*b077aed3SPierre ProncheryThe function SMIME_read_PKCS7_ex() was added in OpenSSL 3.0.
78*b077aed3SPierre Pronchery
79e71b7053SJung-uk Kim=head1 COPYRIGHT
80e71b7053SJung-uk Kim
81*b077aed3SPierre ProncheryCopyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
82e71b7053SJung-uk Kim
83*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
84e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
85e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
86e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
87e71b7053SJung-uk Kim
88e71b7053SJung-uk Kim=cut
89