1.\" $OpenBSD: CMS_compress.3,v 1.7 2019/11/02 15:39:46 schwarze Exp $ 2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" 4.\" This file is a derived work. 5.\" The changes are covered by the following Copyright and license: 6.\" 7.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 8.\" 9.\" Permission to use, copy, modify, and distribute this software for any 10.\" purpose with or without fee is hereby granted, provided that the above 11.\" copyright notice and this permission notice appear in all copies. 12.\" 13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20.\" 21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>. 22.\" Copyright (c) 2008 The OpenSSL Project. All rights reserved. 23.\" 24.\" Redistribution and use in source and binary forms, with or without 25.\" modification, are permitted provided that the following conditions 26.\" are met: 27.\" 28.\" 1. Redistributions of source code must retain the above copyright 29.\" notice, this list of conditions and the following disclaimer. 30.\" 31.\" 2. Redistributions in binary form must reproduce the above copyright 32.\" notice, this list of conditions and the following disclaimer in 33.\" the documentation and/or other materials provided with the 34.\" distribution. 35.\" 36.\" 3. All advertising materials mentioning features or use of this 37.\" software must display the following acknowledgment: 38.\" "This product includes software developed by the OpenSSL Project 39.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 40.\" 41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 42.\" endorse or promote products derived from this software without 43.\" prior written permission. For written permission, please contact 44.\" openssl-core@openssl.org. 45.\" 46.\" 5. Products derived from this software may not be called "OpenSSL" 47.\" nor may "OpenSSL" appear in their names without prior written 48.\" permission of the OpenSSL Project. 49.\" 50.\" 6. Redistributions of any form whatsoever must retain the following 51.\" acknowledgment: 52.\" "This product includes software developed by the OpenSSL Project 53.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 54.\" 55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 58.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" 68.Dd $Mdocdate: November 2 2019 $ 69.Dt CMS_COMPRESS 3 70.Os 71.Sh NAME 72.Nm CMS_compress 73.Nd create a CMS CompressedData structure 74.Sh SYNOPSIS 75.In openssl/cms.h 76.Ft CMS_ContentInfo * 77.Fo CMS_compress 78.Fa "BIO *in" 79.Fa "int comp_nid" 80.Fa "unsigned int flags" 81.Fc 82.Sh DESCRIPTION 83.Fn CMS_compress 84creates and returns a CMS 85.Vt CompressedData 86structure. 87.Pp 88.Fa comp_nid 89is the compression algorithm to use or 90.Dv NID_undef 91to use the default algorithm. 92Currently, the default algorithm 93.Dv NID_zlib_compression 94is the only supported algorithm. 95If zlib support is not compiled in, 96.Fn CMS_compress 97always returns an error. 98.Pp 99.Fa in 100provides the content to be compressed. 101.Pp 102Any of the following flags (OR'ed together) can be passed in the 103.Fa flags 104parameter: 105.Bl -tag -width Ds 106.It Dv CMS_TEXT 107Prepend MIME headers for type text/plain to the data. 108.It Dv CMS_BINARY 109Do not translate the supplied content into MIME canonical format, 110even though that is required by the S/MIME specifications. 111This option should be used if the supplied data is in binary format. 112Otherwise, the translation will corrupt it. 113If 114.Dv CMS_BINARY 115is set, 116.Dv CMS_TEXT 117is ignored. 118.It Dv CMS_STREAM 119Return a partial 120.Vt CMS_ContentInfo 121structure suitable for streaming I/O: no data is read from 122.Fa in . 123Several functions including 124.Xr SMIME_write_CMS 3 , 125.Xr i2d_CMS_bio_stream 3 , 126or 127.Xr PEM_write_bio_CMS_stream 3 128can be used to finalize the structure. 129Alternatively, finalization can be performed by obtaining the streaming 130ASN1 131.Vt BIO 132directly using 133.Xr BIO_new_CMS 3 . 134Outputting the contents of the 135.Vt CMS_ContentInfo 136structure via a function that does not 137properly finalize it will give unpredictable results. 138.It Dv CMS_DETACHED 139Do not include the compressed data in the 140.Vt CMS_ContentInfo 141structure. 142This is rarely used in practice and is not supported by 143.Xr SMIME_write_CMS 3 . 144.El 145.Pp 146Additional compression parameters such as the zlib compression level 147cannot currently be set. 148.Sh RETURN VALUES 149.Fn CMS_compress 150returns either a 151.Vt CMS_ContentInfo 152structure or 153.Dv NULL 154if an error occurred. 155The error can be obtained from 156.Xr ERR_get_error 3 . 157.Sh SEE ALSO 158.Xr CMS_ContentInfo_new 3 , 159.Xr CMS_uncompress 3 160.Sh STANDARDS 161RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS) 162.Sh HISTORY 163.Fn CMS_compress 164first appeared in OpenSSL 0.9.8h 165and has been available since 166.Ox 6.7 . 167.Pp 168The 169.Dv CMS_STREAM 170flag first appeared in OpenSSL 1.0.0. 171