CMS_ENVELOPEDDATA_CREATE(3SSL)

πŸ’Œ CMS_ENVELOPEDDATA_CREATE(3SSL) β€” the CMS_EnvelopedData_create_ex family πŸ’Œ

okay bestie, sit down, hydrate, because we're building CMS envelopes and it's actually not scary. this is the 3SSL manual page for the CMS_EnvelopedData_create_ex, CMS_EnvelopedData_create, CMS_AuthEnvelopedData_create, and CMS_AuthEnvelopedData_create_ex girlies. let's go πŸŽ€

✨ NAME ✨

CMS_EnvelopedData_create_ex, CMS_EnvelopedData_create, CMS_AuthEnvelopedData_create, CMS_AuthEnvelopedData_create_ex β€” Create CMS envelope πŸ’–

yes bestie, all four of them. we stan a family of functions.


✨ SYNOPSIS ✨

#include <openssl/cms.h>

CMS_ContentInfo *
CMS_EnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx,
                            const char *propq);
CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);

CMS_ContentInfo *
CMS_AuthEnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx,
                                const char *propq);
CMS_ContentInfo *CMS_AuthEnvelopedData_create(const EVP_CIPHER *cipher);

look at them. four little functions. so tidy. πŸ’…


✨ DESCRIPTION ✨

so CMS_EnvelopedData_create_ex() makes you a CMS_ContentInfo structure with a type of NID_pkcs7_enveloped. the cipher you hand it is the symmetric cipher it's gonna use, and then the library context libctx and the property query propq get used when it's out here retrieving algorithms from providers. provider girlie energy. 🫢

CMS_AuthEnvelopedData_create_ex() is the same vibe but it creates a CMS_ContentInfo structure with a type of NID_id_smime_ct_authEnvelopedData. the cipher here is the symmetric AEAD cipher you're using, and lowkey the only ones supported rn are AES variants with GCM mode. that's it. that's the roster. πŸ‘‘

and yes β€” the algorithm you pass in the cipher parameter must support ASN1 encoding of its parameters. no ASN1 parameter encoding? no entry. periodt.

now, the recipients? they don't come pre-installed, bestie. you add them later using CMS_add1_recipient_cert(3) or CMS_add0_recipient_key(3). build-a-bear but make it cryptography. 🧸

your CMS_ContentInfo structure then needs to be finalized with CMS_final(3), and after all that it gets freed with CMS_ContentInfo_free(3). that's the whole life cycle. birth, finalize, free. iconic. πŸ¦‹

and the originals β€” CMS_EnvelopedData_create() and CMS_AuthEnvelopedData_create() β€” are literally just the _ex versions but they use the default values of NULL for the library context libctx and the property query propq. same girl, less paperwork. πŸ’–


✨ NOTES ✨

so here's the tea β˜• β€” even though CMS_EnvelopedData_create_ex(), CMS_EnvelopedData_create(), CMS_AuthEnvelopedData_create_ex(), and CMS_AuthEnvelopedData_create() do allocate you a brand new CMS_ContentInfo structure… applications usually don't call them directly. ngl that's just not the move. the wrappers CMS_encrypt(3) and CMS_decrypt(3) are the ones that get used instead. slay for them, honestly. πŸ’…


✨ RETURN VALUES ✨

if the allocation fails, all of these β€” CMS_EnvelopedData_create_ex(), CMS_EnvelopedData_create(), CMS_AuthEnvelopedData_create_ex(), CMS_AuthEnvelopedData_create(), CMS_AuthEnvelopedData_create(), and CMS_AuthEnvelopedData_create_ex() (yes bestie, the original lists CMS_AuthEnvelopedData_create() and CMS_AuthEnvelopedData_create_ex() twice, I'm not making the rules, I just report them 😭) β€” return NULL and set an error code. you can grab that error code with ERR_get_error(3). πŸ™ˆ

otherwise? they return a pointer to the newly allocated structure. a little gift. a present. a CMS_ContentInfo of your very own. 🎁


🌈 SEE ALSO 🌈

go read them. iykyk. ✨


✨ HISTORY ✨

  • the CMS_EnvelopedData_create_ex() method was added in OpenSSL 3.0.
  • CMS_AuthEnvelopedData_create() and CMS_AuthEnvelopedData_create_ex() were added in OpenSSL 3.5.

glow-ups on a timeline, honestly. πŸ“ˆ


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


and that's the whole page, bestie πŸ’œ this was OpenSSL 4.0.3, dated 2026-09-29, and you just read CMS_ENVELOPEDDATA_CREATE(3SSL). go forth and envelop responsibly. mwah 🫢🌸✨

πŸ“¦ where this page comes from