CMS_ENVELOPEDDATA_CREATE(3ossl)
β¨ CMS_ENVELOPEDDATA_CREATE π
okay bestie, welcome to CMS_ENVELOPEDDATA_CREATE(3ossl) β yes that's the whole name, it's giving long-distance relationship with your keyboard, but we're gonna get through it together π«Ά
This is the one that makes CMS envelopes. Like, the actual envelope. The thing you put stuff in. Iconic behaviour honestly.
πΈ 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);
π DESCRIPTION
So there's four of these girls and they all do basically the same thing, just with different levels of extra β¨
CMS_EnvelopedData_create_ex() builds you a CMS_ContentInfo structure with type NID_pkcs7_enveloped. The cipher is the symmetric cipher you wanna use. The library context libctx and the property query propq get used when pulling algorithms from providers β that's the whole point of the _ex version, she's fancy π
CMS_AuthEnvelopedData_create_ex() builds a CMS_ContentInfo structure with type NID_id_smime_ct_authEnvelopedData. Here cipher is the symmetric AEAD cipher you wanna use. And lowkey important: right now only AES variants with GCM mode are supported. That's it. That's the list. Don't come at me with anything else π The library context libctx and the property query propq are again used when retrieving algorithms from providers.
π¨ okay so this one matters: the algorithm you pass in that cipher parameter must support ASN1 encoding of its parameters. Non-negotiable bestie.
The recipients? You add those later, they don't come pre-loaded. Use CMS_add1_recipient_cert(3) or CMS_add0_recipient_key(3) β pick your fighter π₯
Then you gotta finalize your CMS_ContentInfo structure with CMS_final(3), and then free it with CMS_ContentInfo_free(3). In that order. The way that forgetting to free is a crime against your own memory π
CMS_EnvelopedData_create() and CMS_AuthEnvelopedData_create() are the low-key versions of CMS_EnvelopedData_create_ex() and CMS_AuthEnvelopedData_create_ex() β same energy, except they just use the default values of NULL for both the library context libctx and the property query propq. No thoughts, head empty, defaults on π
π¦ NOTES
So here's the tea: even though CMS_EnvelopedData_create_ex(), CMS_EnvelopedData_create(), CMS_AuthEnvelopedData_create_ex() and CMS_AuthEnvelopedData_create() all allocate you a brand new CMS_ContentInfo structure... applications don't usually call them directly. Like, at all. Fr fr. Most people just use the wrappers CMS_encrypt(3) and CMS_decrypt(3) instead. They're the main characters, these four are the supporting cast π
π RETURN VALUES
If the allocation fails, CMS_EnvelopedData_create_ex(), CMS_EnvelopedData_create(), CMS_AuthEnvelopedData_create_ex(), CMS_AuthEnvelopedData_create(), CMS_AuthEnvelopedData_create(), and CMS_AuthEnvelopedData_create_ex() all return NULL and set an error code β you can grab that with ERR_get_error(3).
Otherwise? They return a pointer to the newly allocated structure. Slay β¨
π SEE ALSO
π HISTORY
- The
CMS_EnvelopedData_create_ex()method was added in OpenSSL 3.0. CMS_AuthEnvelopedData_create()andCMS_AuthEnvelopedData_create_ex()were added in OpenSSL 3.5.
(so yes the auth ones are the babies of the group, born in 3.5, we love a fresh era πΌ)
π COPYRIGHT
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>.
okay that's the whole page bestie, you ate that π go forth and create envelopes responsibly. this was 3.5.9 energy, dated 2026-09-29, and it lives under the name CMS_ENVELOPEDDATA_CREATE(3ossl) β ily, bye π
π«Ά
π¦ 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