---
name: "CMS_EnvelopedData_create"
section: "3ssl"
platform: "linux"
package: "openssl"
version: "3.6.5-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/CMS_EnvelopedData_create"
---

# CMS\_EnvelopedData\_create(3ssl)

Create CMS envelope

## NAME

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

## 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

**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) or **CMS\_add0\_recipient\_key**(3).

The **CMS\_ContentInfo** structure needs to be finalized using **CMS\_final**(3) and then freed using **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

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) and **CMS\_decrypt**(3) are often used instead.

## 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). Otherwise, they return a pointer to the newly allocated structure.

## SEE ALSO

**ERR\_get\_error**(3), **CMS\_encrypt**(3), **CMS\_decrypt**(3), **CMS\_final**(3), **CMS\_sign\_ex**(3), **CMS\_encrypt\_ex**(3)

## 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 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\>.
