BIO_NEW_CMS(3ossl)
π BIO_new_CMS β the CMS streaming filter BIO π
okay bestie, this is BIO_new_CMS(3ossl) from the OpenSSL manual, and it's genuinely one of the slay-est little streaming functions in the whole crypto lib. sit with me, we're gonna get you fluent π
β¨ NAME β¨
BIO_new_CMS β CMS streaming filter BIO π
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
π¦ DESCRIPTION π¦
So BIO_new_CMS() hands you back a streaming filter BIO chain built on top of cms. Everything the filter spits out gets written to out. And the cute part? Anything you write into that chain gets automatically translated into a BER format CMS structure of the appropriate type. automatic. no manual labour. we love a self-sufficient queen π
π NOTES π
- The chain this function returns behaves like a standard filter BIO. it's not doing anything weird, it's just a filter, periodt.
- It supports non blocking I/O. yes bestie, async girlies, this one's for you.
- Content is processed and streamed on the fly and is not all held in memory at once β which means you can encode very large structures. she's scalable, she's efficient, she's that girl π
- Once all the content has been written through the chain, you must call
BIO_flush()to finalise the structure. do not skip this. do not be casual about this. the structure is not done until you flush. π€ - The
CMS_STREAMflag must be included in the correspondingflagsparameter of thecmscreation function. no flag, no stream, no vibe check passed. π© - If your application wants to write additional data to
out, BIOs should be removed from the chain usingBIO_pop()and freed withBIO_free()β keep doing that until you reachout. If you don't need to write any additional data, you can just callBIO_free_all()to free up the whole chain. tidy. organised. iconic. π§ - Any content written through the filter is used verbatim: no canonical translation is performed. what you put in is what comes out, exactly as-is, no notes.
- You can chain multiple BIOs together to make, for example, a triple wrapped signed, enveloped, signed structure. nested like russian dolls, obsessed. BUT β in that case it is the application's responsibility to set the inner content type of any outer
CMS_ContentInfostructures. that's on you, bestie, not on OpenSSL. π«Ά - Avoid large numbers of small writes through the chain. why? because it'll produce an output consisting of lots of
OCTET STRINGstructures. so messy. so chaotic. not the aesthetic. the fix: prepend aBIO_f_buffer()buffering BIO and it prevents this. buffer first, slay always β¨
π BUGS π
There is currently no corresponding inverse BIO β like, nothing that can decode a CMS structure on the fly. so we can encode streaming-ly but we can't decode streaming-ly. one direction only. it's giving one-way street π
π RETURN VALUES π
BIO_new_CMS() returns a BIO chain when successful, or NULL if an error occurred. and if it errors? you can grab the deets with ERR_get_error(3). she tells you what went wrong, you just gotta ask. π
π SEE ALSO π
π HISTORY π
The BIO_new_CMS() function was added in OpenSSL 1.0.0. an elder icon fr fr. been serving since way back. π«‘
π 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>.
okay that's the whole page bestie, you ate it π
β¨ this was OpenSSL 3.5.9, dated 2026-09-29, and it's the BIO_NEW_CMS(3ossl) man page. go stream something huge, flush it, and free the chain. mwah ππ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms