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