diff options
author | schwarze <> | 2021-10-21 16:26:34 +0000 |
---|---|---|
committer | schwarze <> | 2021-10-21 16:26:34 +0000 |
commit | 7407ef96822a37aa07e99916747ae2221fdbbd3d (patch) | |
tree | 15363d1cef0087206e1d08afd012916d3f907fdb | |
parent | 4cfbd873a9384e1d78aa5a97546a95524597891e (diff) | |
download | openbsd-7407ef96822a37aa07e99916747ae2221fdbbd3d.tar.gz openbsd-7407ef96822a37aa07e99916747ae2221fdbbd3d.tar.bz2 openbsd-7407ef96822a37aa07e99916747ae2221fdbbd3d.zip |
new manual page X509_ATTRIBUTE_set1_object(3)
documenting five X.501 Attribute write accessors
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 | 267 |
4 files changed, 276 insertions, 6 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 0f6b84a1b6..51c2cf45b7 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.195 2021/10/20 13:14:00 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.196 2021/10/21 16:26:34 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> |
4 | 4 | ||
@@ -279,6 +279,7 @@ MAN= \ | |||
279 | X509_ALGOR_dup.3 \ | 279 | X509_ALGOR_dup.3 \ |
280 | X509_ATTRIBUTE_get0_object.3 \ | 280 | X509_ATTRIBUTE_get0_object.3 \ |
281 | X509_ATTRIBUTE_new.3 \ | 281 | X509_ATTRIBUTE_new.3 \ |
282 | X509_ATTRIBUTE_set1_object.3 \ | ||
282 | X509_CINF_new.3 \ | 283 | X509_CINF_new.3 \ |
283 | X509_CRL_get0_by_serial.3 \ | 284 | X509_CRL_get0_by_serial.3 \ |
284 | X509_CRL_new.3 \ | 285 | X509_CRL_new.3 \ |
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 index 72a6557985..4212e27d7e 100644 --- a/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 +++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_get0_object.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.1 2021/10/20 05:06:36 schwarze Exp $ | 1 | .\" $OpenBSD: X509_ATTRIBUTE_get0_object.3,v 1.2 2021/10/21 16:26:34 schwarze Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> |
4 | .\" | 4 | .\" |
@@ -14,7 +14,7 @@ | |||
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: October 20 2021 $ | 17 | .Dd $Mdocdate: October 21 2021 $ |
18 | .Dt X509_ATTRIBUTE_GET0_OBJECT 3 | 18 | .Dt X509_ATTRIBUTE_GET0_OBJECT 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
@@ -128,7 +128,8 @@ is not of the requested | |||
128 | .Xr ASN1_OBJECT_new 3 , | 128 | .Xr ASN1_OBJECT_new 3 , |
129 | .Xr ASN1_TYPE_new 3 , | 129 | .Xr ASN1_TYPE_new 3 , |
130 | .Xr OPENSSL_sk_new 3 , | 130 | .Xr OPENSSL_sk_new 3 , |
131 | .Xr X509_ATTRIBUTE_new 3 | 131 | .Xr X509_ATTRIBUTE_new 3 , |
132 | .Xr X509_ATTRIBUTE_set1_object 3 | ||
132 | .Sh HISTORY | 133 | .Sh HISTORY |
133 | These functions first appeared in OpenSSL 0.9.5 | 134 | These functions first appeared in OpenSSL 0.9.5 |
134 | and have been available since | 135 | and have been available since |
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 index cd3d90e4c9..e0cff822da 100644 --- a/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 +++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_new.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.10 2021/10/20 05:06:36 schwarze Exp $ | 1 | .\" $OpenBSD: X509_ATTRIBUTE_new.3,v 1.11 2021/10/21 16:26:34 schwarze Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> | 3 | .\" Copyright (c) 2016, 2021 Ingo Schwarze <schwarze@openbsd.org> |
4 | .\" | 4 | .\" |
@@ -14,7 +14,7 @@ | |||
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: October 20 2021 $ | 17 | .Dd $Mdocdate: October 21 2021 $ |
18 | .Dt X509_ATTRIBUTE_NEW 3 | 18 | .Dt X509_ATTRIBUTE_NEW 3 |
19 | .Os | 19 | .Os |
20 | .Sh NAME | 20 | .Sh NAME |
@@ -116,6 +116,7 @@ fails on | |||
116 | .Xr PKCS7_add_attribute 3 , | 116 | .Xr PKCS7_add_attribute 3 , |
117 | .Xr PKCS8_PRIV_KEY_INFO_new 3 , | 117 | .Xr PKCS8_PRIV_KEY_INFO_new 3 , |
118 | .Xr X509_ATTRIBUTE_get0_object 3 , | 118 | .Xr X509_ATTRIBUTE_get0_object 3 , |
119 | .Xr X509_ATTRIBUTE_set1_object 3 , | ||
119 | .Xr X509_EXTENSION_new 3 , | 120 | .Xr X509_EXTENSION_new 3 , |
120 | .Xr X509_new 3 , | 121 | .Xr X509_new 3 , |
121 | .Xr X509_REQ_new 3 | 122 | .Xr X509_REQ_new 3 |
diff --git a/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 b/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 new file mode 100644 index 0000000000..6a57805071 --- /dev/null +++ b/src/lib/libcrypto/man/X509_ATTRIBUTE_set1_object.3 | |||
@@ -0,0 +1,267 @@ | |||
1 | .\" $OpenBSD: X509_ATTRIBUTE_set1_object.3,v 1.1 2021/10/21 16:26:34 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2021 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: October 21 2021 $ | ||
18 | .Dt X509_ATTRIBUTE_SET1_OBJECT 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm X509_ATTRIBUTE_set1_object , | ||
22 | .Nm X509_ATTRIBUTE_set1_data , | ||
23 | .Nm X509_ATTRIBUTE_create_by_OBJ , | ||
24 | .Nm X509_ATTRIBUTE_create_by_NID , | ||
25 | .Nm X509_ATTRIBUTE_create_by_txt | ||
26 | .\" In the following line, "X.501" and "Attribute" are not typos. | ||
27 | .\" The "Attribute" type is defined in X.501, not in X.509. | ||
28 | .\" The type is called "Attribute" with capital "A", not "attribute". | ||
29 | .Nd modify an X.501 Attribute | ||
30 | .Sh SYNOPSIS | ||
31 | .In openssl/x509.h | ||
32 | .Ft int | ||
33 | .Fo X509_ATTRIBUTE_set1_object | ||
34 | .Fa "X509_ATTRIBUTE *attr" | ||
35 | .Fa "const ASN1_OBJECT *obj" | ||
36 | .Fc | ||
37 | .Ft int | ||
38 | .Fo X509_ATTRIBUTE_set1_data | ||
39 | .Fa "X509_ATTRIBUTE *attr" | ||
40 | .Fa "int type" | ||
41 | .Fa "const void *data" | ||
42 | .Fa "int len" | ||
43 | .Fc | ||
44 | .Ft X509_ATTRIBUTE * | ||
45 | .Fo X509_ATTRIBUTE_create_by_OBJ | ||
46 | .Fa "X509_ATTRIBUTE **pattr" | ||
47 | .Fa "const ASN1_OBJECT *obj" | ||
48 | .Fa "int type" | ||
49 | .Fa "const void *data" | ||
50 | .Fa "int len" | ||
51 | .Fc | ||
52 | .Ft X509_ATTRIBUTE * | ||
53 | .Fo X509_ATTRIBUTE_create_by_NID | ||
54 | .Fa "X509_ATTRIBUTE **pattr" | ||
55 | .Fa "int nid" | ||
56 | .Fa "int type" | ||
57 | .Fa "const void *data" | ||
58 | .Fa "int len" | ||
59 | .Fc | ||
60 | .Ft X509_ATTRIBUTE * | ||
61 | .Fo X509_ATTRIBUTE_create_by_txt | ||
62 | .Fa "X509_ATTRIBUTE **pattr" | ||
63 | .Fa "const char *name" | ||
64 | .Fa "int type" | ||
65 | .Fa "const unsigned char *bytes" | ||
66 | .Fa "int len" | ||
67 | .Fc | ||
68 | .Sh DESCRIPTION | ||
69 | .Fn X509_ATTRIBUTE_set1_object | ||
70 | sets the type of | ||
71 | .Fa attr | ||
72 | to | ||
73 | .Fa obj . | ||
74 | If | ||
75 | .Fa obj | ||
76 | is dynamically allocated, a deep copy is created. | ||
77 | If the type of | ||
78 | .Fa attr | ||
79 | was already set, the old type is freed | ||
80 | as far as it was dynamically allocated. | ||
81 | After calling this function, | ||
82 | .Fa attr | ||
83 | may be in an inconsistent state | ||
84 | because its values may not agree with the new attribute type. | ||
85 | .Pp | ||
86 | .Fn X509_ATTRIBUTE_set1_data | ||
87 | sets | ||
88 | .Fa attr | ||
89 | to be multi-valued and initializes its set of values | ||
90 | to contain a single new ASN.1 ANY object representing the | ||
91 | .Fa data . | ||
92 | .Pp | ||
93 | The interpretation of the | ||
94 | .Fa data | ||
95 | depends on the values of the | ||
96 | .Fa type | ||
97 | and | ||
98 | .Fa len | ||
99 | arguments; there are four different cases. | ||
100 | .Pp | ||
101 | If the | ||
102 | .Fa type | ||
103 | argument has the bit | ||
104 | .Dv MBSTRING_FLAG | ||
105 | set, | ||
106 | .Fa data | ||
107 | is expected to point to a multibyte character string that is | ||
108 | .Fa len | ||
109 | bytes long and uses the encoding specified by the | ||
110 | .Fa type | ||
111 | argument, and it is expected that an attribute type was already assigned to | ||
112 | .Fa attr , | ||
113 | for example by calling | ||
114 | .Fn X509_ATTRIBUTE_set1_object | ||
115 | before calling | ||
116 | .Fn X509_ATTRIBUTE_set1_data . | ||
117 | In this case, an appropriate ASN.1 multibyte string type is chosen and | ||
118 | a new object of that type is allocated and populated to represent the | ||
119 | .Fa data | ||
120 | by calling | ||
121 | .Xr ASN1_STRING_set_by_NID 3 . | ||
122 | The type of that new ASN.1 string object is subsequently used instead of the | ||
123 | .Fa type | ||
124 | argument. | ||
125 | .Pp | ||
126 | If the | ||
127 | .Fa type | ||
128 | argument does not have the bit | ||
129 | .Dv MBSTRING_FLAG | ||
130 | set and the | ||
131 | .Fa len argument | ||
132 | is not \-1, the | ||
133 | .Fa type | ||
134 | argument is expected to be one of the types documented in | ||
135 | .Xr ASN1_STRING_new 3 | ||
136 | and | ||
137 | .Fa data | ||
138 | is expected to point to a buffer of | ||
139 | .Fa len | ||
140 | bytes. | ||
141 | In this case, a new object is allocated with | ||
142 | .Xr ASN1_STRING_type_new 3 | ||
143 | and populated with | ||
144 | .Xr ASN1_STRING_set 3 . | ||
145 | .Pp | ||
146 | If the | ||
147 | .Fa type | ||
148 | argument does not have the bit | ||
149 | .Dv MBSTRING_FLAG | ||
150 | set and the | ||
151 | .Fa len argument | ||
152 | is \-1, | ||
153 | .Fa data | ||
154 | is expected to point to an object of the given | ||
155 | .Fa type | ||
156 | rather than to a buffer. | ||
157 | In this case, a deep copy of the existing object | ||
158 | into the new ASN.1 ANY object is performed with | ||
159 | .Xr ASN1_TYPE_set1 3 . | ||
160 | .Pp | ||
161 | If the | ||
162 | .Fa type | ||
163 | argument is 0, the | ||
164 | .Fa data | ||
165 | and | ||
166 | .Fa len | ||
167 | arguments are ignored and the set of values is left empty | ||
168 | instead of adding a single ASN.1 ANY object to it. | ||
169 | This violates section 8.2 of the X.501 standard, which requires | ||
170 | every attribute to contain at least one value, but some attribute | ||
171 | types used by the library use empty sets of values anyway. | ||
172 | .Pp | ||
173 | .Fn X509_ATTRIBUTE_create_by_OBJ | ||
174 | sets the type of | ||
175 | .Pf ** Fa attr | ||
176 | to | ||
177 | .Fa obj | ||
178 | using | ||
179 | .Fn X509_ATTRIBUTE_set1_object | ||
180 | and copies the | ||
181 | .Fa data | ||
182 | into it using | ||
183 | .Fn X509_ATTRIBUTE_set1_data . | ||
184 | If | ||
185 | .Fa attr | ||
186 | or | ||
187 | .Pf * Fa attr | ||
188 | is | ||
189 | .Dv NULL , | ||
190 | a new | ||
191 | .Vt X509_ATTRIBUTE | ||
192 | object is allocated, populated, and returned. | ||
193 | .Pp | ||
194 | .Fn X509_ATTRIBUTE_create_by_NID | ||
195 | is a wrapper around | ||
196 | .Fn X509_ATTRIBUTE_create_by_OBJ | ||
197 | that obtains the required | ||
198 | .Fa obj | ||
199 | argument by calling | ||
200 | .Xr OBJ_nid2obj 3 | ||
201 | on the | ||
202 | .Fa nid | ||
203 | argument. | ||
204 | .Pp | ||
205 | .Fn X509_ATTRIBUTE_create_by_txt | ||
206 | is a similar wrapper that obtains | ||
207 | .Fa obj | ||
208 | by calling | ||
209 | .Xr OBJ_txt2obj 3 | ||
210 | with the arguments | ||
211 | .Fa name | ||
212 | and 0, which means that long names, short names, and numerical OID | ||
213 | strings are all acceptable. | ||
214 | .Sh RETURN VALUES | ||
215 | .Fn X509_ATTRIBUTE_set1_object | ||
216 | returns 1 if successful or 0 if | ||
217 | .Fa attr | ||
218 | or | ||
219 | .Fa obj | ||
220 | is | ||
221 | .Dv NULL | ||
222 | or if memory allocation fails. | ||
223 | .Pp | ||
224 | .Fn X509_ATTRIBUTE_set1_data | ||
225 | returns 1 if successful or 0 if | ||
226 | .Fa attr | ||
227 | is | ||
228 | .Dv NULL | ||
229 | or if | ||
230 | .Xr ASN1_STRING_set_by_NID 3 , | ||
231 | .Xr ASN1_STRING_set 3 , | ||
232 | .Xr ASN1_TYPE_set1 3 , | ||
233 | or memory allocation fails. | ||
234 | .Pp | ||
235 | .Fn X509_ATTRIBUTE_create_by_OBJ , | ||
236 | .Fn X509_ATTRIBUTE_create_by_NID , | ||
237 | and | ||
238 | .Fn X509_ATTRIBUTE_create_by_txt | ||
239 | return a pointer to the changed or new object or | ||
240 | .Dv NULL | ||
241 | if obtaining | ||
242 | .Fa obj , | ||
243 | allocating mamory, or copying fails. | ||
244 | .Sh SEE ALSO | ||
245 | .Xr ASN1_OBJECT_new 3 , | ||
246 | .Xr ASN1_STRING_new 3 , | ||
247 | .Xr ASN1_STRING_set 3 , | ||
248 | .Xr ASN1_STRING_set_by_NID 3 , | ||
249 | .Xr ASN1_TYPE_new 3 , | ||
250 | .Xr OBJ_nid2obj 3 , | ||
251 | .Xr X509_ATTRIBUTE_get0_object 3 , | ||
252 | .Xr X509_ATTRIBUTE_new 3 | ||
253 | .Sh HISTORY | ||
254 | These functions first appeared in OpenSSL 0.9.5 | ||
255 | and have been available since | ||
256 | .Ox 2.7 . | ||
257 | .Sh BUGS | ||
258 | If | ||
259 | .Fa attr | ||
260 | already contains one or more values, | ||
261 | .Fn X509_ATTRIBUTE_set1_data , | ||
262 | .Fn X509_ATTRIBUTE_create_by_OBJ , | ||
263 | .Fn X509_ATTRIBUTE_create_by_NID , | ||
264 | and | ||
265 | .Fn X509_ATTRIBUTE_create_by_txt | ||
266 | silently overwrite the pointers to the old values | ||
267 | and leak the memory used for them. | ||