CMS_SIGNED_GET_ATTR(3SSL)
π CMS_SIGNED_GET_ATTR β the OpenSSL 3SSL page, but make it cute β¨
okay so bestie. listen. you're reading CMS_SIGNED_GET_ATTR(3SSL) and honestly? it's giving "the attribute manager for CMS SignerInfos." no cap. π
πΈ NAME πΈ
CMS_signed_get_attr_count, CMS_signed_get_attr_by_NID, CMS_signed_get_attr_by_OBJ, CMS_signed_get_attr, CMS_signed_delete_attr, CMS_signed_add1_attr, CMS_signed_add1_attr_by_OBJ, CMS_signed_add1_attr_by_NID, CMS_signed_add1_attr_by_txt, CMS_signed_get0_data_by_OBJ, CMS_unsigned_get_attr_count, CMS_unsigned_get_attr_by_NID, CMS_unsigned_get_attr_by_OBJ, CMS_unsigned_get_attr, CMS_unsigned_delete_attr, CMS_unsigned_add1_attr, CMS_unsigned_add1_attr_by_OBJ, CMS_unsigned_add1_attr_by_NID, CMS_unsigned_add1_attr_by_txt, CMS_unsigned_get0_data_by_OBJ β aka the CMS signed and unsigned attribute functions π
β¨ SYNOPSIS β¨
like, here's the whole vibe, verbatim, don't touch it:
#include <openssl/cms.h>
int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
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);
X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
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_NID(CMS_SignerInfo *si,
int nid, 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);
void *CMS_signed_get0_data_by_OBJ(const CMS_SignerInfo *si,
const ASN1_OBJECT *oid,
int lastpos, int type);
int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
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);
X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
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_NID(CMS_SignerInfo *si,
int nid, 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);
void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
int lastpos, int type);
π¦ DESCRIPTION π¦
so. CMS_signerInfo (bestie, write it how the page writes it, iykyk) keeps separate attribute lists for signed and unsigned attributes. every CMS_signed_XXX() function is for the signed side, and every CMS_unsigned_XXX() function is for the unsigned side. and here's the slay part: because the CMS_unsigned_XXX() functions literally work the same way as their CMS_signed_XXX() equivalents, only the CMS_signed_XXX() ones get described below. equality. π
Let's go one by one, bestie:
CMS_signed_get_attr_by_OBJ()β finds the location of the first matching object obj in the SignerInfo'ssisigned attribute list. the search starts at the position afterlastpos. if the returned value is positive, then guess what β you can use it on the next call toCMS_signed_get_attr_by_OBJ()as the value oflastposto iterate through the remaining attributes. and on the very first call? setlastposto any negative value and it starts searching from the start of the signed attribute list. iconic iterator behaviour, no notes. π₯CMS_signed_get_attr_by_NID()β same energy asCMS_signed_get_attr_by_OBJ()except it passes the numerical identifier (NID) nid associated with the object. see<openssl/obj_mac.h>for a list ofNID_*. β¨CMS_signed_get_attr()β returns theX509_ATTRIBUTEobject at indexlocin thesisigned attribute list.locshould be in the range from0toCMS_signed_get_attr_count() - 1. πCMS_signed_delete_attr()β removes theX509_ATTRIBUTEobject at indexlocin thesisigned attribute list. an error occurs if thesiattribute list isNULL. πCMS_signed_add1_attr()β pushes a copy of the passed inX509_ATTRIBUTEobject to thesisigned attribute list. a new signed attribute list is created if required. an error occurs ifattrisNULL.CMS_signed_add1_attr_by_OBJ()β creates a new signedX509_ATTRIBUTEusingX509_ATTRIBUTE_set1_object()andX509_ATTRIBUTE_set1_data()to assign a new obj with type type and data bytes of length len, and then pushes it to the key object's attribute list. whole assembly line moment. π§CMS_signed_add1_attr_by_NID()β same asCMS_signed_add1_attr_by_OBJ()except it passes the numerical identifier (NID) nid associated with the object. see<openssl/obj_mac.h>for a list ofNID_*.CMS_signed_add1_attr_by_txt()β same asCMS_signed_add1_attr_by_OBJ()except it passes a name attrname associated with the object. see<openssl/obj_mac.h>for a list ofSN_*names.CMS_signed_get0_data_by_OBJ()β finds the first attribute in asisigned attributes list that matches obj, starting at indexlastpos, and returns the data retrieved from the found attribute's firstASN1_TYPEobject. an error will occur if:- the attribute type type does not match the type of the
ASN1_TYPEobject, OR - type is either
V_ASN1_BOOLEANorV_ASN1_NULL, OR - the attribute is not found.
- the attribute type type does not match the type of the
and bestie, more conditions: if lastpos is less than -1 then an error will occur if there are multiple objects in the signed attribute list that match obj. and if lastpos is less than -2 then an error will occur if there is more than one ASN1_TYPE object in the found signed attribute. read those twice, fr fr. π
refer to X509_ATTRIBUTE(3) for information related to attributes. π«Ά
π RETURN VALUES π
- the
CMS_unsigned_XXX()functions return values are similar to those of the equivalentCMS_signed_XXX()functions. twin behaviour. π CMS_signed_get_attr_count()β returns the number of signed attributes in the SignerInfosi, or-1if the signed attribute list isNULL.CMS_signed_get_attr_by_OBJ()β returns-1if either the signed attribute list ofsiis empty OR if obj is not found; otherwise it returns the location of the obj in the SignerInfo'ssisigned attribute list.CMS_signed_get_attr_by_NID()β similar toCMS_signed_get_attr_by_OBJ()except that it returns-2if the nid is not known by OpenSSL.CMS_signed_get_attr()β returns either a signedX509_ATTRIBUTEorNULLon error.CMS_signed_delete_attr()β returns either the removed signedX509_ATTRIBUTEorNULLif there is a error.CMS_signed_add1_attr(),CMS_signed_add1_attr_by_OBJ(),CMS_signed_add1_attr_by_NID(),CMS_signed_add1_attr_by_txt()β return1on success or0on error. yes queen, binary.CMS_signed_get0_data_by_OBJ()β returns the data retrieved from the found signed attribute's firstASN1_TYPEobject, orNULLif an error occurs.
π NOTES π
some attributes are added automatically during the signing process. like, you didn't even ask. π
- calling
CMS_SignerInfo_sign()adds theNID_pkcs9_signingTimesigned attribute. - calling
CMS_final(),CMS_final_digest()orCMS_dataFinal()adds theNID_pkcs9_messageDigestsigned attribute. - the
NID_pkcs9_contentTypesigned attribute is always added if theNID_pkcs9_signingTimeattribute is added. package deal, periodt. - calling
CMS_sign_ex(),CMS_sign_receipt()orCMS_add1_signer()may add attributes depending on the flags parameter. seeCMS_add1_signer(3)for more information.
OpenSSL applies special rules for the following attribute NIDs, bestie, pay attention π¨:
CMS Signed Attributes
NID_pkcs9_contentType NID_pkcs9_messageDigest NID_pkcs9_signingTime
ESS Signed Attributes
NID_id_smime_aa_signingCertificate NID_id_smime_aa_signingCertificateV2 NID_id_smime_aa_receiptRequest
CMS Unsigned Attributes
NID_pkcs9_countersignature
and now the important bit, so don't scroll past it: CMS_signed_add1_attr(), CMS_signed_add1_attr_by_OBJ(), CMS_signed_add1_attr_by_NID(), CMS_signed_add1_attr_by_txt() and the equivalent CMS_unsigned_add1_attrXXX() functions allow duplicate attributes to be added. the attribute rules are not checked during these function calls β they're deferred until the sign or verify process. i.e. during calls to any of:
CMS_sign_ex(), CMS_sign(), CMS_sign_receipt(), CMS_add1_signer(), CMS_Final(), CMS_dataFinal(), CMS_final_digest(), CMS_verify(), CMS_verify_receipt() or CMS_SignedData_verify().
for CMS attribute rules see RFC 5652 Section 11. for ESS attribute rules see RFC 2634 Section 1.3.4 and RFC 5035 Section 5.4. π
π SEE ALSO π
π COPYRIGHT π
Copyright 2023-2024 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>.
okay that's the whole thing bestie, you ate that π version 4.0.3, dated 2026-09-29, and yeah the page is literally called CMS_SIGNED_GET_ATTR(3SSL) β go forth and manage your attributes, main character energy only, mwah π
β¨π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms