summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/ENGINE_ctrl.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/ENGINE_ctrl.3')
-rw-r--r--src/lib/libcrypto/man/ENGINE_ctrl.3470
1 files changed, 0 insertions, 470 deletions
diff --git a/src/lib/libcrypto/man/ENGINE_ctrl.3 b/src/lib/libcrypto/man/ENGINE_ctrl.3
deleted file mode 100644
index b4965a5a03..0000000000
--- a/src/lib/libcrypto/man/ENGINE_ctrl.3
+++ /dev/null
@@ -1,470 +0,0 @@
1.\" $OpenBSD: ENGINE_ctrl.3,v 1.5 2022/01/15 23:38:50 jsg Exp $
2.\" content checked up to:
3.\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800
4.\"
5.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
6.\"
7.\" Permission to use, copy, modify, and distribute this software for any
8.\" purpose with or without fee is hereby granted, provided that the above
9.\" copyright notice and this permission notice appear in all copies.
10.\"
11.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18.\"
19.Dd $Mdocdate: January 15 2022 $
20.Dt ENGINE_CTRL 3
21.Os
22.Sh NAME
23.Nm ENGINE_ctrl ,
24.Nm ENGINE_cmd_is_executable ,
25.Nm ENGINE_ctrl_cmd ,
26.Nm ENGINE_ctrl_cmd_string ,
27.Nm ENGINE_set_ctrl_function ,
28.Nm ENGINE_get_ctrl_function ,
29.Nm ENGINE_set_cmd_defns ,
30.Nm ENGINE_get_cmd_defns
31.Nd control commands for ENGINE objects
32.Sh SYNOPSIS
33.In openssl/engine.h
34.Ft int
35.Fo ENGINE_ctrl
36.Fa "ENGINE *e"
37.Fa "int cmd"
38.Fa "long i"
39.Fa "void *p"
40.Fa "void (*f)(void)"
41.Fc
42.Ft int
43.Fo ENGINE_cmd_is_executable
44.Fa "ENGINE *e"
45.Fa "int cmd"
46.Fc
47.Ft int
48.Fo ENGINE_ctrl_cmd
49.Fa "ENGINE *e"
50.Fa "const char *cmd_name"
51.Fa "long i"
52.Fa "void *p"
53.Fa "void (*f)(void)"
54.Fa "int cmd_optional"
55.Fc
56.Ft int
57.Fo ENGINE_ctrl_cmd_string
58.Fa "ENGINE *e"
59.Fa "const char *cmd_name"
60.Fa "const char *arg"
61.Fa "int cmd_optional"
62.Fc
63.Ft typedef int
64.Fo (*ENGINE_CTRL_FUNC_PTR)
65.Fa "ENGINE *e"
66.Fa "int cmd"
67.Fa "long i"
68.Fa "void *p"
69.Fa "void (*f)(void)"
70.Fc
71.Ft int
72.Fo ENGINE_set_ctrl_function
73.Fa "ENGINE *e"
74.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f"
75.Fc
76.Ft ENGINE_CTRL_FUNC_PTR
77.Fo ENGINE_get_ctrl_function
78.Fa "const ENGINE *e"
79.Fc
80.Ft int
81.Fo ENGINE_set_cmd_defns
82.Fa "ENGINE *e"
83.Fa "const ENGINE_CMD_DEFN *defns"
84.Fc
85.Ft const ENGINE_CMD_DEFN *
86.Fo ENGINE_get_cmd_defns
87.Fa "const ENGINE *e"
88.Fc
89.Sh DESCRIPTION
90.Fn ENGINE_ctrl
91calls the built-in or user-defined
92.Fa cmd
93for the engine
94.Fa e ,
95passing the arguments
96.Fa i
97and
98.Fa p .
99.Pp
100User-defined commands can be used before
101.Xr ENGINE_init 3
102to provide data required for initialization
103or at any time to modify the behaviour of an engine.
104.Pp
105Most built-in commands operate on user-defined commands installed with
106.Fn ENGINE_set_cmd_defns ,
107either using the
108.Fa p
109argument to indicate the user-defined command with the command name
110.Fa cmd_name
111or using the
112.Fa i
113argument to indicate the user-defined command with the command number
114.Fa cmd_num .
115The
116.Fa cmd
117arguments to call the built-in commands are as follows:
118.Bl -tag -width Ds
119.It Dv ENGINE_CTRL_GET_CMD_FLAGS
120Return the
121.Fa cmd_flags
122of the user-defined command with the number
123.Fa i ,
124or a number less than or equal to 0 if an error occurs or
125the command number does not exist.
126A return value of 0 indicates failure if
127.Fa e
128is
129.Dv NULL
130or has a reference count of 0, or success if
131.Fa e
132is valid.
133.It Dv ENGINE_CTRL_GET_CMD_FROM_NAME
134Return the positive command number
135of the user-defined command with the name
136.Fa p ,
137or a number less than or equal to 0 if an error occurs or no
138matching name is found.
139.It Dv ENGINE_CTRL_GET_DESC_FROM_CMD
140Copy the description of the user-defined command with the number
141.Fa i
142into the buffer
143.Fa p
144and NUL-terminate it.
145It is the responsibility of the caller to make sure that the buffer
146.Fa p
147is large enough, either by calling
148.Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD
149first or using knowledge about the array passed to
150.Fn ENGINE_set_cmd_defns .
151The return value is the number of bytes written
152.Em including
153the terminating NUL byte, or a number less than or equal to 0
154if an error occurs.
155.It Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD
156Return the length in bytes
157.Em excluding
158the terminating NUL byte
159of the description of the user-defined command with the number
160.Fa i ,
161or a number less than or equal to 0 if an error occurs.
162A return value of 0 indicates failure if
163.Fa e
164is
165.Dv NULL
166or has a reference count of 0, or success if
167.Fa e
168is valid.
169.It Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE
170Return the positive command number
171of the first user-defined command installed with
172.Fn ENGINE_set_cmd_defns
173or a number less than or equal to 0 if an error occurs or no
174user-defined command has been installed.
175.It Dv ENGINE_CTRL_GET_NAME_FROM_CMD
176Copy the name of the user-defined command with the number
177.Fa i
178into the buffer
179.Fa p
180and NUL-terminate it.
181It is the responsibility of the caller to make sure that the buffer
182.Fa p
183is large enough, either by calling
184.Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD
185first or using knowledge about the array passed to
186.Fn ENGINE_set_cmd_defns .
187The return value is the number of bytes written
188.Em including
189the terminating NUL byte, or a number less than or equal to 0
190if an error occurs.
191.It Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD
192Return the length in bytes
193.Em excluding
194the terminating NULL byte
195of the name of the user-defined command with the number
196.Fa i ,
197or a number less than or equal to 0 if an error occurs.
198A return value of 0 indicates failure if
199.Fa e
200is
201.Dv NULL
202or has a reference count of 0, or success if
203.Fa e
204is valid.
205.It Dv ENGINE_CTRL_GET_NEXT_CMD_TYPE
206Return the positive command number of the next user-defined command
207after the user-defined command with the number
208.Fa i ,
209or a number less than or equal to 0 if an error occurs or if
210.Fa i
211is the last user-defined command.
212Together with
213.Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE ,
214this can be used to iterate the user-defined commands installed with
215.Fn ENGINE_set_cmd_defns .
216.It Dv ENGINE_CTRL_HAS_CTRL_FUNCTION
217Return 1 if
218.Fa e
219has its own
220.Fa ctrl_f
221installed with
222.Fn ENGINE_set_ctrl_function
223or 0 otherwise.
224.El
225.Pp
226.Fn ENGINE_ctrl_cmd
227translates the
228.Fa cmd_name
229of a user-defined command to a
230.Fa cmd
231number and calls
232.Fn ENGINE_ctrl
233on it.
234If
235.Fa cmd_optional
236is non-zero, lack of a
237.Fa ctrl_f
238in
239.Fa e
240and translation failure with
241.Dv ENGINE_CTRL_GET_CMD_FROM_NAME
242are considered success, and the command has no effect.
243Otherwise, these problems cause
244.Fn ENGINE_ctrl_cmd
245to fail.
246.Pp
247Neither
248.Fn ENGINE_ctrl
249nor
250.Fn ENGINE_ctrl_cmd
251ever call the
252.Fa f
253callback, but merely pass it on as an argument to the engine-specific
254.Fa ctrl_f
255control function.
256It is up to
257.Fa ctrl_f
258how to use it, or alternatively to ignore it as well.
259.Pp
260.Fn ENGINE_ctrl_cmd_string
261translates the
262.Fa cmd_name
263of a user-defined command to a
264.Fa cmd
265number.
266If that command has the
267.Dv ENGINE_CMD_FLAG_NO_INPUT
268flag set,
269.Fa arg
270must be
271.Dv NULL
272and
273.Fn ENGINE_ctrl
274is called with
275.Fa i
276set to 0 and
277.Fa p
278set to
279.Dv NULL .
280Otherwise,
281.Fa arg
282must not be
283.Dv NULL .
284If the command accepts string input,
285.Fa i
286is set to 0 and
287.Fa arg
288is passed as the
289.Fa p
290argument to
291.Fn ENGINE_ctrl .
292Otherwise,
293.Fa arg
294is converted with
295.Xr strtol 3
296and passed as the
297.Fa i
298argument to
299.Fn ENGINE_ctrl ,
300setting
301.Fa p
302to
303.Dv NULL .
304.Pp
305.Fn ENGINE_set_ctrl_function
306installs
307.Fa ctrl_f
308as the engine-specific control function for
309.Fa e .
310Future calls to
311.Fn ENGINE_ctrl
312will call that function, passing on their arguments unchanged, if the
313.Fa cmd
314is not built-in to the library or if the
315.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
316flag is set in
317.Fa e .
318Let the
319.Fa ctrl_f
320return positive values on success or negative values on failure.
321Avoid return values of 0 because they cause dangerous ambiguity.
322In particular,
323.Fn ENGINE_ctrl_cmd
324and
325.Fn ENGINE_ctrl_cmd_string
326cannot be used with user-defined commands
327that may return 0 on success.
328.Pp
329.Fn ENGINE_set_cmd_defns
330install an array of command definitions in
331.Fa e .
332.Pp
333The structure
334.Vt ENGINE_CMD_DEFN
335has the following fields:
336.Bl -tag -width Ds
337.It Fa "unsigned int cmd_num"
338A positive, unique, monotonically increasing command number.
339Avoid using numbers below
340.Dv ENGINE_CMD_BASE .
341.It Fa "const char *cmd_name"
342The unique name of the command.
343.It Fa "const char *cmd_desc"
344A short description of the command.
345.It Fa "unsigned int cmd_flags"
346The bitwise OR of zero or more of the following flags:
347.Bl -tag -width Ds
348.It Dv ENGINE_CMD_FLAG_NUMERIC
349The command uses
350.Fa i .
351.It Dv ENGINE_CMD_FLAG_STRING
352The command uses
353.Fa p .
354.It Dv ENGINE_CMD_FLAG_NO_INPUT
355The command neither uses
356.Fa i
357nor
358.Fa p .
359.It Dv ENGINE_CMD_FLAG_INTERNAL
360This flag has no effect and is only provided for compatibility.
361.El
362.El
363.Pp
364The last element of
365.Fa defns
366does not specify a command, but must have a
367.Fa cmd_num
368of 0 and a
369.Fa cmd_name
370of
371.Dv NULL
372to indicate the end of the array.
373.Sh RETURN VALUES
374For
375.Fn ENGINE_ctrl ,
376positive return values indicate success and negative return values
377indicate failure.
378The meaning of a zero return value depends on the particular
379.Fa cmd
380and may indicate both success and failure, which is pathetic.
381.Pp
382Regardless of the
383.Fa cmd ,
384.Fn ENGINE_ctrl
385returns 0 if
386.Fa e
387is
388.Dv NULL
389or has a reference count of 0.
390This is quite unfortunate for commands like
391.Dv ENGINE_CTRL_GET_CMD_FLAGS
392where 0 may indicate success, so make sure
393.Fa e
394is valid before issuing a control command.
395.Pp
396For built-in commands except
397.Dv ENGINE_CTRL_HAS_CTRL_FUNCTION ,
398.Fn ENGINE_ctrl
399returns \-1 if
400.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
401is set but no
402.Fa ctrl_f
403has been installed with
404.Fn ENGINE_set_ctrl_function .
405.Pp
406For commands that are not built in,
407.Fn ENGINE_ctrl
408returns 0 if no
409.Fa ctrl_f
410has been installed with
411.Fn ENGINE_set_ctrl_function .
412.Pp
413.Fn ENGINE_cmd_is_executable
414returns 1 if the user-defined
415.Fa cmd
416is executable and has at least one of the flags
417.Dv ENGINE_CMD_FLAG_NUMERIC ,
418.Dv ENGINE_CMD_FLAG_STRING ,
419and
420.Dv ENGINE_CMD_FLAG_NO_INPUT
421set, or 0 otherwise.
422.Pp
423.Fn ENGINE_ctrl_cmd
424and
425.Fn ENGINE_ctrl_cmd_string
426return 1 on success or 0 on error.
427.Pp
428.Fn ENGINE_set_ctrl_function
429and
430.Fn ENGINE_set_cmd_defns
431always return 1.
432.Pp
433.Fn ENGINE_get_ctrl_function
434returns a pointer to the function
435.Fa ctrl_f
436installed with
437.Fn ENGINE_set_ctrl_function ,
438or
439.Dv NULL
440if none has been installed.
441.Pp
442.Fn ENGINE_get_cmd_defns
443returns the array of command definitions installed in
444.Fa e
445or
446.Dv NULL
447if none is installed.
448.Sh SEE ALSO
449.Xr ENGINE_add 3 ,
450.Xr ENGINE_init 3 ,
451.Xr ENGINE_new 3 ,
452.Xr ENGINE_register_RSA 3 ,
453.Xr ENGINE_set_flags 3 ,
454.Xr ENGINE_set_RSA 3
455.Sh HISTORY
456.Fn ENGINE_ctrl ,
457.Fn ENGINE_set_ctrl_function ,
458and
459.Fn ENGINE_get_ctrl_function
460first appeared in OpenSSL 0.9.7 and have been available since
461.Ox 2.9 .
462.Pp
463.Fn ENGINE_cmd_is_executable ,
464.Fn ENGINE_ctrl_cmd ,
465.Fn ENGINE_ctrl_cmd_string ,
466.Fn ENGINE_set_cmd_defns ,
467and
468.Fn ENGINE_get_cmd_defns
469first appeared in OpenSSL 0.9.7 and have been available since
470.Ox 3.2 .