BIO_NEW_CMS(3SSL)

πŸ’– BIO_new_CMS β€” CMS streaming filter BIO πŸ’–

okay bestie, welcome to the <openssl/cms.h> section of the manual (yes this is the BIO_NEW_CMS(3SSL) page, we're doing this, sit down, hydrate πŸ“)


✨ NAME ✨

BIO_new_CMS β€” a CMS streaming filter BIO. it's giving filter. it's giving stream. it's iconic πŸ‘‘


🌸 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 off of cms. everything the filter spits out gets written to out. and the way that any data you write into that chain just automatically gets translated into a BER format CMS structure of the appropriate type?? obsessed. genuinely. no cap πŸ’…


πŸŽ€ NOTES πŸŽ€

  • the chain that comes back behaves exactly like a standard filter BIO. standard filter BIO behaviour, periodt.
  • it supports non blocking I/O ✨
  • content gets processed and streamed on the fly β€” it is not all held in memory at once, so bestie you can encode very large structures if you want to. main character energy 🫢
  • once all your content has been written through the chain, you must call BIO_flush() to finalise the structure. do not skip this. it's not optional, it's the whole vibe check 😀
  • the CMS_STREAM flag must be included in the corresponding flags parameter of the cms creation function. must. fr fr.
  • if the application wants to write additional data to out, BIOs should be removed from the chain using BIO_pop() and freed with BIO_free() until out is reached. if no additional data needs writing, BIO_free_all() can be called to free the whole chain. pick your fighter πŸ’€
  • any content written through the filter is used verbatim β€” no canonical translation is performed. none. zero. what you wrote is what you get πŸ™ˆ
  • you can chain multiple BIOs together to, like, create a triple wrapped signed, enveloped, signed structure (a slay within a slay within a slay πŸ’–). but heads up: in that case it's the application's responsibility to set the inner content type of any outer CMS_ContentInfo structures. that's on you, not on us 🌈
  • large numbers of small writes through the chain should be avoided, because that produces an output consisting of lots of OCTET STRING structures (a mess, a literal mess 😭). prepending a BIO_f_buffer() buffering BIO will prevent this. do it. your output will thank you. ⭐

πŸ’€ BUGS πŸ’€

there is currently no corresponding inverse BIO β€” like, no BIO that can decode a CMS structure on the fly. it doesn't exist yet bestie, we're all just coping πŸ™ˆ


⭐ RETURN VALUES ⭐

BIO_new_CMS() returns a BIO chain when it's successful πŸŽ‰ or NULL if an error occurred 😭. you can get the error from ERR_get_error(3).


🌈 SEE ALSO 🌈

ERR_get_error(3), CMS_sign(3), CMS_encrypt(3)


πŸ‘‘ HISTORY πŸ‘‘

the BIO_new_CMS() function was added in OpenSSL 1.0.0. an OG. a legend. respect the elders 🫢


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, go forth and stream your CMS structures responsibly πŸ’…βœ¨

OpenSSL 4.0.3 Β· 2026-09-29 Β· BIO_NEW_CMS(3SSL) β€” mwah, that's a wrap πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from