summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/man/PKCS7_add_attribute.3222
1 files changed, 208 insertions, 14 deletions
diff --git a/src/lib/libcrypto/man/PKCS7_add_attribute.3 b/src/lib/libcrypto/man/PKCS7_add_attribute.3
index 081703f0f3..4a1c350f98 100644
--- a/src/lib/libcrypto/man/PKCS7_add_attribute.3
+++ b/src/lib/libcrypto/man/PKCS7_add_attribute.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.2 2020/06/04 21:21:03 schwarze Exp $ 1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.3 2020/06/10 11:39:12 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,14 +14,20 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: June 4 2020 $ 17.Dd $Mdocdate: June 10 2020 $
18.Dt PKCS7_ADD_ATTRIBUTE 3 18.Dt PKCS7_ADD_ATTRIBUTE 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm PKCS7_add_attribute , 21.Nm PKCS7_add_attribute ,
22.Nm PKCS7_set_attributes ,
22.Nm PKCS7_get_attribute , 23.Nm PKCS7_get_attribute ,
23.Nm PKCS7_add_signed_attribute , 24.Nm PKCS7_add_signed_attribute ,
24.Nm PKCS7_get_signed_attribute 25.Nm PKCS7_set_signed_attributes ,
26.Nm PKCS7_get_signed_attribute ,
27.Nm PKCS7_add_attrib_content_type ,
28.Nm PKCS7_add1_attrib_digest ,
29.Nm PKCS7_add0_attrib_signing_time ,
30.Nm PKCS7_add_attrib_smimecap
25.Nd attributes of SignerInfo objects 31.Nd attributes of SignerInfo objects
26.Sh SYNOPSIS 32.Sh SYNOPSIS
27.In openssl/pkcs7.h 33.In openssl/pkcs7.h
@@ -32,6 +38,11 @@
32.Fa "int attrtype" 38.Fa "int attrtype"
33.Fa "void *value" 39.Fa "void *value"
34.Fc 40.Fc
41.Ft int
42.Fo PKCS7_set_attributes
43.Fa "PKCS7_SIGNER_INFO *si"
44.Fa "STACK_OF(X509_ATTRIBUTE) *sk"
45.Fc
35.Ft ASN1_TYPE * 46.Ft ASN1_TYPE *
36.Fo PKCS7_get_attribute 47.Fo PKCS7_get_attribute
37.Fa "PKCS7_SIGNER_INFO *si" 48.Fa "PKCS7_SIGNER_INFO *si"
@@ -44,11 +55,37 @@
44.Fa "int attrtype" 55.Fa "int attrtype"
45.Fa "void *value" 56.Fa "void *value"
46.Fc 57.Fc
58.Ft int
59.Fo PKCS7_set_signed_attributes
60.Fa "PKCS7_SIGNER_INFO *si"
61.Fa "STACK_OF(X509_ATTRIBUTE) *sk"
62.Fc
47.Ft ASN1_TYPE * 63.Ft ASN1_TYPE *
48.Fo PKCS7_get_signed_attribute 64.Fo PKCS7_get_signed_attribute
49.Fa "PKCS7_SIGNER_INFO *si" 65.Fa "PKCS7_SIGNER_INFO *si"
50.Fa "int nid" 66.Fa "int nid"
51.Fc 67.Fc
68.Ft int
69.Fo PKCS7_add_attrib_content_type
70.Fa "PKCS7_SIGNER_INFO *si"
71.Fa "ASN1_OBJECT *coid"
72.Fc
73.Ft int
74.Fo PKCS7_add1_attrib_digest
75.Fa "PKCS7_SIGNER_INFO *si"
76.Fa "const unsigned char *md"
77.Fa "int mdlen"
78.Fc
79.Ft int
80.Fo PKCS7_add0_attrib_signing_time
81.Fa "PKCS7_SIGNER_INFO *si"
82.Fa "ASN1_TIME *t"
83.Fc
84.Ft int
85.Fo PKCS7_add_attrib_smimecap
86.Fa "PKCS7_SIGNER_INFO *si"
87.Fa "STACK_OF(X509_ALGOR) *cap"
88.Fc
52.Sh DESCRIPTION 89.Sh DESCRIPTION
53.Fn PKCS7_add_attribute 90.Fn PKCS7_add_attribute
54appends a new attribute of type 91appends a new attribute of type
@@ -74,6 +111,14 @@ If the list already contains an unauthenticated attribute of type
74before the call, the new attribute replaces the old one 111before the call, the new attribute replaces the old one
75instead of being appended to the end of the list. 112instead of being appended to the end of the list.
76.Pp 113.Pp
114.Fn PKCS7_set_attributes
115frees the
116.Fa unauthenticatedAttributes
117list of
118.Fa si
119and all the attributes contained in it and replaces it with a deep copy of
120.Fa sk .
121.Pp
77.Fn PKCS7_get_attribute 122.Fn PKCS7_get_attribute
78retrieves the first ASN.1 ANY member of the attribute of type 123retrieves the first ASN.1 ANY member of the attribute of type
79.Fa nid 124.Fa nid
@@ -83,7 +128,8 @@ list of
83.Fa si . 128.Fa si .
84.Pp 129.Pp
85The behaviour of 130The behaviour of
86.Fn PKCS7_add_signed_attribute 131.Fn PKCS7_add_signed_attribute ,
132.Fn PKCS7_set_signed_attributes ,
87and 133and
88.Fn PKCS7_get_signed_attribute 134.Fn PKCS7_get_signed_attribute
89is identical except that they operate on the list of 135is identical except that they operate on the list of
@@ -101,8 +147,8 @@ or
101.Dv PKCS7_STREAM 147.Dv PKCS7_STREAM
102flag, retrieve the 148flag, retrieve the
103.Vt PKCS7_SIGNER_INFO 149.Vt PKCS7_SIGNER_INFO
104object with the undocumented function 150object with
105.Fn PKCS7_get_signer_info 151.Xr PKCS7_get_signer_info 3
106or add an additional one with 152or add an additional one with
107.Xr PKCS7_sign_add_signer 3 , 153.Xr PKCS7_sign_add_signer 3 ,
108call 154call
@@ -111,21 +157,122 @@ for each desired additional attribute, then do the signing with
111.Xr PKCS7_final 3 157.Xr PKCS7_final 3
112or with another finalizing function. 158or with another finalizing function.
113.Pp 159.Pp
114For particular types of attributes, undocumented wrapper functions 160The four remaining functions are wrappers around
161.Fn PKCS7_add_signed_attribute .
162.Pp
163.Fn PKCS7_add_attrib_content_type
164sets the
165.Dv NID_pkcs9_contentType
166attribute to
167.Fa coid ,
168which specifies the content type of the
169.Vt ContentInfo
170value to be signed.
171This attribute is mandatory and automatically added by
172.Xr PKCS7_sign 3
173and
174.Xr PKCS7_sign_add_signer 3
175unless the
176.Dv PKCS7_NOATTR
177flag is present.
178Objects suitable as
179.Fa coid
180arguments can for example be obtained with
181.Xr OBJ_nid2obj 3 .
182If
183.Fa coid
184is
185.Dv NULL ,
186the content type defaults to
187.Dv NID_pkcs7_data .
188.Pp
189.Fn PKCS7_add1_attrib_digest
190sets or replaces the
191.Dv NID_pkcs9_messageDigest
192attribute, which is the message digest of the contents octets
193of the DER-encoding of the content field of the
194.Vt ContentInfo
195value being signed, to a copy of
196.Fa md ,
197which is assumed to be
198.Fa mdlen
199bytes long.
200If
201.Fa mdlen
202is -1, then
203.Fn strlen md
204is used instead of
205.Fa mdlen .
206This attribute is mandatory and automatically added by
207.Xr PKCS7_dataFinal 3
208and
209.Xr PKCS7_final 3 .
210.Pp
211.Fn PKCS7_add0_attrib_signing_time
212sets or replaces the optional
213.Dv NID_pkcs9_signingTime
214attribute to
215.Fa t ,
216specifying the time at which the signer performed the signing process.
217Ownership of
218.Fa t
219is transferred into the new attribute object, so the calling code
220must not
221.Xr free 3
222.Fa t .
223If
224.Fa t
225is
226.Dv NULL ,
227a new
228.Vt ASN1_TIME
229structure is allocated.
230This attribute is automatically added by
231.Xr PKCS7_dataFinal 3
232and
233.Xr PKCS7_final 3 .
234.Pp
235.Fn PKCS7_add_attrib_smimecap
236sets or replaces the optional
237.Dv NID_SMIMECapabilities
238attribute, indicating algorithms the sender is prepared to handle.
239The
240.Fa cap
241pointer is not stored in the new attribute object and can be passed to
242.Fn sk_X509_ALGOR_pop_free
243after the call.
244This attribute is automatically added by
245.Xr PKCS7_sign 3
246and
247.Xr PKCS7_sign_add_signer 3
248unless the
249.Dv PKCS7_NOATTR
250or
251.Dv PKCS7_NOSMIMECAP
252flag is present.
253.Sh RETURN VALUES
254.Fn PKCS7_add_attribute ,
255.Fn PKCS7_set_attributes ,
256.Fn PKCS7_add_signed_attribute ,
257.Fn PKCS7_set_signed_attributes ,
115.Fn PKCS7_add_attrib_content_type , 258.Fn PKCS7_add_attrib_content_type ,
116.Fn PKCS7_add1_attrib_digest , 259.Fn PKCS7_add1_attrib_digest ,
117.Fn PKCS7_add0_attrib_signing_time , 260.Fn PKCS7_add0_attrib_signing_time ,
118and 261and
119.Fn PKCS7_add_attrib_smimecap 262.Fn PKCS7_add_attrib_smimecap
120exist. 263return 1 on success or 0 on failure.
121.Sh RETURN VALUES 264The most common reason for failure is lack of memory.
122.Fn PKCS7_add_attribute 265.Fn PKCS7_add_attribute
123and 266and
124.Fn PKCS7_add_signed_attribute 267.Fn PKCS7_add_signed_attribute
125return 1 on success or 0 on failure. 268also fail if
126The most common reasons for failure are an invalid
127.Fa nid 269.Fa nid
128argument or lack of memory. 270is invalid, and
271.Fn PKCS7_add_attrib_content_type
272if
273.Fa si
274already contains an authenticated attribute of type
275.Dv NID_pkcs9_contentType .
129.Pp 276.Pp
130.Fn PKCS7_get_attribute 277.Fn PKCS7_get_attribute
131and 278and
@@ -140,20 +287,67 @@ is invalid, if the respective list in
140contains no attribute of the requested type, or if an invalid element 287contains no attribute of the requested type, or if an invalid element
141is found in the list before finding the attribute of the requested type. 288is found in the list before finding the attribute of the requested type.
142.Sh SEE ALSO 289.Sh SEE ALSO
290.Xr ASN1_TIME_new 3 ,
143.Xr ASN1_TYPE_new 3 , 291.Xr ASN1_TYPE_new 3 ,
292.Xr OBJ_nid2obj 3 ,
144.Xr PKCS7_final 3 , 293.Xr PKCS7_final 3 ,
294.Xr PKCS7_get_signer_info 3 ,
145.Xr PKCS7_new 3 , 295.Xr PKCS7_new 3 ,
146.Xr PKCS7_sign 3 , 296.Xr PKCS7_sign 3 ,
147.Xr PKCS7_sign_add_signer 3 , 297.Xr PKCS7_sign_add_signer 3 ,
148.Xr STACK_OF 3 , 298.Xr STACK_OF 3 ,
299.Xr X509_ALGOR_new 3 ,
149.Xr X509_ATTRIBUTE_new 3 300.Xr X509_ATTRIBUTE_new 3
150.Sh STANDARDS 301.Sh STANDARDS
151RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5, 302RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5,
152section 9.2: SignerInfo type 303section 9.2: SignerInfo type
304.Pp
305RFC 2985: PKCS #9: Selected Object Classes and Attribute Types Version 2.0,
306section 5.3: Attribute types for use in PKCS #7 data
307and section 5.6: Attributes defined in S/MIME
308.Pp
309RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME)
310Version 4.0 Message Specification,
311section 2.5.2: SMIMECapabilities Attribute
153.Sh HISTORY 312.Sh HISTORY
154These functions first appeared in OpenSSL 0.9.1 313.Fn PKCS7_add_attribute ,
155and have been available since 314.Fn PKCS7_set_attributes ,
315.Fn PKCS7_get_attribute ,
316.Fn PKCS7_add_signed_attribute ,
317.Fn PKCS7_set_signed_attributes ,
318and
319.Fn PKCS7_get_signed_attribute
320first appeared in OpenSSL 0.9.1 and have been available since
156.Ox 2.6 . 321.Ox 2.6 .
322.Pp
323.Fn PKCS7_add_attrib_smimecap
324first appeared in OpenSSL 0.9.5 and has been available since
325.Ox 2.7 .
326.Pp
327.Fn PKCS7_add_attrib_content_type ,
328.Fn PKCS7_add1_attrib_digest ,
329and
330.Fn PKCS7_add0_attrib_signing_time
331first appeared in OpenSSL 1.0.0 and have been available since
332.Ox 4.9 .
333.Sh CAVEATS
334.Fn PKCS7_set_signed_attributes
335does not validate that
336.Fa sk
337contains the PKCS #9 content type and message digest attributes
338required by RFC 2315.
339It succeeds even when
340.Fa sk
341is empty, leaving
342.Fa si
343in a state that violates the standard.
344.Pp
345.Fn PKCS7_add0_attrib_signing_time
346does not validate
347.Fa t
348in any way.
349In particular, it may set the signing time to the future
350or to the remote past.
157.Sh BUGS 351.Sh BUGS
158A function to remove individual attributes from these lists 352A function to remove individual attributes from these lists
159does not appear to exist. 353does not appear to exist.