diff options
Diffstat (limited to 'src/lib/libcrypto/man/OPENSSL_sk_new.3')
-rw-r--r-- | src/lib/libcrypto/man/OPENSSL_sk_new.3 | 553 |
1 files changed, 0 insertions, 553 deletions
diff --git a/src/lib/libcrypto/man/OPENSSL_sk_new.3 b/src/lib/libcrypto/man/OPENSSL_sk_new.3 deleted file mode 100644 index 8f06bb4212..0000000000 --- a/src/lib/libcrypto/man/OPENSSL_sk_new.3 +++ /dev/null | |||
@@ -1,553 +0,0 @@ | |||
1 | .\" $OpenBSD: OPENSSL_sk_new.3,v 1.13 2024/03/04 09:47:34 tb Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2018 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: March 4 2024 $ | ||
18 | .Dt OPENSSL_SK_NEW 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm sk_new_null , | ||
22 | .Nm sk_new , | ||
23 | .Nm sk_set_cmp_func , | ||
24 | .Nm sk_dup , | ||
25 | .Nm sk_free , | ||
26 | .Nm sk_pop_free , | ||
27 | .Nm sk_num , | ||
28 | .Nm sk_value , | ||
29 | .Nm sk_find , | ||
30 | .Nm sk_sort , | ||
31 | .Nm sk_is_sorted , | ||
32 | .Nm sk_push , | ||
33 | .Nm sk_unshift , | ||
34 | .Nm sk_insert , | ||
35 | .Nm sk_set , | ||
36 | .Nm sk_pop , | ||
37 | .Nm sk_shift , | ||
38 | .Nm sk_delete , | ||
39 | .Nm sk_delete_ptr , | ||
40 | .Nm sk_zero | ||
41 | .Nd variable-sized arrays of void pointers, called OpenSSL stacks | ||
42 | .Sh SYNOPSIS | ||
43 | .In openssl/stack.h | ||
44 | .Ft _STACK * | ||
45 | .Fn sk_new_null void | ||
46 | .Ft _STACK * | ||
47 | .Fo sk_new | ||
48 | .Fa "int (*compfunc)(const void *, const void *)" | ||
49 | .Fc | ||
50 | .Ft old_function_pointer | ||
51 | .Fo sk_set_cmp_func | ||
52 | .Fa "_STACK *stack" | ||
53 | .Fa "int (*compfunc)(const void *, const void *)" | ||
54 | .Fc | ||
55 | .Ft _STACK * | ||
56 | .Fo sk_dup | ||
57 | .Fa "_STACK *stack" | ||
58 | .Fc | ||
59 | .Ft void | ||
60 | .Fo sk_free | ||
61 | .Fa "_STACK *stack" | ||
62 | .Fc | ||
63 | .Ft void | ||
64 | .Fo sk_pop_free | ||
65 | .Fa "_STACK *stack" | ||
66 | .Fa "void (*freefunc)(void *)" | ||
67 | .Fc | ||
68 | .Ft int | ||
69 | .Fo sk_num | ||
70 | .Fa "const _STACK *stack" | ||
71 | .Fc | ||
72 | .Ft void * | ||
73 | .Fo sk_value | ||
74 | .Fa "const _STACK *stack" | ||
75 | .Fa "int index" | ||
76 | .Fc | ||
77 | .Ft int | ||
78 | .Fo sk_find | ||
79 | .Fa "_STACK *stack" | ||
80 | .Fa "void *wanted" | ||
81 | .Fc | ||
82 | .Ft void | ||
83 | .Fo sk_sort | ||
84 | .Fa "_STACK *stack" | ||
85 | .Fc | ||
86 | .Ft int | ||
87 | .Fo sk_is_sorted | ||
88 | .Fa "const _STACK *stack" | ||
89 | .Fc | ||
90 | .Ft int | ||
91 | .Fo sk_push | ||
92 | .Fa "_STACK *stack" | ||
93 | .Fa "void *new_item" | ||
94 | .Fc | ||
95 | .Ft int | ||
96 | .Fo sk_unshift | ||
97 | .Fa "_STACK *stack" | ||
98 | .Fa "void *new_item" | ||
99 | .Fc | ||
100 | .Ft int | ||
101 | .Fo sk_insert | ||
102 | .Fa "_STACK *stack" | ||
103 | .Fa "void *new_item" | ||
104 | .Fa "int index" | ||
105 | .Fc | ||
106 | .Ft void * | ||
107 | .Fo sk_set | ||
108 | .Fa "_STACK *stack" | ||
109 | .Fa "int index" | ||
110 | .Fa "void *new_item" | ||
111 | .Fc | ||
112 | .Ft void * | ||
113 | .Fo sk_pop | ||
114 | .Fa "_STACK *stack" | ||
115 | .Fc | ||
116 | .Ft void * | ||
117 | .Fo sk_shift | ||
118 | .Fa "_STACK *stack" | ||
119 | .Fc | ||
120 | .Ft void * | ||
121 | .Fo sk_delete | ||
122 | .Fa "_STACK *stack" | ||
123 | .Fa "int index" | ||
124 | .Fc | ||
125 | .Ft void * | ||
126 | .Fo sk_delete_ptr | ||
127 | .Fa "_STACK *stack" | ||
128 | .Fa "void *wanted" | ||
129 | .Fc | ||
130 | .Ft void | ||
131 | .Fo sk_zero | ||
132 | .Fa "_STACK *stack" | ||
133 | .Fc | ||
134 | .Sh DESCRIPTION | ||
135 | OpenSSL introduced an idiosyncratic concept of variable sized arrays | ||
136 | of pointers and somewhat misleadingly called such an array a | ||
137 | .Dq stack . | ||
138 | Intrinsically, and as documented in this manual page, OpenSSL stacks | ||
139 | are not type safe but only handle | ||
140 | .Vt void * | ||
141 | function arguments and return values. | ||
142 | .Pp | ||
143 | OpenSSL also provides a fragile, unusually complicated system of | ||
144 | macro-generated wrappers that offers superficial type safety at the | ||
145 | expense of extensive obfuscation, implemented using large amounts | ||
146 | of autogenerated code involving exceedingly ugly, nested | ||
147 | .Xr cpp 1 | ||
148 | macros; see the | ||
149 | .Xr STACK_OF 3 | ||
150 | manual page for details. | ||
151 | .Pp | ||
152 | The fundamental data type is the | ||
153 | .Vt _STACK | ||
154 | structure. | ||
155 | It stores a variable number of void pointers | ||
156 | and remembers the number of pointers currently stored. | ||
157 | It can optionally hold a pointer to a comparison function. | ||
158 | As long as no comparison function is installed, the order of pointers | ||
159 | is meaningful; as soon as a comparison function is installed, it | ||
160 | becomes ill-defined. | ||
161 | .Pp | ||
162 | .Fn sk_new_null | ||
163 | allocates and initializes a new, empty stack. | ||
164 | .Fn sk_new | ||
165 | is identical except that it also installs | ||
166 | .Fa compfunc | ||
167 | as the comparison function for the new stack object. | ||
168 | .Fn sk_set_cmp_func | ||
169 | installs | ||
170 | .Fa compfunc | ||
171 | for the existing | ||
172 | .Fa stack . | ||
173 | The | ||
174 | .Fa compfunc | ||
175 | is allowed to be | ||
176 | .Dv NULL , | ||
177 | but the | ||
178 | .Fa stack | ||
179 | is not. | ||
180 | .Pp | ||
181 | .Fn sk_dup | ||
182 | creates a shallow copy of the given | ||
183 | .Fa stack , | ||
184 | which must not be a | ||
185 | .Dv NULL | ||
186 | pointer. | ||
187 | It neither copies the objects pointed to from the stack nor | ||
188 | increases their reference counts, but merely copies the pointers. | ||
189 | Extreme care must be taken in order to avoid freeing the memory twice, | ||
190 | for example by calling | ||
191 | .Fn sk_free | ||
192 | on one copy and only calling | ||
193 | .Fn sk_pop_free | ||
194 | on the other. | ||
195 | .Pp | ||
196 | .Fn sk_free | ||
197 | frees the given | ||
198 | .Fa stack . | ||
199 | It does not free any of the pointers stored on the stack. | ||
200 | Unless these pointers are merely copies of pointers owned by | ||
201 | other objects, they must be freed before calling | ||
202 | .Fn sk_free , | ||
203 | in order to avoid leaking memory. | ||
204 | If | ||
205 | .Fa stack | ||
206 | is a | ||
207 | .Dv NULL | ||
208 | pointer, no action occurs. | ||
209 | .Pp | ||
210 | .Fn sk_pop_free | ||
211 | is severely misnamed. | ||
212 | It does not at all do what one would expect from a function called | ||
213 | .Dq pop . | ||
214 | Instead, it does the same as | ||
215 | .Fn sk_free , | ||
216 | except that it also calls the function | ||
217 | .Fa freefunc | ||
218 | on each of the pointers contained in the | ||
219 | .Fa stack . | ||
220 | If the calls to | ||
221 | .Fa freefunc | ||
222 | are intended to free the memory in use by the objects on the stack, | ||
223 | ensure that no other pointers to the same objects remain elsewhere. | ||
224 | .Pp | ||
225 | .Fn sk_find | ||
226 | searches the | ||
227 | .Fa stack | ||
228 | for the | ||
229 | .Fa wanted | ||
230 | pointer. | ||
231 | If the | ||
232 | .Fa stack | ||
233 | contains more than one copy of the | ||
234 | .Fa wanted | ||
235 | pointer, only the first match is found. | ||
236 | If a comparison function is installed for the stack, the stack is | ||
237 | first sorted with | ||
238 | .Fn sk_sort , | ||
239 | and instead of comparing pointers, two pointers are considered to match | ||
240 | if the comparison function returns 0. | ||
241 | .Pp | ||
242 | .Fn sk_sort | ||
243 | sorts the | ||
244 | .Fa stack | ||
245 | using | ||
246 | .Xr qsort 3 | ||
247 | and the installed comparison function. | ||
248 | If | ||
249 | .Fa stack | ||
250 | is a | ||
251 | .Dv NULL | ||
252 | pointer or already considered sorted, no action occurs. | ||
253 | This function can only be called if a comparison function is installed. | ||
254 | .Pp | ||
255 | .Fn sk_is_sorted | ||
256 | reports whether the | ||
257 | .Fa stack | ||
258 | is considered sorted. | ||
259 | Calling | ||
260 | .Fn sk_new_null | ||
261 | or | ||
262 | .Fn sk_new , | ||
263 | successfully calling | ||
264 | .Fn sk_push , | ||
265 | .Fn sk_unshift , | ||
266 | .Fn sk_insert , | ||
267 | or | ||
268 | .Fn sk_set , | ||
269 | or changing the comparison function sets the state to unsorted. | ||
270 | If a comparison function is installed, calling | ||
271 | .Fn sk_sort , | ||
272 | or | ||
273 | .Fn sk_find | ||
274 | sets the state to sorted. | ||
275 | .Pp | ||
276 | .Fn sk_push | ||
277 | pushes | ||
278 | .Fa new_item | ||
279 | onto the end of the | ||
280 | .Fa stack , | ||
281 | increasing the number of pointers by 1. | ||
282 | If | ||
283 | .Fa stack | ||
284 | is a | ||
285 | .Dv NULL | ||
286 | pointer, no action occurs. | ||
287 | .Pp | ||
288 | .Fn sk_unshift | ||
289 | inserts | ||
290 | .Fa new_item | ||
291 | at the beginning of the | ||
292 | .Fa stack , | ||
293 | such that it gets the index 0. | ||
294 | The number of pointers increases by 1. | ||
295 | If | ||
296 | .Fa stack | ||
297 | is a | ||
298 | .Dv NULL | ||
299 | pointer, no action occurs. | ||
300 | .Pp | ||
301 | .Fn sk_insert | ||
302 | inserts the | ||
303 | .Fa new_item | ||
304 | into the | ||
305 | .Fa stack | ||
306 | such that it gets the given | ||
307 | .Fa index . | ||
308 | If | ||
309 | .Fa index | ||
310 | is less than 0 or greater than or equal to | ||
311 | .Fn sk_num stack , | ||
312 | the effect is the same as for | ||
313 | .Fn sk_push . | ||
314 | If | ||
315 | .Fa stack | ||
316 | is a | ||
317 | .Dv NULL | ||
318 | pointer, no action occurs. | ||
319 | .Pp | ||
320 | .Fn sk_set | ||
321 | replaces the pointer with the given | ||
322 | .Fa index | ||
323 | on the | ||
324 | .Fa stack | ||
325 | with the | ||
326 | .Fa new_item . | ||
327 | The old pointer is not freed, | ||
328 | which may leak memory if no copy of it exists elsewhere. | ||
329 | If | ||
330 | .Fa stack | ||
331 | is a | ||
332 | .Dv NULL | ||
333 | pointer or if | ||
334 | .Fa index | ||
335 | is less than 0 or greater than or equal to | ||
336 | .Fn sk_num stack , | ||
337 | no action occurs. | ||
338 | .Pp | ||
339 | .Fn sk_pop | ||
340 | and | ||
341 | .Fn sk_shift | ||
342 | remove the pointer with the highest or lowest index from the | ||
343 | .Fa stack , | ||
344 | respectively, reducing the number of pointers by 1. | ||
345 | If | ||
346 | .Fa stack | ||
347 | is a | ||
348 | .Dv NULL | ||
349 | pointer or if it is empty, no action occurs. | ||
350 | .Pp | ||
351 | .Fn sk_delete | ||
352 | removes the pointer with the given | ||
353 | .Fa index | ||
354 | from the | ||
355 | .Fa stack , | ||
356 | reducing the number of pointers by 1. | ||
357 | If | ||
358 | .Fa stack | ||
359 | is a | ||
360 | .Dv NULL | ||
361 | pointer or the | ||
362 | .Fa index | ||
363 | is less than 0 or greater than or equal to | ||
364 | .Fn sk_num stack , | ||
365 | no action occurs. | ||
366 | .Pp | ||
367 | .Fn sk_delete_ptr | ||
368 | removes the | ||
369 | .Fa wanted | ||
370 | pointer from the | ||
371 | .Fa stack , | ||
372 | reducing the number of pointers by 1 if it is found. | ||
373 | It never uses a comparison function | ||
374 | but only compares pointers themselves. | ||
375 | The | ||
376 | .Fa stack | ||
377 | pointer must not be | ||
378 | .Dv NULL . | ||
379 | .Pp | ||
380 | .Fn sk_zero | ||
381 | removes all pointers from the | ||
382 | .Fa stack . | ||
383 | It does not free any of the pointers. | ||
384 | Unless these pointers are merely copies of pointers owned by other | ||
385 | objects, they must be freed before calling | ||
386 | .Fn sk_zero , | ||
387 | in order to avoid leaking memory. | ||
388 | If | ||
389 | .Fa stack | ||
390 | is a | ||
391 | .Dv NULL | ||
392 | pointer, no action occurs. | ||
393 | .Sh RETURN VALUES | ||
394 | .Fn sk_new_null , | ||
395 | .Fn sk_new , | ||
396 | and | ||
397 | .Fn sk_dup | ||
398 | return a pointer to the newly allocated stack object or | ||
399 | .Dv NULL | ||
400 | if insufficient memory is available. | ||
401 | .Pp | ||
402 | .Fn sk_set_cmp_func | ||
403 | returns a pointer to the comparison function | ||
404 | that was previously installed for the | ||
405 | .Fa stack | ||
406 | or | ||
407 | .Dv NULL | ||
408 | if none was installed. | ||
409 | .Pp | ||
410 | .Fn sk_num | ||
411 | returns the number of pointers currently stored on the | ||
412 | .Fa stack , | ||
413 | or \-1 if | ||
414 | .Fa stack | ||
415 | is a | ||
416 | .Dv NULL | ||
417 | pointer. | ||
418 | .Pp | ||
419 | .Fn sk_value | ||
420 | returns the pointer with the given | ||
421 | .Fa index | ||
422 | from the | ||
423 | .Fa stack , | ||
424 | or | ||
425 | .Dv NULL | ||
426 | if | ||
427 | .Fa stack | ||
428 | is a | ||
429 | .Dv NULL | ||
430 | pointer or if the | ||
431 | .Fa index | ||
432 | is less than 0 or greater than or equal to | ||
433 | .Fn sk_num stack . | ||
434 | .Pp | ||
435 | .Fn sk_find | ||
436 | returns the lowest index considered to match or \-1 if | ||
437 | .Fa stack | ||
438 | is a | ||
439 | .Dv NULL | ||
440 | pointer or if no match is found. | ||
441 | .Pp | ||
442 | .Fn sk_is_sorted | ||
443 | returns 1 if the | ||
444 | .Fa stack | ||
445 | is considered sorted or if it is a | ||
446 | .Dv NULL | ||
447 | pointer, or 0 otherwise. | ||
448 | .Pp | ||
449 | .Fn sk_push , | ||
450 | .Fn sk_unshift , | ||
451 | and | ||
452 | .Fn sk_insert | ||
453 | return the new number of pointers on the | ||
454 | .Fa stack | ||
455 | or 0 if | ||
456 | .Fa stack | ||
457 | is a | ||
458 | .Dv NULL | ||
459 | pointer or if memory allocation fails. | ||
460 | .Pp | ||
461 | .Fn sk_set | ||
462 | returns | ||
463 | .Fa new_item | ||
464 | or | ||
465 | .Dv NULL | ||
466 | if | ||
467 | .Fa stack | ||
468 | is a | ||
469 | .Dv NULL | ||
470 | pointer or if the | ||
471 | .Fa index | ||
472 | is less than 0 or greater than or equal to | ||
473 | .Fn sk_num stack . | ||
474 | .Pp | ||
475 | .Fn sk_pop | ||
476 | and | ||
477 | .Fn sk_shift | ||
478 | return the deleted pointer or | ||
479 | .Dv NULL | ||
480 | if | ||
481 | .Fa stack | ||
482 | is a | ||
483 | .Dv NULL | ||
484 | pointer or if it is empty. | ||
485 | .Pp | ||
486 | .Fn sk_delete | ||
487 | returns the deleted pointer or | ||
488 | .Dv NULL | ||
489 | if | ||
490 | .Fa stack | ||
491 | is a | ||
492 | .Dv NULL | ||
493 | pointer or if the | ||
494 | .Fa index | ||
495 | is less than 0 or greater than or equal to | ||
496 | .Fn sk_num stack . | ||
497 | .Pp | ||
498 | .Fn sk_delete_ptr | ||
499 | returns | ||
500 | .Fa wanted | ||
501 | or | ||
502 | .Dv NULL | ||
503 | if it is not found. | ||
504 | .Sh SEE ALSO | ||
505 | .Xr STACK_OF 3 | ||
506 | .Sh HISTORY | ||
507 | .Fn sk_new_null , | ||
508 | .Fn sk_new , | ||
509 | .Fn sk_free , | ||
510 | .Fn sk_pop_free , | ||
511 | .Fn sk_num , | ||
512 | .Fn sk_value , | ||
513 | .Fn sk_find , | ||
514 | .Fn sk_push , | ||
515 | .Fn sk_unshift , | ||
516 | .Fn sk_insert , | ||
517 | .Fn sk_pop , | ||
518 | .Fn sk_shift , | ||
519 | .Fn sk_delete , | ||
520 | and | ||
521 | .Fn sk_delete_ptr | ||
522 | first appeared in SSLeay 0.5.1. | ||
523 | .Fn sk_set_cmp_func , | ||
524 | .Fn sk_dup , | ||
525 | and | ||
526 | .Fn sk_zero | ||
527 | first appeared in SSLeay 0.8.0. | ||
528 | These functions have been available since | ||
529 | .Ox 2.4 . | ||
530 | .Pp | ||
531 | .Fn sk_set | ||
532 | first appeared in OpenSSL 0.9.3. | ||
533 | .Fn sk_sort | ||
534 | first appeared in OpenSSL 0.9.4. | ||
535 | Both functions have been available since | ||
536 | .Ox 2.6 . | ||
537 | .Pp | ||
538 | .Fn sk_is_sorted | ||
539 | first appeared in OpenSSL 0.9.7e and has been available since | ||
540 | .Ox 3.8 . | ||
541 | .Sh BUGS | ||
542 | Even if a comparison function is installed, empty stacks and | ||
543 | stacks containing a single pointer are sometimes considered | ||
544 | sorted and sometimes considered unsorted. | ||
545 | .Pp | ||
546 | If a comparison function is installed, the concept of | ||
547 | .Dq first match | ||
548 | in | ||
549 | .Fn sk_find | ||
550 | is ill-defined because | ||
551 | .Xr qsort 3 | ||
552 | is not a stable sorting function. | ||
553 | It is probably best to only assume that they return an arbitrary match. | ||