summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/PKCS7_add_attribute.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/PKCS7_add_attribute.3')
-rw-r--r--src/lib/libcrypto/man/PKCS7_add_attribute.3179
1 files changed, 179 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/PKCS7_add_attribute.3 b/src/lib/libcrypto/man/PKCS7_add_attribute.3
new file mode 100644
index 0000000000..09c36a4d5d
--- /dev/null
+++ b/src/lib/libcrypto/man/PKCS7_add_attribute.3
@@ -0,0 +1,179 @@
1.\" $OpenBSD: PKCS7_add_attribute.3,v 1.1 2020/06/04 10:24:27 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 4 2020 $
18.Dt PKCS7_ADD_ATTRIBUTE 3
19.Os
20.Sh NAME
21.Nm PKCS7_add_attribute ,
22.Nm PKCS7_get_attribute ,
23.Nm PKCS7_add_signed_attribute ,
24.Nm PKCS7_get_signed_attribute
25.Nd attributes of SignerInfo objects
26.Sh SYNOPSIS
27.In openssl/pkcs7.h
28.Ft int
29.Fo PKCS7_add_attribute
30.Fa "PKCS7_SIGNER_INFO *si"
31.Fa "int nid"
32.Fa "int attrtype"
33.Fa "void *value"
34.Fc
35.Ft ASN1_TYPE *
36.Fo PKCS7_get_attribute
37.Fa "PKCS7_SIGNER_INFO *si"
38.Fa "int nid"
39.Fc
40.Ft int
41.Fo PKCS7_add_signed_attribute
42.Fa "PKCS7_SIGNER_INFO *si"
43.Fa "int nid"
44.Fa "int attrtype"
45.Fa "void *value"
46.Fc
47.Ft ASN1_TYPE *
48.Fo PKCS7_get_signed_attribute
49.Fa "PKCS7_SIGNER_INFO *si"
50.Fa "int nid"
51.Fc
52.Sh DESCRIPTION
53.Fn PKCS7_add_attribute
54appends a new attribute of type
55.Fa nid
56to the
57.Fa unauthenticatedAttributes
58list of
59.Fa si ,
60and it adds a new ASN.1 ANY object of type
61.Fa attrtype
62with the given
63.Fa value
64to the new attribute.
65Ownership of the
66.Fa value
67is transferred into the new attribute object, so the calling code
68must not
69.Xr free 3
70the
71.Fa value .
72If the list already contains an unauthenticated attribute of type
73.Fa nid
74before the call, the new attribute replaces the old one
75instead of being appended to the end of the list.
76.Pp
77.Fn PKCS7_get_attribute
78retrieves the first ASN.1 ANY member of the attribute of type
79.Fa nid
80from the
81.Fa unauthenticatedAttributes
82list of
83.Fa si .
84.Pp
85The behaviour of
86.Fn PKCS7_add_signed_attribute
87and
88.Fn PKCS7_get_signed_attribute
89is identical except that they operate on the list of
90.Fa authenticatedAttributes .
91.Pp
92The normal way to use
93.Fn PKCS7_add_signed_attribute
94is to first create a
95.Vt SignedInfo
96object with
97.Xr PKCS7_sign 3
98using the
99.Dv PKCS7_PARTIAL
100or
101.Dv PKCS7_STREAM
102flag, retrieve the
103.Vt PKCS7_SIGNER_INFO
104object with the undocumented function
105.Fn PKCS7_get_signer_info
106or add an additional one with
107.Xr PKCS7_sign_add_signer 3 ,
108call
109.Fn PKCS7_add_signed_attribute
110for each desired additional attribute, then do the signing with
111.Xr PKCS7_final 3
112or with another finalizing function.
113.Pp
114For particular types of attributes, undocumented wrapper functions
115.Fn PKCS7_add_attrib_content_type ,
116.Fn PKCS7_add1_attrib_digest ,
117.Fn PKCS7_add0_attrib_signing_time ,
118and
119.Fn PKCS7_add_attrib_smimecap
120exist.
121.Sh RETURN VALUES
122.Fn PKCS7_add_attribute
123and
124.Fn PKCS7_add_signed_attribute
125return 1 on success or 0 on failure.
126The most common reason for failure is lack of memory.
127.Pp
128.Fn PKCS7_get_attribute
129and
130.Fn PKCS7_get_signed_attribute
131return an internal pointer to an ASN.1 ANY object or
132.Dv NULL
133on failure.
134They fail if
135.Fa nid
136is invalid, if the respective list in
137.Fa si
138contains no attribute of the requested type, or if an invalid element
139is found in the list before finding the attribute of the requested type.
140.Sh SEE ALSO
141.Xr ASN1_TYPE_new 3 ,
142.Xr PKCS7_final 3 ,
143.Xr PKCS7_new 3 ,
144.Xr PKCS7_sign 3 ,
145.Xr PKCS7_sign_add_signer 3 ,
146.Xr STACK_OF 3 ,
147.Xr X509_ATTRIBUTE_new 3
148.Sh STANDARDS
149RFC 2315: PKCS #7: Cryptographic Message Syntax Version 1.5,
150section 9.2: SignerInfo type
151.Sh HISTORY
152These functions first appeared in OpenSSL 0.9.1
153and have been available since
154.Ox 2.6 .
155.Sh BUGS
156Adding an attribute with an invalid
157.Fa nid
158ought to fail, but it actually succeeds
159setting the type of the new attribute to
160.Dv NULL .
161Subsequent attempts to retrieve attributes
162may cause the program to crash due to
163.Dv NULL
164pointer access.
165.Pp
166A function to remove individual attributes from these lists
167does not appear to exist.
168A program desiring to do that might have to manually iterate the fields
169.Fa auth_attr
170and
171.Fa unauth_attr
172of
173.Fa si ,
174which are both of type
175.Vt STACK_OF(X509_ATTRIBUTE) ,
176using the facilities described in
177.Xr STACK_OF 3
178and
179.Xr OPENSSL_sk_new 3 .