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