xref: /freebsd/crypto/openssl/doc/man3/CMS_compress.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimCMS_compress - create a CMS CompressedData structure
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/cms.h>
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim=head1 DESCRIPTION
14e71b7053SJung-uk Kim
15e71b7053SJung-uk KimCMS_compress() creates and returns a CMS CompressedData structure. B<comp_nid>
16e71b7053SJung-uk Kimis the compression algorithm to use or B<NID_undef> to use the default
17e71b7053SJung-uk Kimalgorithm (zlib compression). B<in> is the content to be compressed.
18e71b7053SJung-uk KimB<flags> is an optional set of flags.
19e71b7053SJung-uk Kim
20e71b7053SJung-uk KimThe only currently supported compression algorithm is zlib using the NID
21e71b7053SJung-uk KimNID_zlib_compression.
22e71b7053SJung-uk Kim
23e71b7053SJung-uk KimIf zlib support is not compiled into OpenSSL then CMS_compress() will return
24e71b7053SJung-uk Kiman error.
25e71b7053SJung-uk Kim
26e71b7053SJung-uk KimIf the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are
27e71b7053SJung-uk Kimprepended to the data.
28e71b7053SJung-uk Kim
29e71b7053SJung-uk KimNormally the supplied content is translated into MIME canonical format (as
30e71b7053SJung-uk Kimrequired by the S/MIME specifications) if B<CMS_BINARY> is set no translation
31e71b7053SJung-uk Kimoccurs. This option should be used if the supplied data is in binary format
32e71b7053SJung-uk Kimotherwise the translation will corrupt it. If B<CMS_BINARY> is set then
33e71b7053SJung-uk KimB<CMS_TEXT> is ignored.
34e71b7053SJung-uk Kim
35e71b7053SJung-uk KimIf the B<CMS_STREAM> flag is set a partial B<CMS_ContentInfo> structure is
36e71b7053SJung-uk Kimreturned suitable for streaming I/O: no data is read from the BIO B<in>.
37e71b7053SJung-uk Kim
38e71b7053SJung-uk KimThe compressed data is included in the CMS_ContentInfo structure, unless
39e71b7053SJung-uk KimB<CMS_DETACHED> is set in which case it is omitted. This is rarely used in
40e71b7053SJung-uk Kimpractice and is not supported by SMIME_write_CMS().
41e71b7053SJung-uk Kim
42e71b7053SJung-uk KimIf the flag B<CMS_STREAM> is set the returned B<CMS_ContentInfo> structure is
43e71b7053SJung-uk KimB<not> complete and outputting its contents via a function that does not
44e71b7053SJung-uk Kimproperly finalize the B<CMS_ContentInfo> structure will give unpredictable
45e71b7053SJung-uk Kimresults.
46e71b7053SJung-uk Kim
47e71b7053SJung-uk KimSeveral functions including SMIME_write_CMS(), i2d_CMS_bio_stream(),
48e71b7053SJung-uk KimPEM_write_bio_CMS_stream() finalize the structure. Alternatively finalization
49e71b7053SJung-uk Kimcan be performed by obtaining the streaming ASN1 B<BIO> directly using
50e71b7053SJung-uk KimBIO_new_CMS().
51e71b7053SJung-uk Kim
52e71b7053SJung-uk KimAdditional compression parameters such as the zlib compression level cannot
53e71b7053SJung-uk Kimcurrently be set.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk Kim=head1 RETURN VALUES
56e71b7053SJung-uk Kim
57e71b7053SJung-uk KimCMS_compress() returns either a CMS_ContentInfo structure or NULL if an error
58e71b7053SJung-uk Kimoccurred. The error can be obtained from ERR_get_error(3).
59e71b7053SJung-uk Kim
60e71b7053SJung-uk Kim=head1 SEE ALSO
61e71b7053SJung-uk Kim
62e71b7053SJung-uk KimL<ERR_get_error(3)>, L<CMS_uncompress(3)>
63e71b7053SJung-uk Kim
64e71b7053SJung-uk Kim=head1 HISTORY
65e71b7053SJung-uk Kim
66e71b7053SJung-uk KimThe B<CMS_STREAM> flag was added in OpenSSL 1.0.0.
67e71b7053SJung-uk Kim
68e71b7053SJung-uk Kim=head1 COPYRIGHT
69e71b7053SJung-uk Kim
70e71b7053SJung-uk KimCopyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
71e71b7053SJung-uk Kim
72*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
73e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
74e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
75e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
76e71b7053SJung-uk Kim
77e71b7053SJung-uk Kim=cut
78