113d40330Schristos=pod 213d40330Schristos 313d40330Schristos=head1 NAME 413d40330Schristos 513d40330SchristosCMS_compress - create a CMS CompressedData structure 613d40330Schristos 713d40330Schristos=head1 SYNOPSIS 813d40330Schristos 913d40330Schristos #include <openssl/cms.h> 1013d40330Schristos 1113d40330Schristos CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); 1213d40330Schristos 1313d40330Schristos=head1 DESCRIPTION 1413d40330Schristos 1513d40330SchristosCMS_compress() creates and returns a CMS CompressedData structure. B<comp_nid> 1613d40330Schristosis the compression algorithm to use or B<NID_undef> to use the default 1713d40330Schristosalgorithm (zlib compression). B<in> is the content to be compressed. 1813d40330SchristosB<flags> is an optional set of flags. 1913d40330Schristos 2013d40330SchristosThe only currently supported compression algorithm is zlib using the NID 2113d40330SchristosNID_zlib_compression. 2213d40330Schristos 2313d40330SchristosIf zlib support is not compiled into OpenSSL then CMS_compress() will return 2413d40330Schristosan error. 2513d40330Schristos 2613d40330SchristosIf the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are 2713d40330Schristosprepended to the data. 2813d40330Schristos 2913d40330SchristosNormally the supplied content is translated into MIME canonical format (as 3013d40330Schristosrequired by the S/MIME specifications) if B<CMS_BINARY> is set no translation 3113d40330Schristosoccurs. This option should be used if the supplied data is in binary format 3213d40330Schristosotherwise the translation will corrupt it. If B<CMS_BINARY> is set then 3313d40330SchristosB<CMS_TEXT> is ignored. 3413d40330Schristos 3513d40330SchristosIf the B<CMS_STREAM> flag is set a partial B<CMS_ContentInfo> structure is 3613d40330Schristosreturned suitable for streaming I/O: no data is read from the BIO B<in>. 3713d40330Schristos 3813d40330SchristosThe compressed data is included in the CMS_ContentInfo structure, unless 3913d40330SchristosB<CMS_DETACHED> is set in which case it is omitted. This is rarely used in 4013d40330Schristospractice and is not supported by SMIME_write_CMS(). 4113d40330Schristos 4213d40330SchristosIf the flag B<CMS_STREAM> is set the returned B<CMS_ContentInfo> structure is 4313d40330SchristosB<not> complete and outputting its contents via a function that does not 4413d40330Schristosproperly finalize the B<CMS_ContentInfo> structure will give unpredictable 4513d40330Schristosresults. 4613d40330Schristos 4713d40330SchristosSeveral functions including SMIME_write_CMS(), i2d_CMS_bio_stream(), 4813d40330SchristosPEM_write_bio_CMS_stream() finalize the structure. Alternatively finalization 4913d40330Schristoscan be performed by obtaining the streaming ASN1 B<BIO> directly using 5013d40330SchristosBIO_new_CMS(). 5113d40330Schristos 5213d40330SchristosAdditional compression parameters such as the zlib compression level cannot 5313d40330Schristoscurrently be set. 5413d40330Schristos 5513d40330Schristos=head1 RETURN VALUES 5613d40330Schristos 5713d40330SchristosCMS_compress() returns either a CMS_ContentInfo structure or NULL if an error 5813d40330Schristosoccurred. The error can be obtained from ERR_get_error(3). 5913d40330Schristos 6013d40330Schristos=head1 SEE ALSO 6113d40330Schristos 6213d40330SchristosL<ERR_get_error(3)>, L<CMS_uncompress(3)> 6313d40330Schristos 6413d40330Schristos=head1 HISTORY 6513d40330Schristos 6613d40330SchristosThe B<CMS_STREAM> flag was added in OpenSSL 1.0.0. 6713d40330Schristos 6813d40330Schristos=head1 COPYRIGHT 6913d40330Schristos 7013d40330SchristosCopyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. 7113d40330Schristos 72*b0d17251SchristosLicensed under the Apache License 2.0 (the "License"). You may not use 7313d40330Schristosthis file except in compliance with the License. You can obtain a copy 7413d40330Schristosin the file LICENSE in the source distribution or at 7513d40330SchristosL<https://www.openssl.org/source/license.html>. 7613d40330Schristos 7713d40330Schristos=cut 78