1238384Sjkim=pod 2238384Sjkim 3238384Sjkim=head1 NAME 4238384Sjkim 5238384Sjkim SMIME_read_CMS - parse S/MIME message. 6238384Sjkim 7238384Sjkim=head1 SYNOPSIS 8238384Sjkim 9238384Sjkim #include <openssl/cms.h> 10238384Sjkim 11238384Sjkim CMS_ContentInfo *SMIME_read_CMS(BIO *in, BIO **bcont); 12238384Sjkim 13238384Sjkim=head1 DESCRIPTION 14238384Sjkim 15238384SjkimSMIME_read_CMS() parses a message in S/MIME format. 16238384Sjkim 17238384SjkimB<in> is a BIO to read the message from. 18238384Sjkim 19238384SjkimIf cleartext signing is used then the content is saved in a memory bio which is 20238384Sjkimwritten to B<*bcont>, otherwise B<*bcont> is set to NULL. 21238384Sjkim 22238384SjkimThe parsed CMS_ContentInfo structure is returned or NULL if an 23238384Sjkimerror occurred. 24238384Sjkim 25238384Sjkim=head1 NOTES 26238384Sjkim 27238384SjkimIf B<*bcont> is not NULL then the message is clear text signed. B<*bcont> can 28238384Sjkimthen be passed to CMS_verify() with the B<CMS_DETACHED> flag set. 29238384Sjkim 30238384SjkimOtherwise the type of the returned structure can be determined 31238384Sjkimusing CMS_get0_type(). 32238384Sjkim 33238384SjkimTo support future functionality if B<bcont> is not NULL B<*bcont> should be 34238384Sjkiminitialized to NULL. For example: 35238384Sjkim 36238384Sjkim BIO *cont = NULL; 37238384Sjkim CMS_ContentInfo *cms; 38238384Sjkim 39238384Sjkim cms = SMIME_read_CMS(in, &cont); 40238384Sjkim 41238384Sjkim=head1 BUGS 42238384Sjkim 43238384SjkimThe MIME parser used by SMIME_read_CMS() is somewhat primitive. While it will 44238384Sjkimhandle most S/MIME messages more complex compound formats may not work. 45238384Sjkim 46238384SjkimThe parser assumes that the CMS_ContentInfo structure is always base64 encoded 47238384Sjkimand will not handle the case where it is in binary format or uses quoted 48238384Sjkimprintable format. 49238384Sjkim 50238384SjkimThe use of a memory BIO to hold the signed content limits the size of message 51238384Sjkimwhich can be processed due to memory restraints: a streaming single pass option 52238384Sjkimshould be available. 53238384Sjkim 54238384Sjkim=head1 RETURN VALUES 55238384Sjkim 56238384SjkimSMIME_read_CMS() returns a valid B<CMS_ContentInfo> structure or B<NULL> 57238384Sjkimif an error occurred. The error can be obtained from ERR_get_error(3). 58238384Sjkim 59238384Sjkim=head1 SEE ALSO 60238384Sjkim 61238384SjkimL<ERR_get_error(3)|ERR_get_error(3)>, L<CMS_type(3)|CMS_type(3)> 62238384SjkimL<SMIME_read_CMS(3)|SMIME_read_CMS(3)>, L<CMS_sign(3)|CMS_sign(3)>, 63238384SjkimL<CMS_verify(3)|CMS_verify(3)>, L<CMS_encrypt(3)|CMS_encrypt(3)> 64238384SjkimL<CMS_decrypt(3)|CMS_decrypt(3)> 65238384Sjkim 66238384Sjkim=head1 HISTORY 67238384Sjkim 68238384SjkimSMIME_read_CMS() was added to OpenSSL 0.9.8 69238384Sjkim 70238384Sjkim=cut 71