summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-12-17 17:56:14 +0000
committerschwarze <>2021-12-17 17:56:14 +0000
commitf3fd5e4639a117250c5d13efab1883f460960aa2 (patch)
treefa1870870dde65aca327ceeedec90557c03ee8b6
parentca1af08567d5dd9ac98a715c46a88a3271fd9522 (diff)
downloadopenbsd-f3fd5e4639a117250c5d13efab1883f460960aa2.tar.gz
openbsd-f3fd5e4639a117250c5d13efab1883f460960aa2.tar.bz2
openbsd-f3fd5e4639a117250c5d13efab1883f460960aa2.zip
new manual page OBJ_NAME_add(3)
-rw-r--r--src/lib/libcrypto/man/Makefile3
-rw-r--r--src/lib/libcrypto/man/OBJ_NAME_add.3346
-rw-r--r--src/lib/libcrypto/man/OBJ_create.35
-rw-r--r--src/lib/libcrypto/man/OBJ_nid2obj.37
-rw-r--r--src/lib/libcrypto/man/OpenSSL_add_all_algorithms.311
5 files changed, 363 insertions, 9 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 9a51640331..9f9b152d12 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.229 2021/12/15 20:07:51 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.230 2021/12/17 17:56:14 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -206,6 +206,7 @@ MAN= \
206 HMAC.3 \ 206 HMAC.3 \
207 MD5.3 \ 207 MD5.3 \
208 NAME_CONSTRAINTS_new.3 \ 208 NAME_CONSTRAINTS_new.3 \
209 OBJ_NAME_add.3 \
209 OBJ_create.3 \ 210 OBJ_create.3 \
210 OBJ_nid2obj.3 \ 211 OBJ_nid2obj.3 \
211 OCSP_CRLID_new.3 \ 212 OCSP_CRLID_new.3 \
diff --git a/src/lib/libcrypto/man/OBJ_NAME_add.3 b/src/lib/libcrypto/man/OBJ_NAME_add.3
new file mode 100644
index 0000000000..4fc4d566a7
--- /dev/null
+++ b/src/lib/libcrypto/man/OBJ_NAME_add.3
@@ -0,0 +1,346 @@
1.\" $OpenBSD: OBJ_NAME_add.3,v 1.1 2021/12/17 17:56:14 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: December 17 2021 $
18.Dt OBJ_NAME_ADD 3
19.Os
20.Sh NAME
21.Nm OBJ_NAME_add ,
22.Nm OBJ_NAME_remove ,
23.Nm OBJ_NAME_get ,
24.Nm OBJ_NAME_new_index ,
25.Nm OBJ_NAME_init ,
26.Nm OBJ_NAME_cleanup ,
27.Nm OBJ_NAME_do_all ,
28.Nm OBJ_NAME_do_all_sorted
29.Nd global associative array
30.Sh SYNOPSIS
31.In openssl/objects.h
32.Ft int
33.Fo OBJ_NAME_add
34.Fa "const char *name"
35.Fa "int type"
36.Fa "const char *data"
37.Fc
38.Ft int
39.Fo OBJ_NAME_remove
40.Fa "const char *name"
41.Fa "int type"
42.Fc
43.Ft const char *
44.Fo OBJ_NAME_get
45.Fa "const char *name"
46.Fa "int type"
47.Fc
48.Ft int
49.Fo OBJ_NAME_new_index
50.Fa "unsigned long (*hash_func)(const char *name)"
51.Fa "int (*cmp_func)(const char *name1, const char *name2)"
52.Fa "void (*free_func)(const char *name, int type, const char *value)"
53.Fc
54.Ft int
55.Fn OBJ_NAME_init void
56.Ft void
57.Fn OBJ_NAME_cleanup "int type"
58.Bd -literal
59typedef struct {
60 int type;
61 int alias;
62 const char *name;
63 const char *data;
64} OBJ_NAME;
65.Ed
66.Pp
67.Ft void
68.Fo OBJ_NAME_do_all
69.Fa "int type"
70.Fa "void (*fn)(const OBJ_NAME *pair, void *arg)"
71.Fa "void *arg"
72.Fc
73.Ft void
74.Fo OBJ_NAME_do_all_sorted
75.Fa "int type"
76.Fa "void (*fn)(const OBJ_NAME *pair, void *arg)"
77.Fa "void *arg"
78.Fc
79.Sh DESCRIPTION
80These functions implement a single, static associative array
81with the following properties:
82.Bl -bullet
83.It
84The keys are ordered pairs consisting of a NUL-terminated string
85.Pq called the Fa name
86and an
87.Vt int
88number
89.Pq called the Fa type .
90Two types are predefined and used internally by the library:
91.Dv OBJ_NAME_TYPE_MD_METH
92and
93.Dv OBJ_NAME_TYPE_CIPHER_METH .
94Two additional types are predefined but not used internally:
95.Dv OBJ_NAME_TYPE_PKEY_METH
96and
97.Dv OBJ_NAME_TYPE_COMP_METH .
98All predefined types are greater than
99.Dv OBJ_NAME_TYPE_UNDEF
100and smaller than
101.Dv OBJ_NAME_TYPE_NUM .
102.It
103The values are pointers.
104Formally, they are of the type
105.Vt const char * ,
106but in practice, pointers of other types, for example
107.Vt EVP_CIPHER *
108or
109.Vt EVP_MD * ,
110are often stored as values
111and cast back to the correct type on retrieval.
112.It
113The array supports type-specific aliases for names.
114.El
115.Pp
116.Fn OBJ_NAME_add
117removes the key-value pair or alias with the key
118.Pq Fa name , type
119in the same way as
120.Fn OBJ_NAME_remove
121and inserts a key-value pair with the specified
122.Fa name ,
123.Fa type ,
124and
125.Fa value .
126If the bit
127.Dv OBJ_NAME_ALIAS
128is set in the
129.Fa type
130argument, that bit is cleared before using the
131.Fa type
132and the key
133.Pq Fa name , type
134becomes an alias for the key
135.Pq Fa value , type
136instead of setting a value.
137It is not checked whether the key
138.Pq Fa value , type
139already exists.
140Consequently, it is possible to define an alias
141before setting the associated value.
142.Pp
143.Fn OBJ_NAME_remove
144removes the key-value pair or alias with the key
145.Pq Fa name , type
146from the array, it it exists.
147Otherwise, it has no effect.
148If the bit
149.Dv OBJ_NAME_ALIAS
150is set in the
151.Fa type
152argument, it is ignored and cleared before using the
153.Fa type .
154If the
155.Fa type
156is an application-defined type added with
157.Fn OBJ_NAME_new_index
158and the
159.Fa free_func
160associated with the
161.Fa type
162is not a
163.Dv NULL
164pointer, it is called with the
165.Fa name ,
166.Fa type ,
167and
168.Fa value
169of the key-value pair being removed or with the
170.Fa name ,
171.Fa type ,
172and alias target name of the alias being removed.
173In typical usage, this function might free the
174.Fa name ,
175and it might free the
176.Fa value
177in a type-specific way.
178.Pp
179.Fn OBJ_NAME_get
180looks up the key
181.Pq Fa name , type ,
182recursively resolving up to ten aliases if needed.
183If the bit
184.Dv OBJ_NAME_ALIAS
185is set in the
186.Fa type
187argument, it is cleared before using the
188.Fa type ,
189processing of aliases is disabled, and if
190.Pq Fa name , type
191is an alias, the target name of the alias is returned instead of a value.
192.Pp
193.Fn OBJ_NAME_new_index
194assigns the smallest unassigned positive integer number
195to represent a new, application-defined
196.Fa type .
197The three function pointers will be used, respectively,
198to hash a name for this type, to compare two names for this type,
199and to free the contents of a key-value pair holding the given
200.Fa name ,
201.Fa type ,
202and
203.Fa value .
204If the
205.Fa hash_func
206argument is a
207.Dv NULL
208pointer,
209.Xr lh_strhash 3
210is used instead.
211If the
212.Fa cmp_func
213argument is a
214.Dv NULL
215pointer,
216.Xr strcmp 3
217is used instead.
218If the
219.Fa free_func
220argument is a
221.Dv NULL
222pointer, the
223.Fa name
224and
225.Fa value
226pointers contained in the key-value pair are not freed,
227only the structure representing the pair itself is.
228This default behaviour is also used for the built-in types.
229.Pp
230.Fn OBJ_NAME_init
231initializes the array.
232After initialization, the array is empty.
233Calling
234.Fn OBJ_NAME_init
235when the array is already initialized has no effect.
236Application programs do not need to call this function because
237.Fn OBJ_NAME_add
238and
239.Fn OBJ_NAME_get
240automatically call it whenever needed.
241.Pp
242.Fn OBJ_NAME_cleanup
243removes all key-value pairs and aliases of the given
244.Fa type
245from the array by calling
246.Fn OBJ_NAME_remove
247on every such pair and alias.
248If the
249.Fa type
250argument is negative, it removes all key-value pairs and aliases
251of any type and also reverses all effects of
252.Fn OBJ_NAME_new_index
253and
254.Fn OBJ_NAME_init ,
255in particular resetting the list of types to the predefined types
256and releasing all memory reserved by these functions.
257.Pp
258The
259.Vt OBJ_NAME
260structure represents one key-value pair or one alias with the key
261.Pq Fa name , type .
262If the
263.Fa alias
264field is 0, the
265.Fa data
266field contains the value; otherwise, it contains the alias target name.
267.Pp
268.Fn OBJ_NAME_do_all
269calls
270.Fa fn
271on every
272.Fa pair
273and alias in the array that has the given
274.Fa type ,
275also passing the
276.Fa arg
277pointer.
278.Fn OBJ_NAME_do_all_sorted
279is similar except that it processes the pairs and aliases
280in lexicographic order of their names as determined by
281.Xr strcmp 3 ,
282ignoring any
283.Fa cmp_func
284that may be defined for the
285.Fa type .
286.Sh RETURN VALUES
287.Fn OBJ_NAME_add
288and
289.Fn OBJ_NAME_init
290return 1 on success or 0 if memory allocation fails.
291.Pp
292.Fn OBJ_NAME_remove
293returns 1 if one key-value pair or alias was removed or 0 otherwise.
294.Pp
295.Fn OBJ_NAME_get
296returns the
297.Fa value
298associated with the key
299.Pq Fa name , type
300or
301.Dv NULL
302if
303.Fa name
304is
305.Dv NULL ,
306if the array does not contain a value for this key,
307or if more than ten aliases are encountered before finding a value.
308.Pp
309.Fn OBJ_NAME_new_index
310returns a positive integer greater than or equal to
311.Dv OBJ_NAME_TYPE_NUM
312representing the new type or 0 if memory allocation fails.
313.Sh SEE ALSO
314.Xr EVP_cleanup 3 ,
315.Xr EVP_get_cipherbyname 3 ,
316.Xr EVP_get_digestbyname 3 ,
317.Xr lh_new 3 ,
318.Xr OBJ_create 3 ,
319.Xr OBJ_nid2obj 3
320.Sh BUGS
321Calling
322.Fn OBJ_NAME_get
323with the bit
324.Dv OBJ_NAME_ALIAS
325is not very useful because there is no way to tell
326whether the returned pointer points to a value or to a name,
327short of calling the function again without setting the bit
328and comparing the two returned pointers.
329.Pp
330The
331.Fa free_func
332has no way to tell whether its
333.Fa value
334argument is indeed of the given
335.Fa type
336or whether it is merely the target name of an alias.
337Consequently, to use values of a type
338that requires more cleanup than merely calling
339.Xr free 3
340on it, instances of the type need to begin with a magic number or string
341that cannot occur at the beginning of a name.
342.Pp
343.Fn OBJ_NAME_do_all_sorted
344is unable to report errors.
345If memory allocations fails, it does nothing at all
346without telling the caller about the problem.
diff --git a/src/lib/libcrypto/man/OBJ_create.3 b/src/lib/libcrypto/man/OBJ_create.3
index 0a91fc8655..bc081a8c80 100644
--- a/src/lib/libcrypto/man/OBJ_create.3
+++ b/src/lib/libcrypto/man/OBJ_create.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_create.3,v 1.3 2021/12/16 16:36:16 schwarze Exp $ 1.\" $OpenBSD: OBJ_create.3,v 1.4 2021/12/17 17:56:14 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400 3.\" OpenSSL OBJ_nid2obj.pod 9b86974e Aug 17 15:21:33 2015 -0400
4.\" selective merge up to: 4.\" selective merge up to:
@@ -69,7 +69,7 @@
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE. 70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\" 71.\"
72.Dd $Mdocdate: December 16 2021 $ 72.Dd $Mdocdate: December 17 2021 $
73.Dt OBJ_CREATE 3 73.Dt OBJ_CREATE 3
74.Os 74.Os
75.Sh NAME 75.Sh NAME
@@ -253,6 +253,7 @@ obj = OBJ_nid2obj(new_nid);
253.Sh SEE ALSO 253.Sh SEE ALSO
254.Xr ASN1_OBJECT_new 3 , 254.Xr ASN1_OBJECT_new 3 ,
255.Xr EVP_cleanup 3 , 255.Xr EVP_cleanup 3 ,
256.Xr OBJ_NAME_add 3 ,
256.Xr OBJ_nid2obj 3 257.Xr OBJ_nid2obj 3
257.Sh HISTORY 258.Sh HISTORY
258.Fn OBJ_new_nid , 259.Fn OBJ_new_nid ,
diff --git a/src/lib/libcrypto/man/OBJ_nid2obj.3 b/src/lib/libcrypto/man/OBJ_nid2obj.3
index a43fe962e1..a337cedf18 100644
--- a/src/lib/libcrypto/man/OBJ_nid2obj.3
+++ b/src/lib/libcrypto/man/OBJ_nid2obj.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OBJ_nid2obj.3,v 1.16 2021/12/15 20:07:51 schwarze Exp $ 1.\" $OpenBSD: OBJ_nid2obj.3,v 1.17 2021/12/17 17:56:14 schwarze Exp $
2.\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000 2.\" full merge up to: OpenSSL c264592d May 14 11:28:00 2006 +0000
3.\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200 3.\" selective merge up to: OpenSSL 35fd9953 May 28 14:49:38 2019 +0200
4.\" 4.\"
@@ -67,7 +67,7 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: December 15 2021 $ 70.Dd $Mdocdate: December 17 2021 $
71.Dt OBJ_NID2OBJ 3 71.Dt OBJ_NID2OBJ 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
@@ -389,7 +389,8 @@ obj = OBJ_txt2obj("1.2.3.4", 1);
389.Xr ASN1_OBJECT_new 3 , 389.Xr ASN1_OBJECT_new 3 ,
390.Xr BIO_new 3 , 390.Xr BIO_new 3 ,
391.Xr d2i_ASN1_OBJECT 3 , 391.Xr d2i_ASN1_OBJECT 3 ,
392.Xr OBJ_create 3 392.Xr OBJ_create 3 ,
393.Xr OBJ_NAME_add 3
393.Sh HISTORY 394.Sh HISTORY
394.Fn OBJ_nid2obj , 395.Fn OBJ_nid2obj ,
395.Fn OBJ_nid2ln , 396.Fn OBJ_nid2ln ,
diff --git a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3 b/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
index e47948df4c..f95c0713ef 100644
--- a/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
+++ b/src/lib/libcrypto/man/OpenSSL_add_all_algorithms.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.9 2021/12/16 16:36:16 schwarze Exp $ 1.\" $OpenBSD: OpenSSL_add_all_algorithms.3,v 1.10 2021/12/17 17:56:14 schwarze Exp $
2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400 2.\" full merge up to: OpenSSL b3696a55 Sep 2 09:35:50 2017 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
@@ -48,7 +48,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 50.\"
51.Dd $Mdocdate: December 16 2021 $ 51.Dd $Mdocdate: December 17 2021 $
52.Dt OPENSSL_ADD_ALL_ALGORITHMS 3 52.Dt OPENSSL_ADD_ALL_ALGORITHMS 3
53.Os 53.Os
54.Sh NAME 54.Sh NAME
@@ -98,12 +98,17 @@ If any of the above functions is called more than once,
98only the first call has an effect. 98only the first call has an effect.
99.Pp 99.Pp
100.Fn EVP_cleanup 100.Fn EVP_cleanup
101removes all ciphers and digests from the table. 101removes all ciphers and digests from the table and also calls
102.Xr OBJ_NAME_cleanup 3
103with an argument of \-1, thus resetting the global associative array
104to its default state, removing all types, key-value pairs, and aliases
105from it, including any that are unrelated to the EVP library.
102.Sh SEE ALSO 106.Sh SEE ALSO
103.Xr evp 3 , 107.Xr evp 3 ,
104.Xr EVP_DigestInit 3 , 108.Xr EVP_DigestInit 3 ,
105.Xr EVP_EncryptInit 3 , 109.Xr EVP_EncryptInit 3 ,
106.Xr OBJ_cleanup 3 , 110.Xr OBJ_cleanup 3 ,
111.Xr OBJ_NAME_add 3 ,
107.Xr OPENSSL_config 3 112.Xr OPENSSL_config 3
108.Sh HISTORY 113.Sh HISTORY
109.Fn EVP_cleanup 114.Fn EVP_cleanup