1*4724848cSchristos=pod 2*4724848cSchristos 3*4724848cSchristos=head1 NAME 4*4724848cSchristos 5*4724848cSchristosCMS_compress - create a CMS CompressedData structure 6*4724848cSchristos 7*4724848cSchristos=head1 SYNOPSIS 8*4724848cSchristos 9*4724848cSchristos #include <openssl/cms.h> 10*4724848cSchristos 11*4724848cSchristos CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); 12*4724848cSchristos 13*4724848cSchristos=head1 DESCRIPTION 14*4724848cSchristos 15*4724848cSchristosCMS_compress() creates and returns a CMS CompressedData structure. B<comp_nid> 16*4724848cSchristosis the compression algorithm to use or B<NID_undef> to use the default 17*4724848cSchristosalgorithm (zlib compression). B<in> is the content to be compressed. 18*4724848cSchristosB<flags> is an optional set of flags. 19*4724848cSchristos 20*4724848cSchristos=head1 NOTES 21*4724848cSchristos 22*4724848cSchristosThe only currently supported compression algorithm is zlib using the NID 23*4724848cSchristosNID_zlib_compression. 24*4724848cSchristos 25*4724848cSchristosIf zlib support is not compiled into OpenSSL then CMS_compress() will return 26*4724848cSchristosan error. 27*4724848cSchristos 28*4724848cSchristosIf the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are 29*4724848cSchristosprepended to the data. 30*4724848cSchristos 31*4724848cSchristosNormally the supplied content is translated into MIME canonical format (as 32*4724848cSchristosrequired by the S/MIME specifications) if B<CMS_BINARY> is set no translation 33*4724848cSchristosoccurs. This option should be used if the supplied data is in binary format 34*4724848cSchristosotherwise the translation will corrupt it. If B<CMS_BINARY> is set then 35*4724848cSchristosB<CMS_TEXT> is ignored. 36*4724848cSchristos 37*4724848cSchristosIf the B<CMS_STREAM> flag is set a partial B<CMS_ContentInfo> structure is 38*4724848cSchristosreturned suitable for streaming I/O: no data is read from the BIO B<in>. 39*4724848cSchristos 40*4724848cSchristosThe compressed data is included in the CMS_ContentInfo structure, unless 41*4724848cSchristosB<CMS_DETACHED> is set in which case it is omitted. This is rarely used in 42*4724848cSchristospractice and is not supported by SMIME_write_CMS(). 43*4724848cSchristos 44*4724848cSchristos=head1 NOTES 45*4724848cSchristos 46*4724848cSchristosIf the flag B<CMS_STREAM> is set the returned B<CMS_ContentInfo> structure is 47*4724848cSchristosB<not> complete and outputting its contents via a function that does not 48*4724848cSchristosproperly finalize the B<CMS_ContentInfo> structure will give unpredictable 49*4724848cSchristosresults. 50*4724848cSchristos 51*4724848cSchristosSeveral functions including SMIME_write_CMS(), i2d_CMS_bio_stream(), 52*4724848cSchristosPEM_write_bio_CMS_stream() finalize the structure. Alternatively finalization 53*4724848cSchristoscan be performed by obtaining the streaming ASN1 B<BIO> directly using 54*4724848cSchristosBIO_new_CMS(). 55*4724848cSchristos 56*4724848cSchristosAdditional compression parameters such as the zlib compression level cannot 57*4724848cSchristoscurrently be set. 58*4724848cSchristos 59*4724848cSchristos=head1 RETURN VALUES 60*4724848cSchristos 61*4724848cSchristosCMS_compress() returns either a CMS_ContentInfo structure or NULL if an error 62*4724848cSchristosoccurred. The error can be obtained from ERR_get_error(3). 63*4724848cSchristos 64*4724848cSchristos=head1 SEE ALSO 65*4724848cSchristos 66*4724848cSchristosL<ERR_get_error(3)>, L<CMS_uncompress(3)> 67*4724848cSchristos 68*4724848cSchristos=head1 HISTORY 69*4724848cSchristos 70*4724848cSchristosThe B<CMS_STREAM> flag was added in OpenSSL 1.0.0. 71*4724848cSchristos 72*4724848cSchristos=head1 COPYRIGHT 73*4724848cSchristos 74*4724848cSchristosCopyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. 75*4724848cSchristos 76*4724848cSchristosLicensed under the OpenSSL license (the "License"). You may not use 77*4724848cSchristosthis file except in compliance with the License. You can obtain a copy 78*4724848cSchristosin the file LICENSE in the source distribution or at 79*4724848cSchristosL<https://www.openssl.org/source/license.html>. 80*4724848cSchristos 81*4724848cSchristos=cut 82