CMS_DATA_CREATE(3ossl)

πŸ’– CMS_DATA_CREATE(3ossl) πŸ’–

okay so bestie, welcome to CMS_DATA_CREATE(3ossl) β€” the manual page for making a CMS Data object. it's giving "small but mighty", it's giving "two functions, one job", and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

CMS_data_create_ex, CMS_data_create β€” Create CMS Data object πŸ¦‹


🌸 SYNOPSIS 🌸

#include <openssl/cms.h>

CMS_ContentInfo *CMS_data_create_ex(BIO *in, unsigned int flags,
                                    OSSL_LIB_CTX *libctx, const char *propq);
CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);

no cap, that's the whole thing. copy it exactly, don't get creative with it. πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

so like, CMS_data_create_ex() builds you a CMS_ContentInfo structure and sets its type to NID_pkcs7_data. that's the vibe. the actual data? it comes in through the in BIO. 🫢

when it's pulling algorithms from providers, it uses the library context libctx and the property query propq. those two are your plug-ins for where the crypto comes from.

the flags field supports the CMS_STREAM flag. and here's the tea: internally, CMS_final() gets called unless CMS_STREAM is specified. so if you don't ask for streaming, it's getting finalized for you, whether you were ready or not. 😭

once you're done with the CMS_ContentInfo structure, you can free it with CMS_ContentInfo_free(3). clean up after yourself, queen. 🧹✨

and CMS_data_create()? it's literally the same as CMS_data_create_ex(), except it uses default values of NULL for the library context libctx and the property query propq. so if you don't care about that stuff, take the shortcut, it's fine. πŸ™ˆ


⭐ RETURN VALUES ⭐

  • if the allocation fails, CMS_data_create_ex() and CMS_data_create() return NULL and set an error code you can grab with ERR_get_error(3). not a slay, but at least it tells you why. πŸ’€
  • otherwise, they return a pointer to the newly allocated structure. main character pointer energy. πŸ‘‘

🌈 SEE ALSO 🌈

go read those too, iykyk. πŸ“š


πŸ’œ HISTORY πŸ’œ

CMS_data_create_ex() was added in OpenSSL 3.0. so it's new-ish, it's fresh, it's got lore. ✨


Copyright 2020-2021 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>.


real talk: use it responsibly, read your licenses, and never skip the CMS_STREAM caveat. that's the whole plot twist. πŸ’…

and that's the page!! from the OpenSSL girlies, version 3.5.9, dated 2026-09-29 β€” mwah, xoxo, go create some CMS Data objects bestie πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from