
#use wml::openssl-macros area=docs page=CMS_compress

<title>Documents, CMS_compress(3)</title>

<h1>CMS_compress(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
CMS_compress - create a CMS CompressedData structure

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>CMS_compress()</CODE> creates and returns a CMS CompressedData
structure. <STRONG>comp_nid</STRONG>
is the compression algorithm to use or <STRONG>NID_undef</STRONG> to use the default algorithm (zlib compression). <STRONG>in</STRONG> is the content to be compressed.
<STRONG>flags</STRONG> is an optional set of flags.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The only currently supported compression algorithm is zlib using the NID
NID_zlib_compression.

</P>
<P>
If zlib support is not compiled into OpenSSL then
<CODE>CMS_compress()</CODE> will return an error.

</P>
<P>
If the <STRONG>CMS_TEXT</STRONG> flag is set MIME headers for type <STRONG>text/plain</STRONG> are prepended to the data.

</P>
<P>
Normally the supplied content is translated into MIME canonical format (as
required by the S/MIME specifications) if <STRONG>CMS_BINARY</STRONG> is set no translation occurs. This option should be used if the supplied
data is in binary format otherwise the translation will corrupt it. If <STRONG>CMS_BINARY</STRONG> is set then
<STRONG>CMS_TEXT</STRONG> is ignored.

</P>
<P>
If the <STRONG>CMS_STREAM</STRONG> flag is set a partial <STRONG>CMS_ContentInfo</STRONG> structure is returned suitable for streaming I/O: no data is read from the
BIO <STRONG>in</STRONG>.

</P>
<P>
The compressed data is included in the CMS_ContentInfo structure, unless
<STRONG>CMS_DETACHED</STRONG> is set in which case it is omitted. This is rarely used in practice and is
not supported by <CODE>SMIME_write_CMS().</CODE>

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
If the flag <STRONG>CMS_STREAM</STRONG> is set the returned <STRONG>CMS_ContentInfo</STRONG> structure is
<STRONG>not</STRONG> complete and outputting its contents via a function that does not properly
finalize the <STRONG>CMS_ContentInfo</STRONG> structure will give unpredictable results.

</P>
<P>
Several functions including <CODE>SMIME_write_CMS(),</CODE>
<CODE>i2d_CMS_bio_stream(),</CODE> <CODE>PEM_write_bio_CMS_stream()</CODE>
finalize the structure. Alternatively finalization can be performed by
obtaining the streaming ASN1 <STRONG>BIO</STRONG> directly using <CODE>BIO_new_CMS().</CODE>

</P>
<P>
Additional compression parameters such as the zlib compression level cannot
currently be set.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>CMS_compress()</CODE> returns either a CMS_ContentInfo structure or
NULL if an error occurred. The error can be obtained from
<CODE>ERR_get_error(3).</CODE>

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>, <A HREF="../crypto/CMS_uncompress.html#">CMS_uncompress(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>CMS_compress()</CODE> was added to OpenSSL 0.9.8 The <STRONG>CMS_STREAM</STRONG> flag was first supported in OpenSSL 1.0.0.

</P>
:}


