OpenBSD manual page server

Manual Page Search Parameters

CMS_SIGNED_ADD1_ATTR(3) Library Functions Manual CMS_SIGNED_ADD1_ATTR(3)

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_countchange signed and unsigned attributes of a CMS SignerInfo object

#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 lastpos, 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 lastpos);

int
CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, int lastpos);

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 lastpos, 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 lastpos);

int
CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, int lastpos);

int
CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);

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 functions in this manual are wrappers of the () functions. All arguments except si are passed to X509at_*(). The () and () functions are similar, except CMS_signed_*() calls X509at_*() with the CMS_SignerInfo object's set of signed attributes and CMS_unsigned_*() calls X509at_*() with the CMS_SignerInfo object's set of unsigned attributes. For brevity only the CMS_signed_*() functions are described below.

() appends a deep copy of attr to the signedAttrs array of si, allocating a new array if necessary.

(), (), and () create a new X.501 Attribute object using X509at_add1_attr_by_NID(3), X509at_add1_attr_by_OBJ(3), and X509at_add1_attr_by_txt(3), and append it to the signedAttrs array of si.

() deletes the element with the zero-based loc in signedAttrs of si.

(), (), and () search the array starting after the index lastpos. 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 lastpos argument of () is interpreted in a special way. If lastpos is -2 or smaller, the function also fails if the signedAttrs array of si, contains more than one matching object. If lastpos is -3 or smaller, it also fails unless the matching object contains exactly one value.

() 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.

() returns the number of objects currently stored in the signedAttrs array of si.

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 lastpos 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 lastpos 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.

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), X509at_add1_attr(3)

RFC 5652: Cryptographic Message Syntax (CMS)

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

January 22, 2024 OpenBSD-7.5