summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2018-04-15 01:43:45 +0000
committerschwarze <>2018-04-15 01:43:45 +0000
commit83e8d72fcb33da2c34c5964418ed6fa3b12d08c7 (patch)
treeb200b1089b2fc8e8d079bc4aa2d58db943197f7c
parentca2431d035ec6e4a115f384ff029c2316dd0d465 (diff)
downloadopenbsd-83e8d72fcb33da2c34c5964418ed6fa3b12d08c7.tar.gz
openbsd-83e8d72fcb33da2c34c5964418ed6fa3b12d08c7.tar.bz2
openbsd-83e8d72fcb33da2c34c5964418ed6fa3b12d08c7.zip
Rewrite the ENGINE_*(3) documentation from scratch (step 1,
covering 60% of the documented functions). The old, abominable engine(3) manual page shall die soon.
-rw-r--r--src/lib/libcrypto/man/ENGINE_add.3143
-rw-r--r--src/lib/libcrypto/man/ENGINE_ctrl.3428
-rw-r--r--src/lib/libcrypto/man/ENGINE_get_default_RSA.3133
-rw-r--r--src/lib/libcrypto/man/ENGINE_init.3122
-rw-r--r--src/lib/libcrypto/man/ENGINE_register_RSA.3115
-rw-r--r--src/lib/libcrypto/man/ENGINE_register_all_RSA.373
-rw-r--r--src/lib/libcrypto/man/ENGINE_set_default.3156
-rw-r--r--src/lib/libcrypto/man/ENGINE_unregister_RSA.396
-rw-r--r--src/lib/libcrypto/man/Makefile10
-rw-r--r--src/lib/libcrypto/man/engine.3557
10 files changed, 1303 insertions, 530 deletions
diff --git a/src/lib/libcrypto/man/ENGINE_add.3 b/src/lib/libcrypto/man/ENGINE_add.3
new file mode 100644
index 0000000000..faecb8a2ab
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_add.3
@@ -0,0 +1,143 @@
1.\" $OpenBSD: ENGINE_add.3,v 1.1 2018/04/15 01:43:45 schwarze Exp $
2.\" content checked up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800
3.\"
4.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: April 15 2018 $
19.Dt ENGINE_ADD 3
20.Os
21.Sh NAME
22.Nm ENGINE_add ,
23.Nm ENGINE_remove ,
24.Nm ENGINE_get_first ,
25.Nm ENGINE_get_last ,
26.Nm ENGINE_get_next ,
27.Nm ENGINE_get_prev ,
28.Nm ENGINE_by_id
29.Nd maintain a global list of ENGINE objects
30.Sh SYNOPSIS
31.In openssl/engine.h
32.Ft int
33.Fo ENGINE_add
34.Fa "ENGINE *e"
35.Fc
36.Ft int
37.Fo ENGINE_remove
38.Fa "ENGINE *e"
39.Fc
40.Ft ENGINE *
41.Fn ENGINE_get_first void
42.Ft ENGINE *
43.Fn ENGINE_get_last void
44.Ft ENGINE *
45.Fo ENGINE_get_next
46.Fa "ENGINE *e"
47.Fc
48.Ft ENGINE *
49.Fo ENGINE_get_prev
50.Fa "ENGINE *e"
51.Fc
52.Ft ENGINE *
53.Fo ENGINE_by_id
54.Fa "const char *id"
55.Fc
56.Sh DESCRIPTION
57The crypto library maintains a global list of
58.Vt ENGINE
59objects.
60.Pp
61.Fn ENGINE_add
62appends
63.Fa e
64to the end of the list
65and increments its structural reference count by 1.
66The name and identifier of
67.Fa e
68have to be set with
69.Xr ENGINE_set_name 3
70and
71.Xr ENGINE_set_id 3
72before calling this function.
73.Fn ENGINE_add
74fails if the list already contains an
75.Vt ENGINE
76with the same identifier.
77.Pp
78.Fn ENGINE_remove
79removes
80.Fa e
81from the list.
82If successful, it calls
83.Xr ENGINE_free 3
84on
85.Fa e .
86.Pp
87.Fn ENGINE_get_first
88and
89.Fn ENGINE_get_last
90provide access to the first and last
91.Vt ENGINE
92object on the list, respectively.
93Unless the list is empty, they increment the structural reference
94count of the retrieved object by 1.
95.Pp
96.Fn ENGINE_get_next
97and
98.Fn ENGINE_get_prev
99support iteration of the list.
100They always call
101.Xr ENGINE_free 3
102on
103.Fa e .
104Unless the end of the list is reached, they increment the structural
105reference count of the retrieved object by 1.
106.Pp
107.Fn ENGINE_by_id
108searches the list for an
109.Vt ENGINE
110object with a matching
111.Fa id .
112If found, it increments the structural reference count of the
113retrieved object by 1.
114.Sh RETURN VALUES
115.Fn ENGINE_add
116and
117.Fn ENGINE_remove
118return 1 on success or 0 on error.
119.Pp
120.Fn ENGINE_get_first
121and
122.Fn ENGINE_get_last
123return an
124.Vt ENGINE
125object or
126.Dv NULL
127if the list is empty.
128.Pp
129.Fn ENGINE_get_next
130and
131.Fn ENGINE_get_prev
132return an
133.Vt ENGINE
134object or
135.Dv NULL
136when the end of the list is reached.
137.Pp
138.Fn ENGINE_by_id
139returns an
140.Vt ENGINE
141object or
142.Dv NULL
143if no matching object is found.
diff --git a/src/lib/libcrypto/man/ENGINE_ctrl.3 b/src/lib/libcrypto/man/ENGINE_ctrl.3
new file mode 100644
index 0000000000..1672f2976e
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_ctrl.3
@@ -0,0 +1,428 @@
1.\" $OpenBSD: ENGINE_ctrl.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
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.Fo ENGINE_ctrl
35.Fa "ENGINE *e"
36.Fa "int cmd"
37.Fa "long i"
38.Fa "void *p"
39.Fa "void (*f)(void)"
40.Fc
41.Ft int
42.Fo ENGINE_cmd_is_executable
43.Fa "ENGINE *e"
44.Fa "int cmd"
45.Fc
46.Ft int
47.Fo ENGINE_ctrl_cmd
48.Fa "ENGINE *e"
49.Fa "const char *cmd_name"
50.Fa "long i"
51.Fa "void *p"
52.Fa "void (*f)(void)"
53.Fa "int cmd_optional"
54.Fc
55.Ft int
56.Fo ENGINE_ctrl_cmd_string
57.Fa "ENGINE *e"
58.Fa "const char *cmd_name"
59.Fa "const char *arg"
60.Fa "int cmd_optional"
61.Fc
62.Ft typedef int
63.Fo (*ENGINE_CTRL_FUNC_PTR)
64.Fa "ENGINE *e"
65.Fa "int cmd"
66.Fa "long i"
67.Fa "void *p"
68.Fa "void (*f)(void)"
69.Fc
70.Ft int
71.Fo ENGINE_set_ctrl_function
72.Fa "ENGINE *e"
73.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f"
74.Fc
75.Ft ENGINE_CTRL_FUNC_PTR
76.Fo ENGINE_get_ctrl_function
77.Fa "const ENGINE *e"
78.Fc
79.Ft int
80.Fo ENGINE_set_cmd_defns
81.Fa "ENGINE *e"
82.Fa "const ENGINE_CMD_DEFN *defns"
83.Fc
84.Ft const ENGINE_CMD_DEFN *
85.Fo ENGINE_get_cmd_defns
86.Fa "const ENGINE *e"
87.Fc
88.Sh DESCRIPTION
89.Fn ENGINE_ctrl
90calls the built-in or user-defined
91.Fa cmd
92for the engine
93.Fa e ,
94passing the arguments
95.Fa i
96and
97.Fa p .
98.Pp
99Most built-in commands operate on user-defined commands installed with
100.Fn ENGINE_set_cmd_defns ,
101either using the
102.Fa p
103argument to indicate the user-defined command with the command name
104.Fa cmd_name
105or using the
106.Fa i
107argument to indicate the user-defined command with the command number
108.Fa cmd_num .
109The
110.Fa cmd
111arguments to call the built-in commands are as follows:
112.Bl -tag -width Ds
113.It Dv ENGINE_CTRL_GET_CMD_FLAGS
114Return the
115.Fa cmd_flags
116of the user-defined command with the number
117.Fa i ,
118or a number less than or equal to 0 if an error occurs or
119the command number does not exist.
120A return value of 0 indicates failure if
121.Fa e
122is
123.Dv NULL
124or has a reference count of 0, or success if
125.Fa e
126is valid.
127.It Dv ENGINE_CTRL_GET_CMD_FROM_NAME
128Return the positive command number
129of the user-defined command with the name
130.Fa p ,
131or a number less than or equal to 0 if an error occurs or no
132matching name is found.
133.It Dv ENGINE_CTRL_GET_DESC_FROM_CMD
134Copy the description of the user-defined command with the number
135.Fa i
136into the buffer
137.Fa p
138and NUL-terminate it.
139It is the reponsability of the caller to make sure that the buffer
140.Fa p
141is large enough, either by calling
142.Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD
143first or using knowledge about the array passed to
144.Fn ENGINE_set_cmd_defns .
145The return value is the number of bytes written
146.Em including
147the terminating NUL byte, or a number less than or equal to 0
148if an error occurs.
149.It Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD
150Return the length in bytes
151.Em excluding
152the terminating NUL byte
153of the description of the user-defined command with the number
154.Fa i ,
155or a number less than or equal to 0 if an error occurs.
156A return value of 0 indicates failure if
157.Fa e
158is
159.Dv NULL
160or has a reference count of 0, or success if
161.Fa e
162is valid.
163.It Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE
164Return the positive command number
165of the first user-defined command installed with
166.Fn ENGINE_set_cmd_defns
167or a number less than or equal to 0 if an error occurs or no
168user-defined command has been installed.
169.It Dv ENGINE_CTRL_GET_NAME_FROM_CMD
170Copy the name of the user-defined command with the number
171.Fa i
172into the buffer
173.Fa p
174and NUL-terminate it.
175It is the reponsability of the caller to make sure that the buffer
176.Fa p
177is large enough, either by calling
178.Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD
179first or using knowledge about the array passed to
180.Fn ENGINE_set_cmd_defns .
181The return value is the number of bytes written
182.Em including
183the terminating NUL byte, or a number less than or equal to 0
184if an error occurs.
185.It Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD
186Return the length in bytes
187.Em excluding
188the terminating NULL byte
189of the name of the user-defined command with the number
190.Fa i ,
191or a number less than or equal to 0 if an error occurs.
192A return value of 0 indicates failure if
193.Fa e
194is
195.Dv NULL
196or has a reference count of 0, or success if
197.Fa e
198is valid.
199.It Dv ENGINE_CTRL_GET_NEXT_CMD_TYPE
200Return the positive command number of the next user-defined command
201after the user-defined command with the number
202.Fa i ,
203or a number less than or equal to 0 if an error occurs or if
204.Fa i
205is the last user-defined command.
206Together with
207.Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE ,
208this can be used to iterate the user-defined commands installed with
209.Fn ENGINE_set_cmd_defns .
210.It Dv ENGINE_CTRL_HAS_CTRL_FUNCTION
211Return 1 if
212.Fa e
213has its own
214.Fa ctrl_f
215installed with
216.Fn ENGINE_set_ctrl_function
217or 0 otherwise.
218.El
219.Pp
220.Fn ENGINE_ctrl_cmd
221translates the
222.Fa cmd_name
223of a user-defined command to a
224.Fa cmd
225number and calls
226.Fn ENGINE_ctrl
227on it.
228If
229.Fa cmd_optional
230is non-zero, lack of a
231.Fa ctrl_f
232in
233.Fa e
234and translation failure with
235.Dv ENGINE_CTRL_GET_CMD_FROM_NAME
236are considered success, and the command has no effect.
237Otherwise, these problems cause
238.Fn ENGINE_ctrl_cmd
239to fail.
240.Pp
241.Fn ENGINE_ctrl_cmd_string
242translates the
243.Fa cmd_name
244of a user-defined command to a
245.Fa cmd
246number.
247If that command has the
248.Dv ENGINE_CMD_FLAG_NO_INPUT
249flag set,
250.Fa arg
251must be
252.Dv NULL
253and
254.Fn ENGINE_ctrl
255is called with
256.Fa i
257set to 0 and
258.Fa p
259set to
260.Dv NULL .
261Otherwise,
262.Fa arg
263must not be
264.Dv NULL .
265If the command accepts string input,
266.Fa i
267is set to 0 and
268.Fa arg
269is passed as the
270.Fa p
271argument to
272.Fn ENGINE_ctrl .
273Otherwise,
274.Fa arg
275is converted with
276.Xr strtol 3
277and passed as the
278.Fa i
279argument to
280.Fn ENGINE_ctrl ,
281setting
282.Fa p
283to
284.Dv NULL .
285.Pp
286.Fn ENGINE_set_ctrl_function
287installs
288.Fa ctrl_f
289as the engine-specific control function for
290.Fa e .
291Future calls to
292.Fn ENGINE_ctrl
293will call that function, passing on their arguments unchanged, if the
294.Fa cmd
295is not built-in to the library or if the
296.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
297flag is set in
298.Fa e .
299Let the
300.Fa ctrl_f
301return positive values on success or negative values on failure.
302Avoid return values of 0 because they cause dangerous ambiguity.
303In particular,
304.Fn ENGINE_ctrl_cmd
305and
306.Fn ENGINE_ctrl_cmd_string
307cannot be used with user-defined commands
308that may return 0 on success.
309.Pp
310.Fn ENGINE_set_cmd_defns
311install an array of command definitions in
312.Fa e .
313.Pp
314The structure
315.Vt ENGINE_CMD_DEFN
316has the following fields:
317.Bl -tag -width Ds
318.It Fa "unsigned int cmd_num"
319A positive, unique, monotonically increasing command number.
320Avoid using numbers below
321.Dv ENGINE_CMD_BASE .
322.It Fa "const char *cmd_name"
323The unique name of the command.
324.It Fa "const char *cmd_desc"
325A short description of the command.
326.It Fa "unsigned int cmd_flags"
327The bitwise OR of zero or more of the following flags:
328.Bl -tag -width Ds
329.It Dv ENGINE_CMD_FLAG_NUMERIC
330The command uses
331.Fa i .
332.It Dv ENGINE_CMD_FLAG_STRING
333The command uses
334.Fa p .
335.It Dv ENGINE_CMD_FLAG_NO_INPUT
336The command neither uses
337.Fa i
338nor
339.Fa p .
340.It Dv ENGINE_CMD_FLAG_INTERNAL
341This flag has no effect and is only provided for compatibility.
342.El
343.El
344.Pp
345The last element of
346.Fa defns
347does not specify a command, but must have a
348.Fa cmd_num
349of 0 and a
350.Fa cmd_name
351of
352.Dv NULL
353to indicate the end of the array.
354.Sh RETURN VALUES
355For
356.Fn ENGINE_ctrl ,
357positive return values indicate success and negative return values
358indicate failure.
359The meaning of a zero return value depends on the particular
360.Fa cmd
361and may indicate both success and failure, which is pathetic.
362.Pp
363Regardless of the
364.Fa cmd ,
365.Fn ENGINE_ctrl
366returns 0 if
367.Fa e
368is
369.Dv NULL
370or has a reference count of 0.
371This is quite unfortunate for commands like
372.Dv ENGINE_CTRL_GET_CMD_FLAGS
373where 0 may indicate success, so make sure
374.Fa e
375is valid before issuing a control command.
376.Pp
377For built-in commands except
378.Dv ENGINE_CTRL_HAS_CTRL_FUNCTION ,
379.Fn ENGINE_ctrl
380returns \-1 if
381.Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
382is set but no
383.Fa ctrl_f
384has been installed with
385.Fn ENGINE_set_ctrl_function .
386.Pp
387For commands that are not built in,
388.Fn ENGINE_ctrl
389returns 0 if no
390.Fa ctrl_f
391has been installed with
392.Fn ENGINE_set_ctrl_function .
393.Pp
394.Fn ENGINE_cmd_is_executable
395returns 1 if the user-defined
396.Fa cmd
397is executable and has at least one of the flags
398.Dv ENGINE_CMD_FLAG_NUMERIC ,
399.Dv ENGINE_CMD_FLAG_STRING ,
400and
401.Dv ENGINE_CMD_FLAG_NO_INPUT
402set, or 0 otherwise.
403.Pp
404.Fn ENGINE_ctrl_cmd
405and
406.Fn ENGINE_ctrl_cmd_string
407return 1 on success or 0 on error.
408.Pp
409.Fn ENGINE_set_ctrl_function
410and
411.Fn ENGINE_set_cmd_defns
412always return 1.
413.Pp
414.Fn ENGINE_get_ctrl_function
415returns a pointer to the function
416.Fa ctrl_f
417installed with
418.Fn ENGINE_set_ctrl_function ,
419or
420.Dv NULL
421if none has been installed.
422.Pp
423.Fn ENGINE_get_cmd_defns
424returns the array of command definitions installed in
425.Fa e
426or
427.Dv NULL
428if none is installed.
diff --git a/src/lib/libcrypto/man/ENGINE_get_default_RSA.3 b/src/lib/libcrypto/man/ENGINE_get_default_RSA.3
new file mode 100644
index 0000000000..876ccac775
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_get_default_RSA.3
@@ -0,0 +1,133 @@
1.\" $OpenBSD: ENGINE_get_default_RSA.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
20.Dt ENGINE_GET_DEFAULT_RSA 3
21.Os
22.Sh NAME
23.Nm ENGINE_get_default_RSA ,
24.Nm ENGINE_get_default_DSA ,
25.Nm ENGINE_get_default_ECDH ,
26.Nm ENGINE_get_default_ECDSA ,
27.Nm ENGINE_get_default_DH ,
28.Nm ENGINE_get_default_RAND ,
29.Nm ENGINE_get_cipher_engine ,
30.Nm ENGINE_get_digest_engine ,
31.Nm ENGINE_set_table_flags ,
32.Nm ENGINE_get_table_flags
33.Nd retrieve the default ENGINE for an algorithm
34.Sh SYNOPSIS
35.In openssl/engine.h
36.Ft ENGINE *
37.Fn ENGINE_get_default_RSA void
38.Ft ENGINE *
39.Fn ENGINE_get_default_DSA void
40.Ft ENGINE *
41.Fn ENGINE_get_default_ECDH void
42.Ft ENGINE *
43.Fn ENGINE_get_default_ECDSA void
44.Ft ENGINE *
45.Fn ENGINE_get_default_DH void
46.Ft ENGINE *
47.Fn ENGINE_get_default_RAND void
48.Ft ENGINE *
49.Fo ENGINE_get_cipher_engine
50.Fa "int nid"
51.Fc
52.Ft ENGINE *
53.Fo ENGINE_get_digest_engine
54.Fa "int nid"
55.Fc
56.Ft void
57.Fo ENGINE_set_table_flags
58.Fa "unsigned int flags"
59.Fc
60.Ft unsigned int
61.Fn ENGINE_get_table_flags void
62.Sh DESCRIPTION
63These functions retrieve the current default
64.Vt ENGINE
65implementing the respective algorithm.
66.Pp
67If a default engine was previously selected,
68.Xr ENGINE_init 3
69is called on it again and it is used.
70Otherwise, these functions inspect the engines registered
71with the functions documented in
72.Xr ENGINE_register_RSA 3
73in the order of the table for the respective algorithm.
74If an inspected engine is already successfully initialized,
75.Xr ENGINE_init 3
76is called on it again and it is used as the new default.
77Otherwise, unless the global flag
78.Dv ENGINE_TABLE_FLAG_NOINIT
79is set,
80.Xr ENGINE_init 3
81is tried on it.
82If it succeeds, that engine is used as the new default.
83If it fails or if
84.Dv ENGINE_TABLE_FLAG_NOINIT
85is set, inspection continues with the next engine.
86.Pp
87The global flag can be set by calling
88.Fn ENGINE_set_table_flags
89with an argument of
90.Dv ENGINE_TABLE_FLAG_NOINIT
91or cleared by calling it with an argument of 0.
92By default, the flag is not set.
93.Pp
94While all the other functions operate on exactly one algorithm,
95.Fn ENGINE_get_cipher_engine
96and
97.Fn ENGINE_get_digest_engine
98are special in so far as they can handle multiple algorithms,
99identified by the given
100.Fa nid .
101The default engine is remembered separately for each algorithm.
102.Pp
103Application programs rarely need to call these functions because
104they are called automatically when needed, in particular from
105.Xr RSA_new 3 ,
106.Xr DSA_new 3 ,
107.Fn ECDH_set_method ,
108.Fn ECDH_compute_key ,
109.Xr ECDSA_set_method 3 ,
110.Xr ECDSA_do_sign_ex 3 ,
111.Xr ECDSA_do_verify 3 ,
112.Xr DH_new 3 ,
113.Xr EVP_CipherInit_ex 3 ,
114and
115.Xr EVP_DigestInit_ex 3 .
116.Sh RETURN VALUES
117These functions return a functional reference to an
118.Vt ENGINE
119object or
120.Dv NULL
121on failure, in particular when no engine implementing the algorithm
122is available, when
123.Xr ENGINE_init 3
124fails for all implementations,
125or when insufficient memory is available.
126Even when these functions fail, the application may still be able
127to use the algorithm in question because the built-in implementation
128is used in that case, if one is available.
129.Pp
130.Fn ENGINE_get_table_flags
131returns
132.Dv ENGINE_TABLE_FLAG_NOINIT
133if the global flag is set or 0 otherwise.
diff --git a/src/lib/libcrypto/man/ENGINE_init.3 b/src/lib/libcrypto/man/ENGINE_init.3
new file mode 100644
index 0000000000..d94c6a8b66
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_init.3
@@ -0,0 +1,122 @@
1.\" $OpenBSD: ENGINE_init.3,v 1.1 2018/04/15 01:43:45 schwarze Exp $
2.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
3.\"
4.\" Permission to use, copy, modify, and distribute this software for any
5.\" purpose with or without fee is hereby granted, provided that the above
6.\" copyright notice and this permission notice appear in all copies.
7.\"
8.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15.\"
16.Dd $Mdocdate: April 15 2018 $
17.Dt ENGINE_INIT 3
18.Os
19.Sh NAME
20.Nm ENGINE_init ,
21.Nm ENGINE_finish ,
22.Nm ENGINE_set_init_function ,
23.Nm ENGINE_set_finish_function ,
24.Nm ENGINE_get_init_function ,
25.Nm ENGINE_get_finish_function
26.Nd initialize ENGINE objects
27.Sh SYNOPSIS
28.In openssl/engine.h
29.Ft int
30.Fo ENGINE_init
31.Fa "ENGINE *e"
32.Fc
33.Ft int
34.Fo ENGINE_finish
35.Fa "ENGINE *e"
36.Fc
37.Ft typedef int
38.Fo (*ENGINE_GEN_INT_FUNC_PTR)
39.Fa "ENGINE *e"
40.Fc
41.Ft int
42.Fo ENGINE_set_init_function
43.Fa "ENGINE *e"
44.Fa "ENGINE_GEN_INT_FUNC_PTR init_f"
45.Fc
46.Ft int
47.Fo ENGINE_set_finish_function
48.Fa "ENGINE *e"
49.Fa "ENGINE_GEN_INT_FUNC_PTR finish_f"
50.Fc
51.Ft ENGINE_GEN_INT_FUNC_PTR
52.Fo ENGINE_get_init_function
53.Fa "const ENGINE *e"
54.Fc
55.Ft ENGINE_GEN_INT_FUNC_PTR
56.Fo ENGINE_get_finish_function
57.Fa "const ENGINE *e"
58.Fc
59.Sh DESCRIPTION
60.Fn ENGINE_init
61initializes
62.Fa e
63by calling the
64.Fa init_f
65previously installed with
66.Fn ENGINE_set_init_function ,
67if any.
68In case of success, it also increments both the structural
69and the functional reference count by 1.
70If no
71.Fa init_f
72was installed,
73.Fn ENGINE_init
74always succeeds.
75Calling
76.Fn ENGINE_init
77again after it already succeeded always succeeds, but has no effect
78except that it increments both the structural and the functional
79reference count by 1.
80.Pp
81.Fn ENGINE_finish
82decrements the functional reference count by 1.
83When it reaches 0, it calls the
84.Fa finish_f
85previously installed with
86.Fn ENGINE_set_finish_function ,
87if any.
88If no
89.Fa finish_f
90was installed,
91.Fn ENGINE_finish
92always succeeds.
93Unless
94.Fa finish_f
95fails,
96.Fn ENGINE_finish
97also calls
98.Xr ENGINE_free 3 .
99.Pp
100.Fn ENGINE_init
101is internally called by the functions documented in the
102.Xr ENGINE_get_default_RSA 3
103manual page.
104.Sh RETURN VALUES
105.Fn ENGINE_init
106and
107.Fn ENGINE_finish
108return 1 on success or 0 on error.
109.Pp
110.Fn ENGINE_set_init_function
111and
112.Fn ENGINE_set_finish_function
113always return 1.
114.Pp
115.Fn ENGINE_get_init_function
116and
117.Fn ENGINE_get_finish_function
118return a function pointer to the respective callback, or
119.Dv NULL
120if none is installed.
121.Sh SEE ALSO
122.Xr ENGINE_get_default_RSA 3
diff --git a/src/lib/libcrypto/man/ENGINE_register_RSA.3 b/src/lib/libcrypto/man/ENGINE_register_RSA.3
new file mode 100644
index 0000000000..95735e814d
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_register_RSA.3
@@ -0,0 +1,115 @@
1.\" $OpenBSD: ENGINE_register_RSA.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
20.Dt ENGINE_REGISTER_RSA 3
21.Os
22.Sh NAME
23.Nm ENGINE_register_RSA ,
24.Nm ENGINE_register_DSA ,
25.Nm ENGINE_register_ECDH ,
26.Nm ENGINE_register_ECDSA ,
27.Nm ENGINE_register_DH ,
28.Nm ENGINE_register_RAND ,
29.Nm ENGINE_register_STORE ,
30.Nm ENGINE_register_ciphers ,
31.Nm ENGINE_register_digests ,
32.Nm ENGINE_register_complete
33.Nd register an ENGINE as implementing an algorithm
34.Sh SYNOPSIS
35.In openssl/engine.h
36.Ft int
37.Fo ENGINE_register_RSA
38.Fa "ENGINE *e"
39.Fc
40.Ft int
41.Fo ENGINE_register_DSA
42.Fa "ENGINE *e"
43.Fc
44.Ft int
45.Fo ENGINE_register_ECDH
46.Fa "ENGINE *e"
47.Fc
48.Ft int
49.Fo ENGINE_register_ECDSA
50.Fa "ENGINE *e"
51.Fc
52.Ft int
53.Fo ENGINE_register_DH
54.Fa "ENGINE *e"
55.Fc
56.Ft int
57.Fo ENGINE_register_RAND
58.Fa "ENGINE *e"
59.Fc
60.Ft int
61.Fo ENGINE_register_STORE
62.Fa "ENGINE *e"
63.Fc
64.Ft int
65.Fo ENGINE_register_ciphers
66.Fa "ENGINE *e"
67.Fc
68.Ft int
69.Fo ENGINE_register_digests
70.Fa "ENGINE *e"
71.Fc
72.Ft int
73.Fo ENGINE_register_complete
74.Fa "ENGINE *e"
75.Fc
76.Sh DESCRIPTION
77In addition to the global table described in
78.Xr ENGINE_add 3 ,
79the crypto library maintains several tables containing references to
80.Vt ENGINE
81objects implementing one specific cryptographic algorithm.
82.Pp
83The functions listed in the present manual page append
84.Fa e
85to the end of the table for the respective algorithm.
86.Pp
87If
88.Fa e
89does not contain a method for the requested algorithm,
90these functions succeed without having any effect.
91.Pp
92If
93.Fa e
94is already registered for the given algorithm,
95they move it to the end of the respective table.
96.Pp
97.Fn ENGINE_register_ciphers
98and
99.Fn ENGINE_register_digests
100are special in so far as an engine may implement
101more than one cipher or more than one digest.
102In that case,
103.Fa e
104is registered for all the ciphers or digests it implements.
105.Pp
106.Fn ENGINE_register_complete
107registers
108.Fa e
109for all algorithms it implements by calling all the other functions.
110.Sh RETURN VALUES
111These functions return 1 on success or 0 on error.
112They only fail if insufficient memory is available.
113.Sh BUGS
114.Fn ENGINE_register_complete
115ignores all errors, even memory allocation failure, and always returns 1.
diff --git a/src/lib/libcrypto/man/ENGINE_register_all_RSA.3 b/src/lib/libcrypto/man/ENGINE_register_all_RSA.3
new file mode 100644
index 0000000000..f92a12b2f9
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_register_all_RSA.3
@@ -0,0 +1,73 @@
1.\" $OpenBSD: ENGINE_register_all_RSA.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
20.Dt ENGINE_REGISTER_ALL_RSA 3
21.Os
22.Sh NAME
23.Nm ENGINE_register_all_RSA ,
24.Nm ENGINE_register_all_DSA ,
25.Nm ENGINE_register_all_ECDH ,
26.Nm ENGINE_register_all_ECDSA ,
27.Nm ENGINE_register_all_DH ,
28.Nm ENGINE_register_all_RAND ,
29.Nm ENGINE_register_all_STORE ,
30.Nm ENGINE_register_all_ciphers ,
31.Nm ENGINE_register_all_digests ,
32.Nm ENGINE_register_all_complete
33.Nd register all engines as implementing an algorithm
34.Sh SYNOPSIS
35.In openssl/engine.h
36.Ft void
37.Fn ENGINE_register_all_RSA void
38.Ft void
39.Fn ENGINE_register_all_DSA void
40.Ft void
41.Fn ENGINE_register_all_ECDH void
42.Ft void
43.Fn ENGINE_register_all_ECDSA void
44.Ft void
45.Fn ENGINE_register_all_DH void
46.Ft void
47.Fn ENGINE_register_all_RAND void
48.Ft void
49.Fn ENGINE_register_all_STORE void
50.Ft void
51.Fn ENGINE_register_all_ciphers void
52.Ft void
53.Fn ENGINE_register_all_digests void
54.Ft int
55.Fn ENGINE_register_all_complete void
56.Sh DESCRIPTION
57These functions loop over all the
58.Vt ENGINE
59objects contained in the global table described in the
60.Xr ENGINE_add 3
61manual page.
62They register each object for the respective algorithm
63by calling the corresponding function described in
64.Xr ENGINE_register_RSA 3 .
65.Pp
66.Fn ENGINE_register_all_complete
67calls
68.Fn ENGINE_register_complete
69in this way, except that it skips those
70.Vt ENGINE
71objects that have the
72.Dv ENGINE_FLAGS_NO_REGISTER_ALL
73flag set.
diff --git a/src/lib/libcrypto/man/ENGINE_set_default.3 b/src/lib/libcrypto/man/ENGINE_set_default.3
new file mode 100644
index 0000000000..653582b39d
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_set_default.3
@@ -0,0 +1,156 @@
1.\" $OpenBSD: ENGINE_set_default.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
20.Dt ENGINE 3
21.Os
22.Sh NAME
23.Nm ENGINE_set_default ,
24.Nm ENGINE_set_default_string ,
25.Nm ENGINE_set_default_RSA ,
26.Nm ENGINE_set_default_DSA ,
27.Nm ENGINE_set_default_ECDH ,
28.Nm ENGINE_set_default_ECDSA ,
29.Nm ENGINE_set_default_DH ,
30.Nm ENGINE_set_default_RAND ,
31.Nm ENGINE_set_default_ciphers ,
32.Nm ENGINE_set_default_digests
33.Nd register an ENGINE as the default for an algorithm
34.Sh SYNOPSIS
35.Ft int
36.Fo ENGINE_set_default_RSA
37.Fa "ENGINE *e"
38.Fc
39.Ft int
40.Fo ENGINE_set_default_DSA
41.Fa "ENGINE *e"
42.Fc
43.Ft int
44.Fo ENGINE_set_default_ECDH
45.Fa "ENGINE *e"
46.Fc
47.Ft int
48.Fo ENGINE_set_default_ECDSA
49.Fa "ENGINE *e"
50.Fc
51.Ft int
52.Fo ENGINE_set_default_DH
53.Fa "ENGINE *e"
54.Fc
55.Ft int
56.Fo ENGINE_set_default_RAND
57.Fa "ENGINE *e"
58.Fc
59.Ft int
60.Fo ENGINE_set_default_ciphers
61.Fa "ENGINE *e"
62.Fc
63.Ft int
64.Fo ENGINE_set_default_digests
65.Fa "ENGINE *e"
66.Fc
67.Ft int
68.Fo ENGINE_set_default
69.Fa "ENGINE *e"
70.Fa "unsigned int flags"
71.Fc
72.Ft int
73.Fo ENGINE_set_default_string
74.Fa "ENGINE *e"
75.Fa "const char *list"
76.Fc
77.Sh DESCRIPTION
78These functions register
79.Fa e
80as implementing the respective algorithm
81like the functions described in the
82.Xr ENGINE_register_RSA 3
83manual page do it.
84In addition, they call
85.Xr ENGINE_init 3
86on
87.Fa e
88and select
89.Fa e
90as the default implementation of the respective algorithm to be
91returned by the functions described in
92.Xr ENGINE_get_default_RSA 3
93in the future.
94If another engine was previously selected
95as the default implementation of the respective algorithm,
96.Xr ENGINE_finish 3
97is called on that previous engine.
98.Pp
99If
100.Fa e
101implements more than one cipher or digest,
102.Fn ENGINE_set_default_ciphers
103and
104.Fn ENGINE_set_default_digests
105register and select it for all these ciphers and digests, respectively.
106.Pp
107.Fn ENGINE_set_default
108registers
109.Fa e
110as the default implementation of all algorithms specified by the
111.Fa flags
112by calling the appropriate ones among the other functions.
113Algorithms can be selected by combining any number of the
114following constants with bitwise OR:
115.Dv ENGINE_METHOD_ALL ,
116.Dv ENGINE_METHOD_RSA ,
117.Dv ENGINE_METHOD_DSA ,
118.Dv ENGINE_METHOD_ECDH ,
119.Dv ENGINE_METHOD_ECDSA ,
120.Dv ENGINE_METHOD_DH ,
121.Dv ENGINE_METHOD_RAND ,
122.Dv ENGINE_METHOD_CIPHERS ,
123.Dv ENGINE_METHOD_DIGESTS ,
124.Dv ENGINE_METHOD_PKEY_METHS ,
125and
126.Dv ENGINE_METHOD_PKEY_ASN1_METHS .
127.Pp
128.Fn ENGINE_set_default_string
129is similar except that it selects the algorithms according to the string
130.Fa def_list ,
131which contains an arbitrary number of comma-separated keywords from
132the following list: ALL, RSA, DSA, ECDH, ECDSA, DH, RAND, CIPHERS,
133DIGESTS, PKEY_CRYPTO, PKEY_ASN1, and PKEY.
134PKEY_CRYPTO corresponds to
135.Dv ENGINE_METHOD_PKEY_METHS ,
136PKEY_ASN1 to
137.Dv ENGINE_METHOD_PKEY_ASN1_METHS ,
138and PKEY selects both.
139.Sh RETURN VALUES
140These functions return 1 on success or 0 on error.
141They fail if
142.Xr ENGINE_init 3
143fails or if insufficient memory is available.
144.Sh CAVEATS
145Failure of
146.Xr ENGINE_finish 3
147is ignored.
148.Sh BUGS
149Even when
150.Fn ENGINE_set_default
151or
152.Fn ENGINE_set_default_string
153fail, they typically still register
154.Fa e
155for some algorithms, but usually not for all it could be registered
156for by calling the individual functions.
diff --git a/src/lib/libcrypto/man/ENGINE_unregister_RSA.3 b/src/lib/libcrypto/man/ENGINE_unregister_RSA.3
new file mode 100644
index 0000000000..c596554e86
--- /dev/null
+++ b/src/lib/libcrypto/man/ENGINE_unregister_RSA.3
@@ -0,0 +1,96 @@
1.\" $OpenBSD: ENGINE_unregister_RSA.3,v 1.1 2018/04/15 01:43:45 schwarze 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: April 15 2018 $
20.Dt ENGINE_UNREGISTER_RSA 3
21.Os
22.Sh NAME
23.Nm ENGINE_unregister_RSA ,
24.Nm ENGINE_unregister_DSA ,
25.Nm ENGINE_unregister_ECDH ,
26.Nm ENGINE_unregister_ECDSA ,
27.Nm ENGINE_unregister_DH ,
28.Nm ENGINE_unregister_RAND ,
29.Nm ENGINE_unregister_STORE ,
30.Nm ENGINE_unregister_ciphers ,
31.Nm ENGINE_unregister_digests
32.Nd revoke the registration of an ENGINE object
33.Sh SYNOPSIS
34.In openssl/engine.h
35.Ft void
36.Fo ENGINE_unregister_RSA
37.Fa "ENGINE *e"
38.Fc
39.Ft void
40.Fo ENGINE_unregister_DSA
41.Fa "ENGINE *e"
42.Fc
43.Ft void
44.Fo ENGINE_unregister_ECDH
45.Fa "ENGINE *e"
46.Fc
47.Ft void
48.Fo ENGINE_unregister_ECDSA
49.Fa "ENGINE *e"
50.Fc
51.Ft void
52.Fo ENGINE_unregister_DH
53.Fa "ENGINE *e"
54.Fc
55.Ft void
56.Fo ENGINE_unregister_RAND
57.Fa "ENGINE *e"
58.Fc
59.Ft void
60.Fo ENGINE_unregister_STORE
61.Fa "ENGINE *e"
62.Fc
63.Ft void
64.Fo ENGINE_unregister_ciphers
65.Fa "ENGINE *e"
66.Fc
67.Ft void
68.Fo ENGINE_unregister_digests
69.Fa "ENGINE *e"
70.Fc
71.Sh DESCRIPTION
72These functions remove
73.Fa e
74from the list of
75.Vt ENGINE
76objects that were previously registered for the respective algorithm
77with the functions described in
78.Xr ENGINE_register_RSA 3 .
79.Pp
80If
81.Fa e
82is currently used as the default engine for the algorithm
83as described in the
84.Fn ENGINE_set_default 3
85and
86.Fn ENGINE_get_default_RSA 3
87manual pages,
88.Xr ENGINE_finish
89is also called.
90.Pp
91.Fn ENGINE_unregister_ciphers
92and
93.Fn ENGINE_unregister_digests
94unregister
95.Fa e
96for all ciphers or digests, respectively.
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 0405a06663..a83ae5d3ed 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.138 2018/03/18 13:06:36 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.139 2018/04/15 01:43:45 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -97,6 +97,14 @@ MAN= \
97 EC_KEY_new.3 \ 97 EC_KEY_new.3 \
98 EC_POINT_add.3 \ 98 EC_POINT_add.3 \
99 EC_POINT_new.3 \ 99 EC_POINT_new.3 \
100 ENGINE_add.3 \
101 ENGINE_ctrl.3 \
102 ENGINE_get_default_RSA.3 \
103 ENGINE_init.3 \
104 ENGINE_register_RSA.3 \
105 ENGINE_register_all_RSA.3 \
106 ENGINE_set_default.3 \
107 ENGINE_unregister_RSA.3 \
100 ERR.3 \ 108 ERR.3 \
101 ERR_GET_LIB.3 \ 109 ERR_GET_LIB.3 \
102 ERR_asprintf_error_data.3 \ 110 ERR_asprintf_error_data.3 \
diff --git a/src/lib/libcrypto/man/engine.3 b/src/lib/libcrypto/man/engine.3
index d93f06f024..fac4fa13e1 100644
--- a/src/lib/libcrypto/man/engine.3
+++ b/src/lib/libcrypto/man/engine.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: engine.3,v 1.14 2018/04/14 11:38:32 schwarze Exp $ 1.\" $OpenBSD: engine.3,v 1.15 2018/04/15 01:43:45 schwarze Exp $
2.\" full merge up to: OpenSSL crypto/engine e6390aca Jul 21 10:06:03 2015 -0400 2.\" full merge up to: OpenSSL crypto/engine e6390aca Jul 21 10:06:03 2015 -0400
3.\" selective merge up to: man3/ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 3.\" selective merge up to: man3/ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800
4.\" 4.\"
@@ -51,77 +51,14 @@
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE. 52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\" 53.\"
54.Dd $Mdocdate: April 14 2018 $ 54.Dd $Mdocdate: April 15 2018 $
55.Dt ENGINE 3 55.Dt ENGINE 3
56.Os 56.Os
57.Sh NAME 57.Sh NAME
58.Nm ENGINE_get_first ,
59.Nm ENGINE_get_last ,
60.Nm ENGINE_get_next ,
61.Nm ENGINE_get_prev ,
62.Nm ENGINE_add ,
63.Nm ENGINE_remove ,
64.Nm ENGINE_by_id ,
65.Nm ENGINE_init ,
66.Nm ENGINE_finish ,
67.Nm ENGINE_load_openssl , 58.Nm ENGINE_load_openssl ,
68.Nm ENGINE_load_dynamic , 59.Nm ENGINE_load_dynamic ,
69.Nm ENGINE_load_cryptodev ,
70.Nm ENGINE_load_builtin_engines , 60.Nm ENGINE_load_builtin_engines ,
71.Nm ENGINE_cleanup , 61.Nm ENGINE_cleanup ,
72.Nm ENGINE_get_default_RSA ,
73.Nm ENGINE_get_default_DSA ,
74.Nm ENGINE_get_default_ECDH ,
75.Nm ENGINE_get_default_ECDSA ,
76.Nm ENGINE_get_default_DH ,
77.Nm ENGINE_get_default_RAND ,
78.Nm ENGINE_get_cipher_engine ,
79.Nm ENGINE_get_digest_engine ,
80.Nm ENGINE_set_default_RSA ,
81.Nm ENGINE_set_default_DSA ,
82.Nm ENGINE_set_default_ECDH ,
83.Nm ENGINE_set_default_ECDSA ,
84.Nm ENGINE_set_default_DH ,
85.Nm ENGINE_set_default_RAND ,
86.Nm ENGINE_set_default_ciphers ,
87.Nm ENGINE_set_default_digests ,
88.Nm ENGINE_set_default_string ,
89.Nm ENGINE_set_default ,
90.Nm ENGINE_get_table_flags ,
91.Nm ENGINE_set_table_flags ,
92.Nm ENGINE_register_RSA ,
93.Nm ENGINE_unregister_RSA ,
94.Nm ENGINE_register_all_RSA ,
95.Nm ENGINE_register_DSA ,
96.Nm ENGINE_unregister_DSA ,
97.Nm ENGINE_register_all_DSA ,
98.Nm ENGINE_register_ECDH ,
99.Nm ENGINE_unregister_ECDH ,
100.Nm ENGINE_register_all_ECDH ,
101.Nm ENGINE_register_ECDSA ,
102.Nm ENGINE_unregister_ECDSA ,
103.Nm ENGINE_register_all_ECDSA ,
104.Nm ENGINE_register_DH ,
105.Nm ENGINE_unregister_DH ,
106.Nm ENGINE_register_all_DH ,
107.Nm ENGINE_register_RAND ,
108.Nm ENGINE_unregister_RAND ,
109.Nm ENGINE_register_all_RAND ,
110.Nm ENGINE_register_STORE ,
111.Nm ENGINE_unregister_STORE ,
112.Nm ENGINE_register_all_STORE ,
113.Nm ENGINE_register_ciphers ,
114.Nm ENGINE_unregister_ciphers ,
115.Nm ENGINE_register_all_ciphers ,
116.Nm ENGINE_register_digests ,
117.Nm ENGINE_unregister_digests ,
118.Nm ENGINE_register_all_digests ,
119.Nm ENGINE_register_complete ,
120.Nm ENGINE_register_all_complete ,
121.Nm ENGINE_ctrl ,
122.Nm ENGINE_cmd_is_executable ,
123.Nm ENGINE_ctrl_cmd ,
124.Nm ENGINE_ctrl_cmd_string ,
125.Nm ENGINE_new , 62.Nm ENGINE_new ,
126.Nm ENGINE_free , 63.Nm ENGINE_free ,
127.Nm ENGINE_up_ref , 64.Nm ENGINE_up_ref ,
@@ -135,15 +72,11 @@
135.Nm ENGINE_set_RAND , 72.Nm ENGINE_set_RAND ,
136.Nm ENGINE_set_STORE , 73.Nm ENGINE_set_STORE ,
137.Nm ENGINE_set_destroy_function , 74.Nm ENGINE_set_destroy_function ,
138.Nm ENGINE_set_init_function ,
139.Nm ENGINE_set_finish_function ,
140.Nm ENGINE_set_ctrl_function ,
141.Nm ENGINE_set_load_privkey_function , 75.Nm ENGINE_set_load_privkey_function ,
142.Nm ENGINE_set_load_pubkey_function , 76.Nm ENGINE_set_load_pubkey_function ,
143.Nm ENGINE_set_ciphers , 77.Nm ENGINE_set_ciphers ,
144.Nm ENGINE_set_digests , 78.Nm ENGINE_set_digests ,
145.Nm ENGINE_set_flags , 79.Nm ENGINE_set_flags ,
146.Nm ENGINE_set_cmd_defns ,
147.Nm ENGINE_get_id , 80.Nm ENGINE_get_id ,
148.Nm ENGINE_get_name , 81.Nm ENGINE_get_name ,
149.Nm ENGINE_get_RSA , 82.Nm ENGINE_get_RSA ,
@@ -154,9 +87,6 @@
154.Nm ENGINE_get_RAND , 87.Nm ENGINE_get_RAND ,
155.Nm ENGINE_get_STORE , 88.Nm ENGINE_get_STORE ,
156.Nm ENGINE_get_destroy_function , 89.Nm ENGINE_get_destroy_function ,
157.Nm ENGINE_get_init_function ,
158.Nm ENGINE_get_finish_function ,
159.Nm ENGINE_get_ctrl_function ,
160.Nm ENGINE_get_load_privkey_function , 90.Nm ENGINE_get_load_privkey_function ,
161.Nm ENGINE_get_load_pubkey_function , 91.Nm ENGINE_get_load_pubkey_function ,
162.Nm ENGINE_get_ciphers , 92.Nm ENGINE_get_ciphers ,
@@ -164,248 +94,20 @@
164.Nm ENGINE_get_cipher , 94.Nm ENGINE_get_cipher ,
165.Nm ENGINE_get_digest , 95.Nm ENGINE_get_digest ,
166.Nm ENGINE_get_flags , 96.Nm ENGINE_get_flags ,
167.Nm ENGINE_get_cmd_defns ,
168.Nm ENGINE_load_private_key , 97.Nm ENGINE_load_private_key ,
169.Nm ENGINE_load_public_key 98.Nm ENGINE_load_public_key
170.Nd ENGINE cryptographic module support 99.Nd ENGINE cryptographic module support
171.Sh SYNOPSIS 100.Sh SYNOPSIS
172.In openssl/engine.h 101.In openssl/engine.h
173.Ft ENGINE *
174.Fn ENGINE_get_first void
175.Ft ENGINE *
176.Fn ENGINE_get_last void
177.Ft ENGINE *
178.Fo ENGINE_get_next
179.Fa "ENGINE *e"
180.Fc
181.Ft ENGINE *
182.Fo ENGINE_get_prev
183.Fa "ENGINE *e"
184.Fc
185.Ft int
186.Fo ENGINE_add
187.Fa "ENGINE *e"
188.Fc
189.Ft int
190.Fo ENGINE_remove
191.Fa "ENGINE *e"
192.Fc
193.Ft ENGINE *
194.Fo ENGINE_by_id
195.Fa "const char *id"
196.Fc
197.Ft int
198.Fo ENGINE_init
199.Fa "ENGINE *e"
200.Fc
201.Ft int
202.Fo ENGINE_finish
203.Fa "ENGINE *e"
204.Fc
205.Ft void 102.Ft void
206.Fn ENGINE_load_openssl void 103.Fn ENGINE_load_openssl void
207.Ft void 104.Ft void
208.Fn ENGINE_load_dynamic void 105.Fn ENGINE_load_dynamic void
209.Ft void 106.Ft void
210.Fn ENGINE_load_cryptodev void
211.Ft void
212.Fn ENGINE_load_builtin_engines void 107.Fn ENGINE_load_builtin_engines void
213.Ft void 108.Ft void
214.Fn ENGINE_cleanup void 109.Fn ENGINE_cleanup void
215.Ft ENGINE * 110.Ft ENGINE *
216.Fn ENGINE_get_default_RSA void
217.Ft ENGINE *
218.Fn ENGINE_get_default_DSA void
219.Ft ENGINE *
220.Fn ENGINE_get_default_ECDH void
221.Ft ENGINE *
222.Fn ENGINE_get_default_ECDSA void
223.Ft ENGINE *
224.Fn ENGINE_get_default_DH void
225.Ft ENGINE *
226.Fn ENGINE_get_default_RAND void
227.Ft ENGINE *
228.Fo ENGINE_get_cipher_engine
229.Fa "int nid"
230.Fc
231.Ft ENGINE *
232.Fo ENGINE_get_digest_engine
233.Fa "int nid"
234.Fc
235.Ft int
236.Fo ENGINE_set_default_RSA
237.Fa "ENGINE *e"
238.Fc
239.Ft int
240.Fo ENGINE_set_default_DSA
241.Fa "ENGINE *e"
242.Fc
243.Ft int
244.Fo ENGINE_set_default_ECDH
245.Fa "ENGINE *e"
246.Fc
247.Ft int
248.Fo ENGINE_set_default_ECDSA
249.Fa "ENGINE *e"
250.Fc
251.Ft int
252.Fo ENGINE_set_default_DH
253.Fa "ENGINE *e"
254.Fc
255.Ft int
256.Fo ENGINE_set_default_RAND
257.Fa "ENGINE *e"
258.Fc
259.Ft int
260.Fo ENGINE_set_default_ciphers
261.Fa "ENGINE *e"
262.Fc
263.Ft int
264.Fo ENGINE_set_default_digests
265.Fa "ENGINE *e"
266.Fc
267.Ft int
268.Fo ENGINE_set_default_string
269.Fa "ENGINE *e"
270.Fa "const char *list"
271.Fc
272.Ft int
273.Fo ENGINE_set_default
274.Fa "ENGINE *e"
275.Fa "unsigned int flags"
276.Fc
277.Ft unsigned int
278.Fn ENGINE_get_table_flags void
279.Ft void
280.Fo ENGINE_set_table_flags
281.Fa "unsigned int flags"
282.Fc
283.Ft int
284.Fo ENGINE_register_RSA
285.Fa "ENGINE *e"
286.Fc
287.Ft void
288.Fo ENGINE_unregister_RSA
289.Fa "ENGINE *e"
290.Fc
291.Ft void
292.Fn ENGINE_register_all_RSA void
293.Ft int
294.Fo ENGINE_register_DSA
295.Fa "ENGINE *e"
296.Fc
297.Ft void
298.Fo ENGINE_unregister_DSA
299.Fa "ENGINE *e"
300.Fc
301.Ft void
302.Fn ENGINE_register_all_DSA void
303.Ft int
304.Fo ENGINE_register_ECDH
305.Fa "ENGINE *e"
306.Fc
307.Ft void
308.Fo ENGINE_unregister_ECDH
309.Fa "ENGINE *e"
310.Fc
311.Ft void
312.Fn ENGINE_register_all_ECDH void
313.Ft int
314.Fo ENGINE_register_ECDSA
315.Fa "ENGINE *e"
316.Fc
317.Ft void
318.Fo ENGINE_unregister_ECDSA
319.Fa "ENGINE *e"
320.Fc
321.Ft void
322.Fn ENGINE_register_all_ECDSA void
323.Ft int
324.Fo ENGINE_register_DH
325.Fa "ENGINE *e"
326.Fc
327.Ft void
328.Fo ENGINE_unregister_DH
329.Fa "ENGINE *e"
330.Fc
331.Ft void
332.Fn ENGINE_register_all_DH void
333.Ft int
334.Fo ENGINE_register_RAND
335.Fa "ENGINE *e"
336.Fc
337.Ft void
338.Fo ENGINE_unregister_RAND
339.Fa "ENGINE *e"
340.Fc
341.Ft void
342.Fn ENGINE_register_all_RAND void
343.Ft int
344.Fo ENGINE_register_STORE
345.Fa "ENGINE *e"
346.Fc
347.Ft void
348.Fo ENGINE_unregister_STORE
349.Fa "ENGINE *e"
350.Fc
351.Ft void
352.Fn ENGINE_register_all_STORE void
353.Ft int
354.Fo ENGINE_register_ciphers
355.Fa "ENGINE *e"
356.Fc
357.Ft void
358.Fo ENGINE_unregister_ciphers
359.Fa "ENGINE *e"
360.Fc
361.Ft void
362.Fn ENGINE_register_all_ciphers void
363.Ft int
364.Fo ENGINE_register_digests
365.Fa "ENGINE *e"
366.Fc
367.Ft void
368.Fo ENGINE_unregister_digests
369.Fa "ENGINE *e"
370.Fc
371.Ft void
372.Fn ENGINE_register_all_digests void
373.Ft int
374.Fo ENGINE_register_complete
375.Fa "ENGINE *e"
376.Fc
377.Ft int
378.Fn ENGINE_register_all_complete void
379.Ft int
380.Fo ENGINE_ctrl
381.Fa "ENGINE *e"
382.Fa "int cmd"
383.Fa "long i"
384.Fa "void *p"
385.Fa "void (*f)(void)"
386.Fc
387.Ft int
388.Fo ENGINE_cmd_is_executable
389.Fa "ENGINE *e"
390.Fa "int cmd"
391.Fc
392.Ft int
393.Fo ENGINE_ctrl_cmd
394.Fa "ENGINE *e"
395.Fa "const char *cmd_name"
396.Fa "long i"
397.Fa "void *p"
398.Fa "void (*f)(void)"
399.Fa "int cmd_optional"
400.Fc
401.Ft int
402.Fo ENGINE_ctrl_cmd_string
403.Fa "ENGINE *e"
404.Fa "const char *cmd_name"
405.Fa "const char *arg"
406.Fa "int cmd_optional"
407.Fc
408.Ft ENGINE *
409.Fn ENGINE_new void 111.Fn ENGINE_new void
410.Ft int 112.Ft int
411.Fo ENGINE_free 113.Fo ENGINE_free
@@ -466,21 +168,6 @@
466.Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f" 168.Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f"
467.Fc 169.Fc
468.Ft int 170.Ft int
469.Fo ENGINE_set_init_function
470.Fa "ENGINE *e"
471.Fa "ENGINE_GEN_INT_FUNC_PTR init_f"
472.Fc
473.Ft int
474.Fo ENGINE_set_finish_function
475.Fa "ENGINE *e"
476.Fa "ENGINE_GEN_INT_FUNC_PTR finish_f"
477.Fc
478.Ft int
479.Fo ENGINE_set_ctrl_function
480.Fa "ENGINE *e"
481.Fa "ENGINE_CTRL_FUNC_PTR ctrl_f"
482.Fc
483.Ft int
484.Fo ENGINE_set_load_privkey_function 171.Fo ENGINE_set_load_privkey_function
485.Fa "ENGINE *e" 172.Fa "ENGINE *e"
486.Fa "ENGINE_LOAD_KEY_PTR loadpriv_f" 173.Fa "ENGINE_LOAD_KEY_PTR loadpriv_f"
@@ -505,11 +192,6 @@
505.Fa "ENGINE *e" 192.Fa "ENGINE *e"
506.Fa "int flags" 193.Fa "int flags"
507.Fc 194.Fc
508.Ft int
509.Fo ENGINE_set_cmd_defns
510.Fa "ENGINE *e"
511.Fa "const ENGINE_CMD_DEFN *defns"
512.Fc
513.Ft const char * 195.Ft const char *
514.Fo ENGINE_get_id 196.Fo ENGINE_get_id
515.Fa "const ENGINE *e" 197.Fa "const ENGINE *e"
@@ -550,18 +232,6 @@
550.Fo ENGINE_get_destroy_function 232.Fo ENGINE_get_destroy_function
551.Fa "const ENGINE *e" 233.Fa "const ENGINE *e"
552.Fc 234.Fc
553.Ft ENGINE_GEN_INT_FUNC_PTR
554.Fo ENGINE_get_init_function
555.Fa "const ENGINE *e"
556.Fc
557.Ft ENGINE_GEN_INT_FUNC_PTR
558.Fo ENGINE_get_finish_function
559.Fa "const ENGINE *e"
560.Fc
561.Ft ENGINE_CTRL_FUNC_PTR
562.Fo ENGINE_get_ctrl_function
563.Fa "const ENGINE *e"
564.Fc
565.Ft ENGINE_LOAD_KEY_PTR 235.Ft ENGINE_LOAD_KEY_PTR
566.Fo ENGINE_get_load_privkey_function 236.Fo ENGINE_get_load_privkey_function
567.Fa "const ENGINE *e" 237.Fa "const ENGINE *e"
@@ -592,10 +262,6 @@
592.Fo ENGINE_get_flags 262.Fo ENGINE_get_flags
593.Fa "const ENGINE *e" 263.Fa "const ENGINE *e"
594.Fc 264.Fc
595.Ft const ENGINE_CMD_DEFN *
596.Fo ENGINE_get_cmd_defns
597.Fa "const ENGINE *e"
598.Fc
599.Ft EVP_PKEY * 265.Ft EVP_PKEY *
600.Fo ENGINE_load_private_key 266.Fo ENGINE_load_private_key
601.Fa "ENGINE *e" 267.Fa "ENGINE *e"
@@ -712,20 +378,23 @@ and its functional reference count to 0.
712Many functions increment the structural reference count by 1 378Many functions increment the structural reference count by 1
713when successful. 379when successful.
714Some of them, including 380Some of them, including
715.Fn ENGINE_by_id , 381.Xr ENGINE_by_id 3 ,
716.Fn ENGINE_get_first , 382.Xr ENGINE_get_first 3 ,
717.Fn ENGINE_get_last , 383.Xr ENGINE_get_last 3 ,
718.Fn ENGINE_get_next , 384.Xr ENGINE_get_next 3 ,
719and 385and
720.Fn ENGINE_get_prev , 386.Xr ENGINE_get_prev 3 ,
721do so because they return a structural reference to the user. 387do so because they return a structural reference to the user.
722Other functions, including 388Other functions, including
723.Fn ENGINE_add , 389.Xr ENGINE_add 3 ,
724.Fn ENGINE_init , 390.Xr ENGINE_init 3 ,
725.Fn ENGINE_get_default_* , 391.Xr ENGINE_get_cipher_engine 3 ,
726.Fn ENGINE_get_*_engine , 392.Xr ENGINE_get_digest_engine 3 ,
393and the
394.Xr ENGINE_get_default_RSA 3
727and 395and
728.Fn ENGINE_set_default_* , 396.Xr ENGINE_set_default 3
397families of functions
729do so because they store a structural refence internally. 398do so because they store a structural refence internally.
730.Fn ENGINE_up_ref 399.Fn ENGINE_up_ref
731explicitly increment the structural reference count by 1. 400explicitly increment the structural reference count by 1.
@@ -747,144 +416,17 @@ pointer, no action occurs.
747Many functions internally call the equivalent of 416Many functions internally call the equivalent of
748.Fn ENGINE_free . 417.Fn ENGINE_free .
749Some of them, including 418Some of them, including
750.Fn ENGINE_get_next 419.Xr ENGINE_get_next 3
751and 420and
752.Fn ENGINE_get_prev , 421.Xr ENGINE_get_prev 3 ,
753thus invalidate the structural reference passed in by the user. 422thus invalidate the structural reference passed in by the user.
754Other functions, including 423Other functions, including
755.Fn ENGINE_finish , 424.Xr ENGINE_finish 3 ,
756.Fn ENGINE_remove , 425.Xr ENGINE_remove 3 ,
757.Fn ENGINE_get_default_* , 426and the
758.Fn ENGINE_get_*_engine , 427.Xr ENGINE_set_default 3
759and 428family of functions
760.Fn ENGINE_set_default_* ,
761do so when an internally stored structural reference is no longer needed. 429do so when an internally stored structural reference is no longer needed.
762.Pp
763.Em Functional references
764.Pp
765As mentioned, functional references exist when the cryptographic
766functionality of an
767.Vt ENGINE
768is required to be available.
769A functional reference can be obtained in one of two ways; from an
770existing structural reference to the required
771.Vt ENGINE ,
772or by asking OpenSSL for the default operational
773.Vt ENGINE
774for a given cryptographic purpose.
775.Pp
776To obtain a functional reference from an existing structural reference,
777call the
778.Fn ENGINE_init
779function.
780This returns zero if the
781.Vt ENGINE
782was not already operational and couldn't be successfully initialised
783(e.g. lack of system drivers, no special hardware attached),
784otherwise it will return non-zero to indicate that the
785.Vt ENGINE
786is now operational and will have allocated a new
787.Sy functional
788reference to the
789.Vt ENGINE .
790All functional references are released by calling
791.Fn ENGINE_finish ,
792which removes the implicit structural reference as well.
793.Pp
794The second way to get a functional reference is by asking OpenSSL for a
795default implementation for a given task, e.g.
796by
797.Fn ENGINE_get_default_RSA ,
798.Fn ENGINE_get_default_cipher_engine ,
799etc.
800These are discussed in the next section, though they are not usually
801required by application programmers as they are used automatically when
802creating and using the relevant algorithm-specific types in OpenSSL,
803such as RSA, DSA, EVP_CIPHER_CTX, etc.
804.Ss Default implementations
805For each supported abstraction, the
806.Nm engine
807code maintains an internal table of state to control which
808implementations are available for a given abstraction and which
809should be used by default.
810These implementations are registered in the tables and indexed by an
811.Fa nid
812value, because abstractions like
813.Vt EVP_CIPHER
814and
815.Vt EVP_DIGEST
816support many distinct algorithms and modes, and
817.Vt ENGINE Ns s
818can support arbitrarily many of them.
819In the case of other abstractions like RSA, DSA, etc., there is
820only one "algorithm" so all implementations implicitly register
821using the same
822.Fa nid
823index.
824.Pp
825When a default
826.Vt ENGINE
827is requested for a given abstraction/algorithm/mode, (e.g. when
828calling
829.Fn RSA_new_method NULL ) ,
830a "get_default" call will be made to the
831.Nm engine
832subsystem to process the corresponding state table and return
833a functional reference to an initialised
834.Vt ENGINE
835whose implementation should be used.
836If no
837.Vt ENGINE
838should (or can) be used, it will return
839.Dv NULL
840and the caller will operate with a
841.Dv NULL
842.Vt ENGINE
843handle.
844This usually equates to using the conventional software implementation.
845In the latter case, OpenSSL will from then on behave the way it used to
846before the
847.Nm engine
848API existed.
849.Pp
850Each state table has a flag to note whether it has processed this
851"get_default" query since the table was last modified, because to
852process this question it must iterate across all the registered
853.Vt ENGINE Ns s
854in the table trying to initialise each of them in turn, in case one of
855them is operational.
856If it returns a functional reference to an
857.Vt ENGINE ,
858it will also cache another reference to speed up processing future
859queries (without needing to iterate across the table).
860Likewise, it will cache a
861.Dv NULL
862response if no
863.Vt ENGINE
864was available so that future queries won't repeat the same iteration
865unless the state table changes.
866This behaviour can also be changed; if the
867.Dv ENGINE_TABLE_FLAG_NOINIT
868flag is set (using
869.Fn ENGINE_set_table_flags ) ,
870no attempted initialisations will take place, instead the only way for
871the state table to return a
872.Pf non- Dv NULL
873.Vt ENGINE
874to the "get_default" query will be if one is expressly set in the table.
875For example,
876.Fn ENGINE_set_default_RSA
877does the same job as
878.Fn ENGINE_register_RSA
879except that it also sets the state table's cached response for the
880"get_default" query.
881In the case of abstractions like
882.Vt EVP_CIPHER ,
883where implementations are indexed by
884.Fa nid ,
885these flags and cached-responses are distinct for each
886.Fa nid
887value.
888.Ss Application requirements 430.Ss Application requirements
889This section will explain the basic things an application programmer 431This section will explain the basic things an application programmer
890should support to make the most useful elements of the 432should support to make the most useful elements of the
@@ -1029,7 +571,7 @@ For example, the next time OpenSSL tries to set up an RSA key, any bundled
1029that implement 571that implement
1030.Vt RSA_METHOD 572.Vt RSA_METHOD
1031will be passed to 573will be passed to
1032.Fn ENGINE_init 574.Xr ENGINE_init 3
1033and if any of those succeed, that 575and if any of those succeed, that
1034.Vt ENGINE 576.Vt ENGINE
1035will be set as the default for RSA use from then on. 577will be set as the default for RSA use from then on.
@@ -1074,11 +616,11 @@ This class of commands typically needs to be passed to an
1074.Vt ENGINE 616.Vt ENGINE
1075.Sy before 617.Sy before
1076attempting to initialise it, i.e. before calling 618attempting to initialise it, i.e. before calling
1077.Fn ENGINE_init . 619.Xr ENGINE_init 3 .
1078The other class of commands consist of settings or operations that tweak 620The other class of commands consist of settings or operations that tweak
1079certain behaviour or cause certain operations to take place, and these 621certain behaviour or cause certain operations to take place, and these
1080commands may work either before or after 622commands may work either before or after
1081.Fn ENGINE_init , 623.Xr ENGINE_init 3 ,
1082or in some cases both. 624or in some cases both.
1083.Vt ENGINE 625.Vt ENGINE
1084implementations should provide indications of this in the descriptions 626implementations should provide indications of this in the descriptions
@@ -1295,55 +837,22 @@ to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and
1295could therefore decide whether or not to support this "foo"-specific 837could therefore decide whether or not to support this "foo"-specific
1296extension). 838extension).
1297.Sh RETURN VALUES 839.Sh RETURN VALUES
1298.Fn ENGINE_get_first ,
1299.Fn ENGINE_get_last ,
1300.Fn ENGINE_get_next ,
1301.Fn ENGINE_get_prev ,
1302.Fn ENGINE_by_id ,
1303.Fn ENGINE_get_cipher_engine , 840.Fn ENGINE_get_cipher_engine ,
1304.Fn ENGINE_get_digest_engine , 841.Fn ENGINE_get_digest_engine ,
1305.Fn ENGINE_new , 842and
1306and all 843.Fn ENGINE_new
1307.Fn ENGINE_get_default_* 844return a valid
1308functions return a valid
1309.Vt ENGINE 845.Vt ENGINE
1310structure or 846structure or
1311.Dv NULL 847.Dv NULL
1312if an error occurred. 848if an error occurred.
1313.Pp 849.Pp
1314.Fn ENGINE_add ,
1315.Fn ENGINE_remove ,
1316.Fn ENGINE_init ,
1317.Fn ENGINE_finish ,
1318.Fn ENGINE_ctrl_cmd ,
1319.Fn ENGINE_ctrl_cmd_string ,
1320.Fn ENGINE_free , 850.Fn ENGINE_free ,
1321.Fn ENGINE_up_ref , 851.Fn ENGINE_up_ref ,
1322and all 852and all
1323.Fn ENGINE_set_* 853.Fn ENGINE_set_*
1324and
1325.Fn ENGINE_register_*
1326functions return 1 on success or 0 on error. 854functions return 1 on success or 0 on error.
1327.Pp 855.Pp
1328.Fn ENGINE_get_table_flags
1329returns an unsigned integer value representing the global table
1330flags which are used to control the registration behaviour of
1331.Vt ENGINE
1332implementations.
1333.Pp
1334For
1335.Fn ENGINE_ctrl ,
1336positive return values indicate success and negative return values
1337indicate failure.
1338The meaning of a zero return value depends on the particular
1339.Fa cmd
1340and may indicate both success and failure, which is pathetic.
1341.Pp
1342.Fn ENGINE_cmd_is_executable
1343returns 1 if
1344.Fa cmd
1345is executable or 0 otherwise.
1346.Pp
1347.Fn ENGINE_get_id 856.Fn ENGINE_get_id
1348and 857and
1349.Fn ENGINE_get_name 858.Fn ENGINE_get_name
@@ -1361,9 +870,6 @@ and
1361return a method structure for the respective algorithm. 870return a method structure for the respective algorithm.
1362.Pp 871.Pp
1363.Fn ENGINE_get_destroy_function , 872.Fn ENGINE_get_destroy_function ,
1364.Fn ENGINE_get_init_function ,
1365.Fn ENGINE_get_finish_function ,
1366.Fn ENGINE_get_ctrl_function ,
1367.Fn ENGINE_get_load_privkey_function , 873.Fn ENGINE_get_load_privkey_function ,
1368.Fn ENGINE_get_load_pubkey_function , 874.Fn ENGINE_get_load_pubkey_function ,
1369.Fn ENGINE_get_ciphers , 875.Fn ENGINE_get_ciphers ,
@@ -1390,13 +896,6 @@ returns an integer representing the flags
1390which are used to control various behaviours of an 896which are used to control various behaviours of an
1391.Vt ENGINE . 897.Vt ENGINE .
1392.Pp 898.Pp
1393.Fn ENGINE_get_cmd_defns
1394returns an
1395.Vt ENGINE_CMD_DEFN
1396structure or
1397.Dv NULL
1398if none is set.
1399.Pp
1400.Fn ENGINE_load_private_key 899.Fn ENGINE_load_private_key
1401and 900and
1402.Fn ENGINE_load_public_key 901.Fn ENGINE_load_public_key