---
name: "libressl-CMS_get0_type"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-CMS_get0_type"
---

# libressl-CMS\_get0\_type(3)

get and set CMS content types and content

## NAME

**CMS\_get0\_type**, **CMS\_get\_version**, **CMS\_set1\_eContentType**, **CMS\_get0\_eContentType**, **CMS\_get0\_content** – get and set CMS content types and content

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/cms.h\>**

*const* *ASN1\_OBJECT* *\**\

**CMS\_get0\_type**(*const CMS\_ContentInfo \*cms*);

*int*\

**CMS\_get\_version**(*const CMS\_ContentInfo \*cms*, *long \*version*);

*int*\

**CMS\_set1\_eContentType**(*CMS\_ContentInfo \*cms*, *const ASN1\_OBJECT \*oid*);

*const* *ASN1\_OBJECT* *\**\

**CMS\_get0\_eContentType**(*CMS\_ContentInfo \*cms*);

*ASN1\_OCTET\_STRING* *\*\**\

**CMS\_get0\_content**(*CMS\_ContentInfo \*cms*);

## DESCRIPTION

**CMS\_get0\_type**() returns the content type of the *ContentInfo* structure *cms*. The *ASN1\_OBJECT* value returned can be converted to an integer NID value using OBJ\_obj2nid(3). The following content types are identified by the following NIDs:

| | |
| --- | --- |
| *SignedData* | NID\_pkcs7\_signed |
| *EnvelopedData* | NID\_pkcs7\_enveloped |
| *DigestedData* | NID\_pkcs7\_digest |
| *EncryptedData* | NID\_pkcs7\_encrypted |
| *AuthenticatedData* | NID\_id\_smime\_ct\_authData |
| *CompressedData* | NID\_id\_smime\_ct\_compressedData |
| arbitrary data | NID\_pkcs7\_data |

The *SignedData*, *DigestedData*, *AuthenticatedData*, and *CompressedData* types contain a field *encapContentInfo* to allow embedding content, and *EnvelopedData* and *EncryptedData* contain a field *encryptedContentInfo* for that purpose. The type of the embedded content to be stored in that field can be set with the function **CMS\_set1\_eContentType**(), to be called on *cms* structures returned from functions such as CMS\_sign(3) or CMS\_encrypt(3) with the CMS\_PARTIAL flag set and *before* the structure is finalised; otherwise the results are undefined. **CMS\_set1\_eContentType**() copies the supplied *oid*, so it should be freed up after use.

**CMS\_get\_version**() sets \**version* to the syntax version number of the *ContentInfo* structure *cms*. The version is a number between 0 and 5 and is defined for all the above content types except for arbitrary data. For arbitrary data and unsupported content types **CMS\_get\_version**() fails and the content of \**version* is unspecified.

**CMS\_get0\_eContentType**() returns the type of the embedded content.

**CMS\_get0\_content**() returns a pointer to the storage location where the pointer to the embedded content is stored. That means that for example after

```
ASN1_OCTET_STRING **pconf = CMS_get0_content(cms);
```

\**pconf* could be NULL if there is no embedded content. Applications can access, modify or create the embedded content in a *CMS\_ContentInfo* structure using this function. Applications usually will not need to modify the embedded content as it is normally set by higher level functions.

## RETURN VALUES

**CMS\_get0\_type**() and **CMS\_get0\_eContentType**() return internal pointers to *OBJECT* *IDENTIFIER* structures.

**CMS\_get\_version**() returns 1 on success and 0 on failure.

**CMS\_get0\_content**() returns an internal pointer to the storage location where the pointer to the embedded content is stored.

**CMS\_set1\_eContentType**() returns 1 for success or 0 if an error occurred. The error can be obtained from ERR\_get\_error(3).

## SEE ALSO

CMS\_ContentInfo\_new(3), d2i\_CMS\_ContentInfo(3), SMIME\_read\_CMS(3)

## STANDARDS

RFC 5652: Cryptographic Message Syntax

RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)

## HISTORY

These functions first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 6.7.

**CMS\_get\_version**() first appeared in OpenBSD 7.4.
