---
name: "libressl-CMS_compress"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-CMS_compress"
---

# libressl-CMS\_compress(3)

create a CMS CompressedData structure

## NAME

**CMS\_compress** – create a CMS CompressedData structure

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/cms.h\>**

*CMS\_ContentInfo* *\**\

**CMS\_compress**(*BIO \*in*, *int comp\_nid*, *unsigned int flags*);

## DESCRIPTION

**CMS\_compress**() creates and returns a CMS *CompressedData* structure.

*comp\_nid* is the compression algorithm to use or NID\_undef to use the default algorithm. Currently, the default algorithm NID\_zlib\_compression is the only supported algorithm. If zlib support is not compiled in, **CMS\_compress**() always returns an error.

*in* provides the content to be compressed.

Any of the following flags (OR'ed together) can be passed in the *flags* parameter:

- CMS\_TEXT

  Prepend MIME headers for type text/plain to the data.

- CMS\_BINARY

  Do not translate the supplied content into MIME canonical format, even though that is required by the S/MIME specifications. This option should be used if the supplied data is in binary format. Otherwise, the translation will corrupt it. If CMS\_BINARY is set, CMS\_TEXT is ignored.

- CMS\_STREAM

  Return a partial *CMS\_ContentInfo* structure suitable for streaming I/O: no data is read from *in*. Several functions including SMIME\_write\_CMS(3), i2d\_CMS\_bio\_stream(3), or PEM\_write\_bio\_CMS\_stream(3) can be used to finalize the structure. Alternatively, finalization can be performed by obtaining the streaming ASN1 *BIO* directly using BIO\_new\_CMS(3). Outputting the contents of the *CMS\_ContentInfo* structure via a function that does not properly finalize it will give unpredictable results.

- CMS\_DETACHED

  Do not include the compressed data in the *CMS\_ContentInfo* structure. This is rarely used in practice and is not supported by SMIME\_write\_CMS(3).

Additional compression parameters such as the zlib compression level cannot currently be set.

## RETURN VALUES

**CMS\_compress**() returns either a *CMS\_ContentInfo* structure or NULL if an error occurred. The error can be obtained from ERR\_get\_error(3).

## SEE ALSO

CMS\_ContentInfo\_new(3), CMS\_uncompress(3)

## STANDARDS

RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)

## HISTORY

**CMS\_compress**() first appeared in OpenSSL 0.9.8h and has been available since OpenBSD 6.7.

The CMS\_STREAM flag first appeared in OpenSSL 1.0.0.
