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