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