Debian Codegraph @

upstream/debian-unstable/man3/CMS_signed_get_attr.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "CMS_SIGNED_GET_ATTR 3SSL"
58 .TH CMS_SIGNED_GET_ATTR 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 CMS_signed_get_attr_count,
65 CMS_signed_get_attr_by_NID, CMS_signed_get_attr_by_OBJ, CMS_signed_get_attr,
66 CMS_signed_delete_attr,
67 CMS_signed_add1_attr, CMS_signed_add1_attr_by_OBJ,
68 CMS_signed_add1_attr_by_NID, CMS_signed_add1_attr_by_txt,
69 CMS_signed_get0_data_by_OBJ,
70 CMS_unsigned_get_attr_count,
71 CMS_unsigned_get_attr_by_NID, CMS_unsigned_get_attr_by_OBJ,
72 CMS_unsigned_get_attr, CMS_unsigned_delete_attr,
73 CMS_unsigned_add1_attr, CMS_unsigned_add1_attr_by_OBJ,
74 CMS_unsigned_add1_attr_by_NID, CMS_unsigned_add1_attr_by_txt,
75 CMS_unsigned_get0_data_by_OBJ
76 \&\- CMS signed and unsigned attribute functions
77 .SH SYNOPSIS
78 .IX Header "SYNOPSIS"
79 .Vb 1
80 \& #include <openssl/cms.h>
81 \&
82 \& int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
83 \& int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
84 \& int lastpos);
85 \& int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
86 \& int lastpos);
87 \& X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
88 \& X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
89 \& int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
90 \& int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
91 \& const ASN1_OBJECT *obj, int type,
92 \& const void *bytes, int len);
93 \& int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
94 \& int nid, int type,
95 \& const void *bytes, int len);
96 \& int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
97 \& const char *attrname, int type,
98 \& const void *bytes, int len);
99 \& void *CMS_signed_get0_data_by_OBJ(const CMS_SignerInfo *si,
100 \& const ASN1_OBJECT *oid,
101 \& int lastpos, int type);
102 \&
103 \& int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
104 \& int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
105 \& int lastpos);
106 \& int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
107 \& const ASN1_OBJECT *obj, int lastpos);
108 \& X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
109 \& X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
110 \& int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
111 \& int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
112 \& const ASN1_OBJECT *obj, int type,
113 \& const void *bytes, int len);
114 \& int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
115 \& int nid, int type,
116 \& const void *bytes, int len);
117 \& int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
118 \& const char *attrname, int type,
119 \& const void *bytes, int len);
120 \& void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
121 \& int lastpos, int type);
122 .Ve
123 .SH DESCRIPTION
124 .IX Header "DESCRIPTION"
125 CMS_signerInfo contains separate attribute lists for signed and unsigned
126 attributes. Each \fBCMS_signed_XXX()\fR function is used for signed attributes, and
127 each \fBCMS_unsigned_XXX()\fR function is used for unsigned attributes.
128 Since the \fBCMS_unsigned_XXX()\fR functions work in the same way as the
129 \&\fBCMS_signed_XXX()\fR equivalents, only the \fBCMS_signed_XXX()\fR functions are
130 described below.
131 .PP
132 \&\fBCMS_signed_get_attr_by_OBJ()\fR finds the location of the first matching object
133 \&\fIobj\fR in the SignerInfo's \fIsi\fR signed attribute list. The search starts at the
134 position after \fIlastpos\fR. If the returned value is positive then it can be used
135 on the next call to \fBCMS_signed_get_attr_by_OBJ()\fR as the value of \fIlastpos\fR in
136 order to iterate through the remaining attributes. \fIlastpos\fR can be set to any
137 negative value on the first call, in order to start searching from the start of
138 the signed attribute list.
139 .PP
140 \&\fBCMS_signed_get_attr_by_NID()\fR is similar to \fBCMS_signed_get_attr_by_OBJ()\fR except
141 that it passes the numerical identifier (NID) \fInid\fR associated with the object.
142 See <openssl/obj_mac.h> for a list of NID_*.
143 .PP
144 \&\fBCMS_signed_get_attr()\fR returns the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in the
145 \&\fIsi\fR signed attribute list. \fIloc\fR should be in the range from 0 to
146 \&\fBCMS_signed_get_attr_count()\fR \- 1.
147 .PP
148 \&\fBCMS_signed_delete_attr()\fR removes the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in
149 the \fIsi\fR signed attribute list. An error occurs if the \fIsi\fR attribute list
150 is NULL.
151 .PP
152 \&\fBCMS_signed_add1_attr()\fR pushes a copy of the passed in \fBX509_ATTRIBUTE\fR object
153 to the \fIsi\fR signed attribute list. A new signed attribute list is created if
154 required. An error occurs if \fIattr\fR is NULL.
155 .PP
156 \&\fBCMS_signed_add1_attr_by_OBJ()\fR creates a new signed \fBX509_ATTRIBUTE\fR using
157 \&\fBX509_ATTRIBUTE_set1_object()\fR and \fBX509_ATTRIBUTE_set1_data()\fR to assign a new
158 \&\fIobj\fR with type \fItype\fR and data \fIbytes\fR of length \fIlen\fR and then pushes it
159 to the \fIkey\fR object's attribute list.
160 .PP
161 \&\fBCMS_signed_add1_attr_by_NID()\fR is similar to \fBCMS_signed_add1_attr_by_OBJ()\fR except
162 that it passes the numerical identifier (NID) \fInid\fR associated with the object.
163 See <openssl/obj_mac.h> for a list of NID_*.
164 .PP
165 \&\fBCMS_signed_add1_attr_by_txt()\fR is similar to \fBCMS_signed_add1_attr_by_OBJ()\fR
166 except that it passes a name \fIattrname\fR associated with the object.
167 See <openssl/obj_mac.h> for a list of SN_* names.
168 .PP
169 \&\fBCMS_signed_get0_data_by_OBJ()\fR finds the first attribute in a \fIsi\fR signed
170 attributes list that matches the \fIobj\fR starting at index \fIlastpos\fR
171 and returns the data retrieved from the found attributes first \fBASN1_TYPE\fR
172 object. An error will occur if the attribute type \fItype\fR does not match the
173 type of the \fBASN1_TYPE\fR object OR if \fItype\fR is either \fBV_ASN1_BOOLEAN\fR or
174 \&\fBV_ASN1_NULL\fR OR the attribute is not found.
175 If \fIlastpos\fR is less than \-1 then an error will occur if there are multiple
176 objects in the signed attribute list that match \fIobj\fR.
177 If \fIlastpos\fR is less than \-2 then an error will occur if there is more than
178 one \fBASN1_TYPE\fR object in the found signed attribute.
179 .PP
180 Refer to \fBX509_ATTRIBUTE\fR\|(3) for information related to attributes.
181 .SH "RETURN VALUES"
182 .IX Header "RETURN VALUES"
183 The \fBCMS_unsigned_XXX()\fR functions return values are similar to those of the
184 equivalent \fBCMS_signed_XXX()\fR functions.
185 .PP
186 \&\fBCMS_signed_get_attr_count()\fR returns the number of signed attributes in the
187 SignerInfo \fIsi\fR, or \-1 if the signed attribute list is NULL.
188 .PP
189 \&\fBCMS_signed_get_attr_by_OBJ()\fR returns \-1 if either the signed attribute list of
190 \&\fIsi\fR is empty OR if \fIobj\fR is not found, otherwise it returns the location of
191 the \fIobj\fR in the SignerInfo's \fIsi\fR signed attribute list.
192 .PP
193 \&\fBCMS_signed_get_attr_by_NID()\fR is similar to \fBCMS_signed_get_attr_by_OBJ()\fR except
194 that it returns \-2 if the \fInid\fR is not known by OpenSSL.
195 .PP
196 \&\fBCMS_signed_get_attr()\fR returns either a signed \fBX509_ATTRIBUTE\fR or NULL on error.
197 .PP
198 \&\fBCMS_signed_delete_attr()\fR returns either the removed signed \fBX509_ATTRIBUTE\fR or
199 NULL if there is a error.
200 .PP
201 \&\fBCMS_signed_add1_attr()\fR, \fBCMS_signed_add1_attr_by_OBJ()\fR,
202 \&\fBCMS_signed_add1_attr_by_NID()\fR, \fBCMS_signed_add1_attr_by_txt()\fR,
203 return 1 on success or 0 on error.
204 .PP
205 \&\fBCMS_signed_get0_data_by_OBJ()\fR returns the data retrieved from the found
206 signed attributes first \fBASN1_TYPE\fR object, or NULL if an error occurs.
207 .SH NOTES
208 .IX Header "NOTES"
209 Some attributes are added automatically during the signing process.
210 .PP
211 Calling \fBCMS_SignerInfo_sign()\fR adds the NID_pkcs9_signingTime signed
212 attribute.
213 .PP
214 Calling \fBCMS_final()\fR, \fBCMS_final_digest()\fR or \fBCMS_dataFinal()\fR adds the
215 NID_pkcs9_messageDigest signed attribute.
216 .PP
217 The NID_pkcs9_contentType signed attribute is always added if the
218 NID_pkcs9_signingTime attribute is added.
219 .PP
220 Calling \fBCMS_sign_ex()\fR, \fBCMS_sign_receipt()\fR or \fBCMS_add1_signer()\fR may add
221 attributes depending on the flags parameter. See \fBCMS_add1_signer\fR\|(3) for
222 more information.
223 .PP
224 OpenSSL applies special rules for the following attribute NIDs:
225 .IP "CMS Signed Attributes" 4
226 .IX Item "CMS Signed Attributes"
227 NID_pkcs9_contentType
228 NID_pkcs9_messageDigest
229 NID_pkcs9_signingTime
230 .IP "ESS Signed Attributes" 4
231 .IX Item "ESS Signed Attributes"
232 NID_id_smime_aa_signingCertificate
233 NID_id_smime_aa_signingCertificateV2
234 NID_id_smime_aa_receiptRequest
235 .IP "CMS Unsigned Attributes" 4
236 .IX Item "CMS Unsigned Attributes"
237 NID_pkcs9_countersignature
238 .PP
239 \&\fBCMS_signed_add1_attr()\fR, \fBCMS_signed_add1_attr_by_OBJ()\fR,
240 \&\fBCMS_signed_add1_attr_by_NID()\fR, \fBCMS_signed_add1_attr_by_txt()\fR
241 and the equivalent \fBCMS_unsigned_add1_attrXXX()\fR functions allow
242 duplicate attributes to be added. The attribute rules are not checked
243 during these function calls, and are deferred until the sign or verify process
244 (i.e. during calls to any of \fBCMS_sign_ex()\fR, \fBCMS_sign()\fR, \fBCMS_sign_receipt()\fR,
245 \&\fBCMS_add1_signer()\fR, \fBCMS_Final()\fR, \fBCMS_dataFinal()\fR, \fBCMS_final_digest()\fR,
246 \&\fBCMS_verify()\fR, \fBCMS_verify_receipt()\fR or \fBCMS_SignedData_verify()\fR).
247 .PP
248 For CMS attribute rules see RFC 5652 Section 11.
249 For ESS attribute rules see RFC 2634 Section 1.3.4 and RFC 5035 Section 5.4.
250 .SH "SEE ALSO"
251 .IX Header "SEE ALSO"
252 \&\fBX509_ATTRIBUTE\fR\|(3)
253 .SH COPYRIGHT
254 .IX Header "COPYRIGHT"
255 Copyright 2023\-2024 The OpenSSL Project Authors. All Rights Reserved.
256 .PP
257 Licensed under the Apache License 2.0 (the "License"). You may not use
258 this file except in compliance with the License. You can obtain a copy
259 in the file LICENSE in the source distribution or at
260 <https://www.openssl.org/source/license.html>.