CMS\_ENVELOPEDDATA\_CREATE(3ossl) OpenSSL CMS\_ENVELOPEDDATA\_CREATE(3ossl)

# [NAME](#NAME)

CMS\_EnvelopedData\_create\_ex, CMS\_EnvelopedData\_create, CMS\_AuthEnvelopedData\_create, CMS\_AuthEnvelopedData\_create\_ex - Create CMS envelope

# [SYNOPSIS](#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](#DESCRIPTION)

**CMS\_EnvelopedData\_create\_ex()** creates a **CMS\_ContentInfo** structure with a type **NID\_pkcs7\_enveloped**. *cipher* is the symmetric cipher to use. The library context *libctx* and the property query *propq* are used when retrieving algorithms from providers.

**CMS\_AuthEnvelopedData\_create\_ex()** creates a **CMS\_ContentInfo** structure with a type **NID\_id\_smime\_ct\_authEnvelopedData**. **cipher** is the symmetric AEAD cipher to use. Currently only AES variants with GCM mode are supported. The library context *libctx* and the property query *propq* are used when retrieving algorithms from providers.

The algorithm passed in the *cipher* parameter must support ASN1 encoding of its parameters.

The recipients can be added later using [**CMS\_add1\_recipient\_cert**(3)](/man/os/openssl-4.0/CMS_add1_recipient_cert.3) or [**CMS\_add0\_recipient\_key**(3)](/man/os/openssl-4.0/CMS_add0_recipient_key.3).

The **CMS\_ContentInfo** structure needs to be finalized using [**CMS\_final**(3)](/man/os/openssl-4.0/CMS_final.3) and then freed using [**CMS\_ContentInfo\_free**(3)](/man/os/openssl-4.0/CMS_ContentInfo_free.3).

**CMS\_EnvelopedData\_create()** and **CMS\_AuthEnvelopedData\_create()** are similar to **CMS\_EnvelopedData\_create\_ex()** and **CMS\_AuthEnvelopedData\_create\_ex()** but use default values of NULL for the library context *libctx* and the property query *propq*.

# [NOTES](#NOTES)

Although **CMS\_EnvelopedData\_create\_ex()**, and **CMS\_EnvelopedData\_create()**, **CMS\_AuthEnvelopedData\_create\_ex()**, and **CMS\_AuthEnvelopedData\_create()** allocate a new **CMS\_ContentInfo** structure, they are not usually used in applications. The wrappers [**CMS\_encrypt**(3)](/man/os/openssl-4.0/CMS_encrypt.3) and [**CMS\_decrypt**(3)](/man/os/openssl-4.0/CMS_decrypt.3) are often used instead.

# [RETURN VALUES](#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()** return NULL and set an error code that can be obtained by [**ERR\_get\_error**(3)](/man/os/openssl-4.0/ERR_get_error.3). Otherwise, they return a pointer to the newly allocated structure.

# [SEE ALSO](#SEE_ALSO)

[**ERR\_get\_error**(3)](/man/os/openssl-4.0/ERR_get_error.3), [**CMS\_encrypt**(3)](/man/os/openssl-4.0/CMS_encrypt.3), [**CMS\_decrypt**(3)](/man/os/openssl-4.0/CMS_decrypt.3), [**CMS\_final**(3)](/man/os/openssl-4.0/CMS_final.3), [**CMS\_sign\_ex**(3)](/man/os/openssl-4.0/CMS_sign_ex.3), [**CMS\_encrypt\_ex**(3)](/man/os/openssl-4.0/CMS_encrypt_ex.3)

# [HISTORY](#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.

# [COPYRIGHT](#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 &lt;https://www.openssl.org/source/license.html&gt;.

2026-09-29 4.0.3

---

Document: CMS_EnvelopedData_create(3ossl) from openssl-4.0 4.0.3-r2 (Chainguard OS)
