CMS_COMPRESS(3ossl)
π CMS_compress β create a CMS CompressedData structure π
okay bestie, welcome to the CMS_COMPRESS(3ossl) page β¨ this is the OpenSSL manual for CMS_compress(), and it's lowkey the glow-up moment where you make a CMS CompressedData structure. no cap, the facts below are all main-character.
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
β¨ DESCRIPTION β¨
CMS_compress() creates and returns a CMS_ContentInfo structure, and it's giving CompressedData energy π comp_nid is the compression algorithm to use, or NID_undef to use the default algorithm (which is zlib compression). in is the content to be compressed. flags is an optional set of flags. periodt.
The only currently supported compression algorithm is zlib using the NID NID_zlib_compression. iykyk.
if zlib support is not compiled into OpenSSL, then CMS_compress() will return an error. not me finding out when it errors π
Now the flag vibe check:
CMS_TEXTβ when this flag is set, MIME headers for typetext/plainare prepended to the data. cute.CMS_BINARYβ normally the supplied content is translated into MIME canonical format (as required by the S/MIME specifications), but ifCMS_BINARYis set, no translation occurs. use this if the supplied data is in binary format, otherwise the translation will corrupt it π also, ifCMS_BINARYis set, thenCMS_TEXTis ignored.CMS_STREAMβ if this flag is set, a partialCMS_ContentInfostructure is returned that's suitable for streaming I/O: no data is read from the BIOin. iconic behavior.CMS_DETACHEDβ the compressed data is included in theCMS_ContentInfostructure unlessCMS_DETACHEDis set, in which case it's omitted. this is rarely used in practice and is not supported bySMIME_write_CMS(). noted π«Ά
β οΈ if the flagCMS_STREAMis set, the returnedCMS_ContentInfostructure is not complete. outputting its contents via a function that doesn't properly finalize theCMS_ContentInfostructure will give unpredictable results. that's the drama we don't want.
Several functions finalize the structure, including SMIME_write_CMS(), i2d_CMS_bio_stream(), and PEM_write_bio_CMS_stream(). alternatively, finalization can be performed by obtaining the streaming ASN1 BIO directly using BIO_new_CMS(). slay.
Additional compression parameters such as the zlib compression level cannot currently be set. sad, but true.
π 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). no guessing, bestie.
π SEE ALSO π
ERR_get_error(3), CMS_uncompress(3)
π¦ HISTORY π¦
The CMS_STREAM flag was added in OpenSSL 1.0.0. a little throwback β¨
π COPYRIGHT π
Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
stay compressed, bestie π this page is from OpenSSL 3.5.0, dated 2026-09-25.
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms