---
name: "libressl-CMS_signed_add1_attr"
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_signed_add1_attr"
---

# libressl-CMS\_signed\_add1\_attr(3)

change signed and unsigned attributes of a CMS SignerInfo object

## NAME

**CMS\_signed\_add1\_attr**, **CMS\_signed\_add1\_attr\_by\_NID**, **CMS\_signed\_add1\_attr\_by\_OBJ**, **CMS\_signed\_add1\_attr\_by\_txt**, **CMS\_signed\_delete\_attr**, **CMS\_signed\_get0\_data\_by\_OBJ**, **CMS\_signed\_get\_attr**, **CMS\_signed\_get\_attr\_by\_NID**, **CMS\_signed\_get\_attr\_by\_OBJ**, **CMS\_signed\_get\_attr\_count**, **CMS\_unsigned\_add1\_attr**, **CMS\_unsigned\_add1\_attr\_by\_NID**, **CMS\_unsigned\_add1\_attr\_by\_OBJ**, **CMS\_unsigned\_add1\_attr\_by\_txt**, **CMS\_unsigned\_delete\_attr**, **CMS\_unsigned\_get0\_data\_by\_OBJ**, **CMS\_unsigned\_get\_attr**, **CMS\_unsigned\_get\_attr\_by\_NID**, **CMS\_unsigned\_get\_attr\_by\_OBJ**, **CMS\_unsigned\_get\_attr\_count** – change signed and unsigned attributes of a CMS SignerInfo object

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*int*\

**CMS\_signed\_add1\_attr**(*CMS\_SignerInfo \*si*, *X509\_ATTRIBUTE \*attr*);

*int*\

**CMS\_signed\_add1\_attr\_by\_NID**(*CMS\_SignerInfo \*si*, *int nid*, *int type*, *const void \*bytes*, *int len*);

*int*\

**CMS\_signed\_add1\_attr\_by\_OBJ**(*CMS\_SignerInfo \*si*, *const ASN1\_OBJECT \*obj*, *int type*, *const void \*bytes*, *int len*);

*int*\

**CMS\_signed\_add1\_attr\_by\_txt**(*CMS\_SignerInfo \*si*, *const char \*attrname*, *int type*, *const void \*bytes*, *int len*);

*X509\_ATTRIBUTE* *\**\

**CMS\_signed\_delete\_attr**(*CMS\_SignerInfo \*si*, *int loc*);

*void* *\**\

**CMS\_signed\_get0\_data\_by\_OBJ**(*CMS\_SignerInfo \*si*, *const ASN1\_OBJECT \*oid*, *int start\_after*, *int type*);

*X509\_ATTRIBUTE* *\**\

**CMS\_signed\_get\_attr**(*const CMS\_SignerInfo \*si*, *int loc*);

*int*\

**CMS\_signed\_get\_attr\_by\_NID**(*const CMS\_SignerInfo \*si*, *int nid*, *int start\_after*);

*int*\

**CMS\_signed\_get\_attr\_by\_OBJ**(*const CMS\_SignerInfo \*si*, *const ASN1\_OBJECT \*obj*, *int start\_after*);

*int*\

**CMS\_signed\_get\_attr\_count**(*const CMS\_SignerInfo \*si*);

*int*\

**CMS\_unsigned\_add1\_attr**(*CMS\_SignerInfo \*si*, *X509\_ATTRIBUTE \*attr*);

*int*\

**CMS\_unsigned\_add1\_attr\_by\_NID**(*CMS\_SignerInfo \*si*, *int nid*, *int type*, *const void \*bytes*, *int len*);

*int*\

**CMS\_unsigned\_add1\_attr\_by\_OBJ**(*CMS\_SignerInfo \*si*, *const ASN1\_OBJECT \*obj*, *int type*, *const void \*bytes*, *int len*);

*int*\

**CMS\_unsigned\_add1\_attr\_by\_txt**(*CMS\_SignerInfo \*si*, *const char \*attrname*, *int type*, *const void \*bytes*, *int len*);

*X509\_ATTRIBUTE* *\**\

**CMS\_unsigned\_delete\_attr**(*CMS\_SignerInfo \*si*, *int loc*);

*void* *\**\

**CMS\_unsigned\_get0\_data\_by\_OBJ**(*CMS\_SignerInfo \*si*, *ASN1\_OBJECT \*oid*, *int start\_after*, *int type*);

*X509\_ATTRIBUTE* *\**\

**CMS\_unsigned\_get\_attr**(*const CMS\_SignerInfo \*si*, *int loc*);

*int*\

**CMS\_unsigned\_get\_attr\_by\_NID**(*const CMS\_SignerInfo \*si*, *int nid*, *int start\_after*);

*int*\

**CMS\_unsigned\_get\_attr\_by\_OBJ**(*const CMS\_SignerInfo \*si*, *const ASN1\_OBJECT \*obj*, *int start\_after*);

*int*\

**CMS\_unsigned\_get\_attr\_count**(*const CMS\_SignerInfo \*si*);

## DESCRIPTION

A *CMS\_SignerInfo* object has two optional sets of X.501 attributes: a set of signed attributes in the *signedAttrs* array and a set of unsigned attributes in the *unsignedAttrs* array. The **CMS\_signed\_\***() and **CMS\_unsigned\_\***() functions are similar, except **CMS\_signed\_\***() modifies the *CMS\_SignerInfo* object's set of signed attributes and **CMS\_unsigned\_\***() modifies the *CMS\_SignerInfo* object's set of unsigned attributes. For brevity only the **CMS\_signed\_\***() functions are described below.

**CMS\_signed\_add1\_attr**() appends a deep copy of *attr* to the *signedAttrs* array of *si*, allocating a new array if necessary.

**CMS\_signed\_add1\_attr\_by\_NID**(), **CMS\_signed\_add1\_attr\_by\_OBJ**(), and **CMS\_signed\_add1\_attr\_by\_txt**() create a new X.501 Attribute object using X509\_ATTRIBUTE\_create\_by\_NID(3), X509\_ATTRIBUTE\_create\_by\_OBJ(3), or X509\_ATTRIBUTE\_create\_by\_txt(3), respectively, and append it to the *signedAttrs* array of *si*.

**CMS\_signed\_delete\_attr**() deletes the element with the zero-based *loc* in *signedAttrs* of *si*.

**CMS\_signed\_get0\_data\_by\_OBJ**(), **CMS\_signed\_get\_attr\_by\_NID**(), and **CMS\_signed\_get\_attr\_by\_OBJ**() search the array starting after the index *start\_after*. They fail if no matching object is found. **CMS\_signed\_get0\_data\_by\_OBJ**() also fails if the data is not of the requested *type*.

Additionally, the *start\_after* argument of **CMS\_signed\_get0\_data\_by\_OBJ**() is interpreted in a special way. If *start\_after* is -2 or smaller, the function also fails if the *signedAttrs* array of *si*, contains more than one matching object. If *start\_after* is -3 or smaller, it also fails unless the matching object contains exactly one value.

**CMS\_signed\_get\_attr**() returns the array element at the zero-based *loc*. It fails if the *loc* argument is negative or greater than or equal to the number of objects in the array.

**CMS\_signed\_get\_attr\_count**() returns the number of objects currently stored in the *signedAttrs* array of *si*.

## RETURN VALUES

**CMS\_signed\_add1\_attr**(), **CMS\_signed\_add1\_attr\_by\_NID**(), **CMS\_signed\_add1\_attr\_by\_OBJ**(), **CMS\_signed\_add1\_attr\_by\_txt**(), **CMS\_unsigned\_add1\_attr**(), **CMS\_unsigned\_add1\_attr\_by\_NID**(), **CMS\_unsigned\_add1\_attr\_by\_OBJ**(), and **CMS\_unsigned\_add1\_attr\_by\_txt**() return 1 for success or 0 if an error occurs.

**CMS\_signed\_delete\_attr**() returns the deleted element or NULL if the *signedAttrs* array is NULL, or if the requested *loc* argument is negative, or greater than or equal to the number of objects in it.

**CMS\_unsigned\_delete\_attr**() returns the deleted element or NULL if the *unsignedAttrs* array is NULL, or if the requested *loc* argument is negative, or greater than or equal to the number of objects in it.

**CMS\_signed\_get0\_data\_by\_OBJ**() and **CMS\_unsigned\_get0\_data\_by\_OBJ**() return an internal pointer to the data contained in the value of the first object that has an index greater than *start\_after* and a type matching *type*, or NULL on failure.

**CMS\_signed\_get\_attr**() and **CMS\_unsigned\_get\_attr**() return an internal pointer or NULL on failure.

**CMS\_signed\_get\_attr\_by\_NID**(), **CMS\_signed\_get\_attr\_by\_OBJ**(), **CMS\_unsigned\_get\_attr\_by\_NID**(), and **CMS\_unsigned\_get\_attr\_by\_OBJ**() return the index of the first object in the array that has an index greater than *start\_after* and a type matching *nid* or *oid*, respectively, or -1 on failure. In addition, **CMS\_signed\_get\_attr\_by\_OBJ**() and **CMS\_unsigned\_get\_attr\_by\_OBJ**() return -2 if OBJ\_nid2obj(3) fails on the requested *nid*.

**CMS\_signed\_get\_attr\_count**() and **CMS\_unsigned\_get\_attr\_count**() return the number of array elements or -1 on failure.

## SEE ALSO

CMS\_add1\_signer(3), CMS\_ContentInfo\_new(3), CMS\_get0\_SignerInfos(3), OBJ\_nid2obj(3), X509\_ATTRIBUTE\_create\_by\_OBJ(3), X509\_ATTRIBUTE\_new(3)

## STANDARDS

RFC 5652: Cryptographic Message Syntax (CMS)

- section 5.3: SignerInfo Type

- section 11: Useful Attributes

## HISTORY

These functions first appeared in OpenSSL 0.9.9 and have been available since OpenBSD 6.6.
