Commit | Line | Data |
---|---|---|
aac4ff6f | 1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
8b0cefbb JR |
2 | .\" |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
984263bc MD |
6 | .br |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
8b0cefbb | 13 | .de Sp \" Vertical space (when we can't use .PP) |
984263bc MD |
14 | .if t .sp .5v |
15 | .if n .sp | |
16 | .. | |
8b0cefbb | 17 | .de Vb \" Begin verbatim text |
984263bc MD |
18 | .ft CW |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
8b0cefbb | 22 | .de Ve \" End verbatim text |
984263bc | 23 | .ft R |
984263bc MD |
24 | .fi |
25 | .. | |
8b0cefbb JR |
26 | .\" Set up some character translations and predefined strings. \*(-- will |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
aac4ff6f PA |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
8b0cefbb | 33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
984263bc | 34 | .ie n \{\ |
8b0cefbb JR |
35 | . ds -- \(*W- |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
984263bc MD |
43 | 'br\} |
44 | .el\{\ | |
8b0cefbb JR |
45 | . ds -- \|\(em\| |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
984263bc | 49 | 'br\} |
8b0cefbb JR |
50 | .\" |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
984263bc | 58 | .. |
8b0cefbb JR |
59 | . nr % 0 |
60 | . rr F | |
984263bc | 61 | .\} |
8b0cefbb | 62 | .\" |
aac4ff6f PA |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
8b0cefbb JR |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
984263bc | 71 | .if n \{\ |
8b0cefbb JR |
72 | . ds #H 0 |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
984263bc MD |
77 | .\} |
78 | .if t \{\ | |
8b0cefbb JR |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
984263bc | 84 | .\} |
8b0cefbb | 85 | . \" simple accents for nroff and troff |
984263bc | 86 | .if n \{\ |
8b0cefbb JR |
87 | . ds ' \& |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
984263bc MD |
93 | .\} |
94 | .if t \{\ | |
8b0cefbb JR |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
984263bc | 101 | .\} |
8b0cefbb | 102 | . \" troff and (daisy-wheel) nroff accents |
984263bc MD |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
8b0cefbb | 112 | . \" corrections for vroff |
984263bc MD |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
8b0cefbb | 115 | . \" for low resolution devices (crt and lpr) |
984263bc MD |
116 | .if \n(.H>23 .if \n(.V>19 \ |
117 | \{\ | |
8b0cefbb JR |
118 | . ds : e |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
984263bc MD |
127 | .\} |
128 | .rm #[ #] #H #V #F C | |
8b0cefbb JR |
129 | .\" ======================================================================== |
130 | .\" | |
131 | .IX Title "engine 3" | |
18ed9402 | 132 | .TH engine 3 "2008-09-27" "0.9.8i" "OpenSSL" |
984263bc | 133 | .SH "NAME" |
74dab6c2 | 134 | engine \- ENGINE cryptographic module support |
984263bc | 135 | .SH "SYNOPSIS" |
8b0cefbb | 136 | .IX Header "SYNOPSIS" |
984263bc MD |
137 | .Vb 1 |
138 | \& #include <openssl/engine.h> | |
aac4ff6f PA |
139 | .Ve |
140 | .PP | |
141 | .Vb 4 | |
984263bc MD |
142 | \& ENGINE *ENGINE_get_first(void); |
143 | \& ENGINE *ENGINE_get_last(void); | |
144 | \& ENGINE *ENGINE_get_next(ENGINE *e); | |
145 | \& ENGINE *ENGINE_get_prev(ENGINE *e); | |
aac4ff6f PA |
146 | .Ve |
147 | .PP | |
148 | .Vb 2 | |
984263bc MD |
149 | \& int ENGINE_add(ENGINE *e); |
150 | \& int ENGINE_remove(ENGINE *e); | |
aac4ff6f PA |
151 | .Ve |
152 | .PP | |
153 | .Vb 1 | |
984263bc | 154 | \& ENGINE *ENGINE_by_id(const char *id); |
aac4ff6f PA |
155 | .Ve |
156 | .PP | |
157 | .Vb 2 | |
984263bc MD |
158 | \& int ENGINE_init(ENGINE *e); |
159 | \& int ENGINE_finish(ENGINE *e); | |
aac4ff6f PA |
160 | .Ve |
161 | .PP | |
162 | .Vb 15 | |
984263bc MD |
163 | \& void ENGINE_load_openssl(void); |
164 | \& void ENGINE_load_dynamic(void); | |
a561f9ff SS |
165 | \& #ifndef OPENSSL_NO_STATIC_ENGINE |
166 | \& void ENGINE_load_4758cca(void); | |
167 | \& void ENGINE_load_aep(void); | |
984263bc | 168 | \& void ENGINE_load_atalla(void); |
a561f9ff SS |
169 | \& void ENGINE_load_chil(void); |
170 | \& void ENGINE_load_cswift(void); | |
171 | \& void ENGINE_load_gmp(void); | |
984263bc | 172 | \& void ENGINE_load_nuron(void); |
984263bc | 173 | \& void ENGINE_load_sureware(void); |
a561f9ff SS |
174 | \& void ENGINE_load_ubsec(void); |
175 | \& #endif | |
176 | \& void ENGINE_load_cryptodev(void); | |
984263bc | 177 | \& void ENGINE_load_builtin_engines(void); |
aac4ff6f PA |
178 | .Ve |
179 | .PP | |
180 | .Vb 1 | |
984263bc | 181 | \& void ENGINE_cleanup(void); |
aac4ff6f PA |
182 | .Ve |
183 | .PP | |
184 | .Vb 8 | |
984263bc MD |
185 | \& ENGINE *ENGINE_get_default_RSA(void); |
186 | \& ENGINE *ENGINE_get_default_DSA(void); | |
a561f9ff SS |
187 | \& ENGINE *ENGINE_get_default_ECDH(void); |
188 | \& ENGINE *ENGINE_get_default_ECDSA(void); | |
984263bc MD |
189 | \& ENGINE *ENGINE_get_default_DH(void); |
190 | \& ENGINE *ENGINE_get_default_RAND(void); | |
191 | \& ENGINE *ENGINE_get_cipher_engine(int nid); | |
192 | \& ENGINE *ENGINE_get_digest_engine(int nid); | |
aac4ff6f PA |
193 | .Ve |
194 | .PP | |
195 | .Vb 9 | |
984263bc MD |
196 | \& int ENGINE_set_default_RSA(ENGINE *e); |
197 | \& int ENGINE_set_default_DSA(ENGINE *e); | |
a561f9ff SS |
198 | \& int ENGINE_set_default_ECDH(ENGINE *e); |
199 | \& int ENGINE_set_default_ECDSA(ENGINE *e); | |
984263bc MD |
200 | \& int ENGINE_set_default_DH(ENGINE *e); |
201 | \& int ENGINE_set_default_RAND(ENGINE *e); | |
202 | \& int ENGINE_set_default_ciphers(ENGINE *e); | |
203 | \& int ENGINE_set_default_digests(ENGINE *e); | |
204 | \& int ENGINE_set_default_string(ENGINE *e, const char *list); | |
aac4ff6f PA |
205 | .Ve |
206 | .PP | |
207 | .Vb 1 | |
984263bc | 208 | \& int ENGINE_set_default(ENGINE *e, unsigned int flags); |
aac4ff6f PA |
209 | .Ve |
210 | .PP | |
211 | .Vb 2 | |
984263bc MD |
212 | \& unsigned int ENGINE_get_table_flags(void); |
213 | \& void ENGINE_set_table_flags(unsigned int flags); | |
aac4ff6f PA |
214 | .Ve |
215 | .PP | |
216 | .Vb 29 | |
984263bc MD |
217 | \& int ENGINE_register_RSA(ENGINE *e); |
218 | \& void ENGINE_unregister_RSA(ENGINE *e); | |
219 | \& void ENGINE_register_all_RSA(void); | |
220 | \& int ENGINE_register_DSA(ENGINE *e); | |
221 | \& void ENGINE_unregister_DSA(ENGINE *e); | |
222 | \& void ENGINE_register_all_DSA(void); | |
a561f9ff SS |
223 | \& int ENGINE_register_ECDH(ENGINE *e); |
224 | \& void ENGINE_unregister_ECDH(ENGINE *e); | |
225 | \& void ENGINE_register_all_ECDH(void); | |
226 | \& int ENGINE_register_ECDSA(ENGINE *e); | |
227 | \& void ENGINE_unregister_ECDSA(ENGINE *e); | |
228 | \& void ENGINE_register_all_ECDSA(void); | |
984263bc MD |
229 | \& int ENGINE_register_DH(ENGINE *e); |
230 | \& void ENGINE_unregister_DH(ENGINE *e); | |
231 | \& void ENGINE_register_all_DH(void); | |
232 | \& int ENGINE_register_RAND(ENGINE *e); | |
233 | \& void ENGINE_unregister_RAND(ENGINE *e); | |
234 | \& void ENGINE_register_all_RAND(void); | |
a561f9ff SS |
235 | \& int ENGINE_register_STORE(ENGINE *e); |
236 | \& void ENGINE_unregister_STORE(ENGINE *e); | |
237 | \& void ENGINE_register_all_STORE(void); | |
984263bc MD |
238 | \& int ENGINE_register_ciphers(ENGINE *e); |
239 | \& void ENGINE_unregister_ciphers(ENGINE *e); | |
240 | \& void ENGINE_register_all_ciphers(void); | |
241 | \& int ENGINE_register_digests(ENGINE *e); | |
242 | \& void ENGINE_unregister_digests(ENGINE *e); | |
243 | \& void ENGINE_register_all_digests(void); | |
244 | \& int ENGINE_register_complete(ENGINE *e); | |
245 | \& int ENGINE_register_all_complete(void); | |
aac4ff6f PA |
246 | .Ve |
247 | .PP | |
248 | .Vb 6 | |
a561f9ff | 249 | \& int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); |
984263bc MD |
250 | \& int ENGINE_cmd_is_executable(ENGINE *e, int cmd); |
251 | \& int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | |
a561f9ff | 252 | \& long i, void *p, void (*f)(void), int cmd_optional); |
984263bc | 253 | \& int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, |
a561f9ff | 254 | \& int cmd_optional); |
aac4ff6f PA |
255 | .Ve |
256 | .PP | |
257 | .Vb 2 | |
984263bc MD |
258 | \& int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); |
259 | \& void *ENGINE_get_ex_data(const ENGINE *e, int idx); | |
aac4ff6f PA |
260 | .Ve |
261 | .PP | |
262 | .Vb 2 | |
984263bc MD |
263 | \& int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
264 | \& CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | |
aac4ff6f PA |
265 | .Ve |
266 | .PP | |
267 | .Vb 3 | |
984263bc MD |
268 | \& ENGINE *ENGINE_new(void); |
269 | \& int ENGINE_free(ENGINE *e); | |
a561f9ff | 270 | \& int ENGINE_up_ref(ENGINE *e); |
aac4ff6f PA |
271 | .Ve |
272 | .PP | |
273 | .Vb 19 | |
984263bc MD |
274 | \& int ENGINE_set_id(ENGINE *e, const char *id); |
275 | \& int ENGINE_set_name(ENGINE *e, const char *name); | |
276 | \& int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); | |
277 | \& int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); | |
a561f9ff SS |
278 | \& int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *dh_meth); |
279 | \& int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *dh_meth); | |
984263bc MD |
280 | \& int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); |
281 | \& int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); | |
a561f9ff | 282 | \& int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *rand_meth); |
984263bc MD |
283 | \& int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); |
284 | \& int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); | |
285 | \& int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); | |
286 | \& int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); | |
287 | \& int ENGINE_set_load_privkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpriv_f); | |
288 | \& int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); | |
289 | \& int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); | |
290 | \& int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); | |
291 | \& int ENGINE_set_flags(ENGINE *e, int flags); | |
292 | \& int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); | |
aac4ff6f PA |
293 | .Ve |
294 | .PP | |
295 | .Vb 21 | |
984263bc MD |
296 | \& const char *ENGINE_get_id(const ENGINE *e); |
297 | \& const char *ENGINE_get_name(const ENGINE *e); | |
298 | \& const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); | |
299 | \& const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); | |
a561f9ff SS |
300 | \& const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); |
301 | \& const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); | |
984263bc MD |
302 | \& const DH_METHOD *ENGINE_get_DH(const ENGINE *e); |
303 | \& const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); | |
a561f9ff | 304 | \& const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); |
984263bc MD |
305 | \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); |
306 | \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); | |
307 | \& ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); | |
308 | \& ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); | |
309 | \& ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); | |
310 | \& ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); | |
311 | \& ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); | |
312 | \& ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); | |
313 | \& const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); | |
314 | \& const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); | |
315 | \& int ENGINE_get_flags(const ENGINE *e); | |
316 | \& const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); | |
aac4ff6f PA |
317 | .Ve |
318 | .PP | |
319 | .Vb 4 | |
984263bc MD |
320 | \& EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, |
321 | \& UI_METHOD *ui_method, void *callback_data); | |
322 | \& EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, | |
323 | \& UI_METHOD *ui_method, void *callback_data); | |
aac4ff6f PA |
324 | .Ve |
325 | .PP | |
326 | .Vb 1 | |
984263bc MD |
327 | \& void ENGINE_add_conf_module(void); |
328 | .Ve | |
329 | .SH "DESCRIPTION" | |
8b0cefbb | 330 | .IX Header "DESCRIPTION" |
984263bc | 331 | These functions create, manipulate, and use cryptographic modules in the |
8b0cefbb | 332 | form of \fB\s-1ENGINE\s0\fR objects. These objects act as containers for |
984263bc MD |
333 | implementations of cryptographic algorithms, and support a |
334 | reference-counted mechanism to allow them to be dynamically loaded in and | |
335 | out of the running application. | |
336 | .PP | |
8b0cefbb | 337 | The cryptographic functionality that can be provided by an \fB\s-1ENGINE\s0\fR |
984263bc MD |
338 | implementation includes the following abstractions; |
339 | .PP | |
a561f9ff | 340 | .Vb 6 |
aac4ff6f | 341 | \& RSA_METHOD - for providing alternative RSA implementations |
a561f9ff | 342 | \& DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD, |
aac4ff6f PA |
343 | \& STORE_METHOD - similarly for other OpenSSL APIs |
344 | \& EVP_CIPHER - potentially multiple cipher algorithms (indexed by 'nid') | |
345 | \& EVP_DIGEST - potentially multiple hash algorithms (indexed by 'nid') | |
346 | \& key-loading - loading public and/or private EVP_PKEY keys | |
984263bc MD |
347 | .Ve |
348 | .Sh "Reference counting and handles" | |
8b0cefbb | 349 | .IX Subsection "Reference counting and handles" |
984263bc MD |
350 | Due to the modular nature of the \s-1ENGINE\s0 \s-1API\s0, pointers to ENGINEs need to be |
351 | treated as handles \- ie. not only as pointers, but also as references to | |
a561f9ff | 352 | the underlying \s-1ENGINE\s0 object. Ie. one should obtain a new reference when |
984263bc | 353 | making copies of an \s-1ENGINE\s0 pointer if the copies will be used (and |
aac4ff6f | 354 | released) independently. |
984263bc | 355 | .PP |
8b0cefbb | 356 | \&\s-1ENGINE\s0 objects have two levels of reference-counting to match the way in |
984263bc | 357 | which the objects are used. At the most basic level, each \s-1ENGINE\s0 pointer is |
a561f9ff SS |
358 | inherently a \fBstructural\fR reference \- a structural reference is required |
359 | to use the pointer value at all, as this kind of reference is a guarantee | |
360 | that the structure can not be deallocated until the reference is released. | |
361 | .PP | |
362 | However, a structural reference provides no guarantee that the \s-1ENGINE\s0 is | |
363 | initiliased and able to use any of its cryptographic | |
364 | implementations. Indeed it's quite possible that most ENGINEs will not | |
365 | initialise at all in typical environments, as ENGINEs are typically used to | |
984263bc | 366 | support specialised hardware. To use an \s-1ENGINE\s0's functionality, you need a |
8b0cefbb | 367 | \&\fBfunctional\fR reference. This kind of reference can be considered a |
984263bc MD |
368 | specialised form of structural reference, because each functional reference |
369 | implicitly contains a structural reference as well \- however to avoid | |
370 | difficult-to-find programming bugs, it is recommended to treat the two | |
aac4ff6f | 371 | kinds of reference independently. If you have a functional reference to an |
8b0cefbb | 372 | \&\s-1ENGINE\s0, you have a guarantee that the \s-1ENGINE\s0 has been initialised ready to |
a561f9ff SS |
373 | perform cryptographic operations and will remain uninitialised |
374 | until after you have released your reference. | |
984263bc | 375 | .PP |
8b0cefbb | 376 | \&\fIStructural references\fR |
984263bc | 377 | .PP |
a561f9ff SS |
378 | This basic type of reference is used for instantiating new ENGINEs, |
379 | iterating across OpenSSL's internal linked-list of loaded | |
984263bc MD |
380 | ENGINEs, reading information about an \s-1ENGINE\s0, etc. Essentially a structural |
381 | reference is sufficient if you only need to query or manipulate the data of | |
382 | an \s-1ENGINE\s0 implementation rather than use its functionality. | |
383 | .PP | |
384 | The \fIENGINE_new()\fR function returns a structural reference to a new (empty) | |
a561f9ff SS |
385 | \&\s-1ENGINE\s0 object. There are other \s-1ENGINE\s0 \s-1API\s0 functions that return structural |
386 | references such as; \fIENGINE_by_id()\fR, \fIENGINE_get_first()\fR, \fIENGINE_get_last()\fR, | |
387 | \&\fIENGINE_get_next()\fR, \fIENGINE_get_prev()\fR. All structural references should be | |
388 | released by a corresponding to call to the \fIENGINE_free()\fR function \- the | |
389 | \&\s-1ENGINE\s0 object itself will only actually be cleaned up and deallocated when | |
390 | the last structural reference is released. | |
984263bc MD |
391 | .PP |
392 | It should also be noted that many \s-1ENGINE\s0 \s-1API\s0 function calls that accept a | |
393 | structural reference will internally obtain another reference \- typically | |
394 | this happens whenever the supplied \s-1ENGINE\s0 will be needed by OpenSSL after | |
395 | the function has returned. Eg. the function to add a new \s-1ENGINE\s0 to | |
396 | OpenSSL's internal list is \fIENGINE_add()\fR \- if this function returns success, | |
397 | then OpenSSL will have stored a new structural reference internally so the | |
398 | caller is still responsible for freeing their own reference with | |
8b0cefbb | 399 | \&\fIENGINE_free()\fR when they are finished with it. In a similar way, some |
984263bc MD |
400 | functions will automatically release the structural reference passed to it |
401 | if part of the function's job is to do so. Eg. the \fIENGINE_get_next()\fR and | |
8b0cefbb JR |
402 | \&\fIENGINE_get_prev()\fR functions are used for iterating across the internal |
403 | \&\s-1ENGINE\s0 list \- they will return a new structural reference to the next (or | |
984263bc MD |
404 | previous) \s-1ENGINE\s0 in the list or \s-1NULL\s0 if at the end (or beginning) of the |
405 | list, but in either case the structural reference passed to the function is | |
406 | released on behalf of the caller. | |
407 | .PP | |
408 | To clarify a particular function's handling of references, one should | |
409 | always consult that function's documentation \*(L"man\*(R" page, or failing that | |
410 | the openssl/engine.h header file includes some hints. | |
411 | .PP | |
8b0cefbb | 412 | \&\fIFunctional references\fR |
984263bc MD |
413 | .PP |
414 | As mentioned, functional references exist when the cryptographic | |
415 | functionality of an \s-1ENGINE\s0 is required to be available. A functional | |
416 | reference can be obtained in one of two ways; from an existing structural | |
417 | reference to the required \s-1ENGINE\s0, or by asking OpenSSL for the default | |
418 | operational \s-1ENGINE\s0 for a given cryptographic purpose. | |
419 | .PP | |
420 | To obtain a functional reference from an existing structural reference, | |
421 | call the \fIENGINE_init()\fR function. This returns zero if the \s-1ENGINE\s0 was not | |
422 | already operational and couldn't be successfully initialised (eg. lack of | |
423 | system drivers, no special hardware attached, etc), otherwise it will | |
424 | return non-zero to indicate that the \s-1ENGINE\s0 is now operational and will | |
a561f9ff SS |
425 | have allocated a new \fBfunctional\fR reference to the \s-1ENGINE\s0. All functional |
426 | references are released by calling \fIENGINE_finish()\fR (which removes the | |
427 | implicit structural reference as well). | |
984263bc MD |
428 | .PP |
429 | The second way to get a functional reference is by asking OpenSSL for a | |
430 | default implementation for a given task, eg. by \fIENGINE_get_default_RSA()\fR, | |
8b0cefbb | 431 | \&\fIENGINE_get_default_cipher_engine()\fR, etc. These are discussed in the next |
984263bc MD |
432 | section, though they are not usually required by application programmers as |
433 | they are used automatically when creating and using the relevant | |
434 | algorithm-specific types in OpenSSL, such as \s-1RSA\s0, \s-1DSA\s0, \s-1EVP_CIPHER_CTX\s0, etc. | |
435 | .Sh "Default implementations" | |
8b0cefbb | 436 | .IX Subsection "Default implementations" |
984263bc MD |
437 | For each supported abstraction, the \s-1ENGINE\s0 code maintains an internal table |
438 | of state to control which implementations are available for a given | |
439 | abstraction and which should be used by default. These implementations are | |
a561f9ff | 440 | registered in the tables and indexed by an 'nid' value, because |
984263bc | 441 | abstractions like \s-1EVP_CIPHER\s0 and \s-1EVP_DIGEST\s0 support many distinct |
a561f9ff SS |
442 | algorithms and modes, and ENGINEs can support arbitrarily many of them. |
443 | In the case of other abstractions like \s-1RSA\s0, \s-1DSA\s0, etc, there is only one | |
444 | \&\*(L"algorithm\*(R" so all implementations implicitly register using the same 'nid' | |
445 | index. | |
446 | .PP | |
447 | When a default \s-1ENGINE\s0 is requested for a given abstraction/algorithm/mode, (eg. | |
448 | when calling RSA_new_method(\s-1NULL\s0)), a \*(L"get_default\*(R" call will be made to the | |
449 | \&\s-1ENGINE\s0 subsystem to process the corresponding state table and return a | |
450 | functional reference to an initialised \s-1ENGINE\s0 whose implementation should be | |
451 | used. If no \s-1ENGINE\s0 should (or can) be used, it will return \s-1NULL\s0 and the caller | |
452 | will operate with a \s-1NULL\s0 \s-1ENGINE\s0 handle \- this usually equates to using the | |
453 | conventional software implementation. In the latter case, OpenSSL will from | |
454 | then on behave the way it used to before the \s-1ENGINE\s0 \s-1API\s0 existed. | |
984263bc MD |
455 | .PP |
456 | Each state table has a flag to note whether it has processed this | |
8b0cefbb | 457 | \&\*(L"get_default\*(R" query since the table was last modified, because to process |
984263bc MD |
458 | this question it must iterate across all the registered ENGINEs in the |
459 | table trying to initialise each of them in turn, in case one of them is | |
460 | operational. If it returns a functional reference to an \s-1ENGINE\s0, it will | |
461 | also cache another reference to speed up processing future queries (without | |
462 | needing to iterate across the table). Likewise, it will cache a \s-1NULL\s0 | |
463 | response if no \s-1ENGINE\s0 was available so that future queries won't repeat the | |
464 | same iteration unless the state table changes. This behaviour can also be | |
465 | changed; if the \s-1ENGINE_TABLE_FLAG_NOINIT\s0 flag is set (using | |
8b0cefbb JR |
466 | \&\fIENGINE_set_table_flags()\fR), no attempted initialisations will take place, |
467 | instead the only way for the state table to return a non-NULL \s-1ENGINE\s0 to the | |
468 | \&\*(L"get_default\*(R" query will be if one is expressly set in the table. Eg. | |
469 | \&\fIENGINE_set_default_RSA()\fR does the same job as \fIENGINE_register_RSA()\fR except | |
984263bc | 470 | that it also sets the state table's cached response for the \*(L"get_default\*(R" |
a561f9ff SS |
471 | query. In the case of abstractions like \s-1EVP_CIPHER\s0, where implementations are |
472 | indexed by 'nid', these flags and cached-responses are distinct for each 'nid' | |
473 | value. | |
984263bc | 474 | .Sh "Application requirements" |
8b0cefbb | 475 | .IX Subsection "Application requirements" |
984263bc MD |
476 | This section will explain the basic things an application programmer should |
477 | support to make the most useful elements of the \s-1ENGINE\s0 functionality | |
478 | available to the user. The first thing to consider is whether the | |
479 | programmer wishes to make alternative \s-1ENGINE\s0 modules available to the | |
480 | application and user. OpenSSL maintains an internal linked list of | |
aac4ff6f | 481 | \&\*(L"visible\*(R" ENGINEs from which it has to operate \- at start\-up, this list is |
984263bc MD |
482 | empty and in fact if an application does not call any \s-1ENGINE\s0 \s-1API\s0 calls and |
483 | it uses static linking against openssl, then the resulting application | |
484 | binary will not contain any alternative \s-1ENGINE\s0 code at all. So the first | |
485 | consideration is whether any/all available \s-1ENGINE\s0 implementations should be | |
486 | made visible to OpenSSL \- this is controlled by calling the various \*(L"load\*(R" | |
487 | functions, eg. | |
488 | .PP | |
489 | .Vb 9 | |
490 | \& /* Make the "dynamic" ENGINE available */ | |
491 | \& void ENGINE_load_dynamic(void); | |
492 | \& /* Make the CryptoSwift hardware acceleration support available */ | |
493 | \& void ENGINE_load_cswift(void); | |
494 | \& /* Make support for nCipher's "CHIL" hardware available */ | |
495 | \& void ENGINE_load_chil(void); | |
496 | \& ... | |
497 | \& /* Make ALL ENGINE implementations bundled with OpenSSL available */ | |
498 | \& void ENGINE_load_builtin_engines(void); | |
499 | .Ve | |
8b0cefbb | 500 | .PP |
984263bc MD |
501 | Having called any of these functions, \s-1ENGINE\s0 objects would have been |
502 | dynamically allocated and populated with these implementations and linked | |
503 | into OpenSSL's internal linked list. At this point it is important to | |
504 | mention an important \s-1API\s0 function; | |
505 | .PP | |
506 | .Vb 1 | |
507 | \& void ENGINE_cleanup(void); | |
508 | .Ve | |
8b0cefbb | 509 | .PP |
984263bc MD |
510 | If no \s-1ENGINE\s0 \s-1API\s0 functions are called at all in an application, then there |
511 | are no inherent memory leaks to worry about from the \s-1ENGINE\s0 functionality, | |
a561f9ff | 512 | however if any ENGINEs are loaded, even if they are never registered or |
984263bc MD |
513 | used, it is necessary to use the \fIENGINE_cleanup()\fR function to |
514 | correspondingly cleanup before program exit, if the caller wishes to avoid | |
515 | memory leaks. This mechanism uses an internal callback registration table | |
516 | so that any \s-1ENGINE\s0 \s-1API\s0 functionality that knows it requires cleanup can | |
517 | register its cleanup details to be called during \fIENGINE_cleanup()\fR. This | |
518 | approach allows \fIENGINE_cleanup()\fR to clean up after any \s-1ENGINE\s0 functionality | |
519 | at all that your program uses, yet doesn't automatically create linker | |
520 | dependencies to all possible \s-1ENGINE\s0 functionality \- only the cleanup | |
521 | callbacks required by the functionality you do use will be required by the | |
522 | linker. | |
523 | .PP | |
524 | The fact that ENGINEs are made visible to OpenSSL (and thus are linked into | |
aac4ff6f | 525 | the program and loaded into memory at run\-time) does not mean they are |
8b0cefbb | 526 | \&\*(L"registered\*(R" or called into use by OpenSSL automatically \- that behaviour |
a561f9ff | 527 | is something for the application to control. Some applications |
984263bc MD |
528 | will want to allow the user to specify exactly which \s-1ENGINE\s0 they want used |
529 | if any is to be used at all. Others may prefer to load all support and have | |
530 | OpenSSL automatically use at run-time any \s-1ENGINE\s0 that is able to | |
531 | successfully initialise \- ie. to assume that this corresponds to | |
532 | acceleration hardware attached to the machine or some such thing. There are | |
533 | probably numerous other ways in which applications may prefer to handle | |
534 | things, so we will simply illustrate the consequences as they apply to a | |
535 | couple of simple cases and leave developers to consider these and the | |
536 | source code to openssl's builtin utilities as guides. | |
537 | .PP | |
8b0cefbb | 538 | \&\fIUsing a specific \s-1ENGINE\s0 implementation\fR |
984263bc MD |
539 | .PP |
540 | Here we'll assume an application has been configured by its user or admin | |
541 | to want to use the \*(L"\s-1ACME\s0\*(R" \s-1ENGINE\s0 if it is available in the version of | |
542 | OpenSSL the application was compiled with. If it is available, it should be | |
543 | used by default for all \s-1RSA\s0, \s-1DSA\s0, and symmetric cipher operation, otherwise | |
544 | OpenSSL should use its builtin software as per usual. The following code | |
545 | illustrates how to approach this; | |
546 | .PP | |
aac4ff6f | 547 | .Vb 22 |
984263bc MD |
548 | \& ENGINE *e; |
549 | \& const char *engine_id = "ACME"; | |
550 | \& ENGINE_load_builtin_engines(); | |
551 | \& e = ENGINE_by_id(engine_id); | |
552 | \& if(!e) | |
553 | \& /* the engine isn't available */ | |
554 | \& return; | |
555 | \& if(!ENGINE_init(e)) { | |
556 | \& /* the engine couldn't initialise, release 'e' */ | |
557 | \& ENGINE_free(e); | |
558 | \& return; | |
559 | \& } | |
560 | \& if(!ENGINE_set_default_RSA(e)) | |
561 | \& /* This should only happen when 'e' can't initialise, but the previous | |
562 | \& * statement suggests it did. */ | |
563 | \& abort(); | |
564 | \& ENGINE_set_default_DSA(e); | |
565 | \& ENGINE_set_default_ciphers(e); | |
566 | \& /* Release the functional reference from ENGINE_init() */ | |
567 | \& ENGINE_finish(e); | |
568 | \& /* Release the structural reference from ENGINE_by_id() */ | |
569 | \& ENGINE_free(e); | |
570 | .Ve | |
8b0cefbb JR |
571 | .PP |
572 | \&\fIAutomatically using builtin \s-1ENGINE\s0 implementations\fR | |
984263bc MD |
573 | .PP |
574 | Here we'll assume we want to load and register all \s-1ENGINE\s0 implementations | |
575 | bundled with OpenSSL, such that for any cryptographic algorithm required by | |
576 | OpenSSL \- if there is an \s-1ENGINE\s0 that implements it and can be initialise, | |
577 | it should be used. The following code illustrates how this can work; | |
578 | .PP | |
579 | .Vb 4 | |
580 | \& /* Load all bundled ENGINEs into memory and make them visible */ | |
581 | \& ENGINE_load_builtin_engines(); | |
582 | \& /* Register all of them for every algorithm they collectively implement */ | |
583 | \& ENGINE_register_all_complete(); | |
584 | .Ve | |
8b0cefbb | 585 | .PP |
984263bc | 586 | That's all that's required. Eg. the next time OpenSSL tries to set up an |
8b0cefbb JR |
587 | \&\s-1RSA\s0 key, any bundled ENGINEs that implement \s-1RSA_METHOD\s0 will be passed to |
588 | \&\fIENGINE_init()\fR and if any of those succeed, that \s-1ENGINE\s0 will be set as the | |
a561f9ff | 589 | default for \s-1RSA\s0 use from then on. |
984263bc | 590 | .Sh "Advanced configuration support" |
8b0cefbb | 591 | .IX Subsection "Advanced configuration support" |
984263bc | 592 | There is a mechanism supported by the \s-1ENGINE\s0 framework that allows each |
8b0cefbb JR |
593 | \&\s-1ENGINE\s0 implementation to define an arbitrary set of configuration |
594 | \&\*(L"commands\*(R" and expose them to OpenSSL and any applications based on | |
984263bc | 595 | OpenSSL. This mechanism is entirely based on the use of name-value pairs |
a561f9ff | 596 | and assumes \s-1ASCII\s0 input (no unicode or \s-1UTF\s0 for now!), so it is ideal if |
984263bc MD |
597 | applications want to provide a transparent way for users to provide |
598 | arbitrary configuration \*(L"directives\*(R" directly to such ENGINEs. It is also | |
599 | possible for the application to dynamically interrogate the loaded \s-1ENGINE\s0 | |
600 | implementations for the names, descriptions, and input flags of their | |
601 | available \*(L"control commands\*(R", providing a more flexible configuration | |
602 | scheme. However, if the user is expected to know which \s-1ENGINE\s0 device he/she | |
603 | is using (in the case of specialised hardware, this goes without saying) | |
604 | then applications may not need to concern themselves with discovering the | |
a561f9ff SS |
605 | supported control commands and simply prefer to pass settings into ENGINEs |
606 | exactly as they are provided by the user. | |
984263bc MD |
607 | .PP |
608 | Before illustrating how control commands work, it is worth mentioning what | |
609 | they are typically used for. Broadly speaking there are two uses for | |
610 | control commands; the first is to provide the necessary details to the | |
611 | implementation (which may know nothing at all specific to the host system) | |
612 | so that it can be initialised for use. This could include the path to any | |
613 | driver or config files it needs to load, required network addresses, | |
a561f9ff | 614 | smart-card identifiers, passwords to initialise protected devices, |
984263bc MD |
615 | logging information, etc etc. This class of commands typically needs to be |
616 | passed to an \s-1ENGINE\s0 \fBbefore\fR attempting to initialise it, ie. before | |
617 | calling \fIENGINE_init()\fR. The other class of commands consist of settings or | |
618 | operations that tweak certain behaviour or cause certain operations to take | |
619 | place, and these commands may work either before or after \fIENGINE_init()\fR, or | |
a561f9ff | 620 | in some cases both. \s-1ENGINE\s0 implementations should provide indications of |
984263bc MD |
621 | this in the descriptions attached to builtin control commands and/or in |
622 | external product documentation. | |
623 | .PP | |
8b0cefbb | 624 | \&\fIIssuing control commands to an \s-1ENGINE\s0\fR |
984263bc MD |
625 | .PP |
626 | Let's illustrate by example; a function for which the caller supplies the | |
627 | name of the \s-1ENGINE\s0 it wishes to use, a table of string-pairs for use before | |
628 | initialisation, and another table for use after initialisation. Note that | |
629 | the string-pairs used for control commands consist of a command \*(L"name\*(R" | |
630 | followed by the command \*(L"parameter\*(R" \- the parameter could be \s-1NULL\s0 in some | |
631 | cases but the name can not. This function should initialise the \s-1ENGINE\s0 | |
632 | (issuing the \*(L"pre\*(R" commands beforehand and the \*(L"post\*(R" commands afterwards) | |
633 | and set it as the default for everything except \s-1RAND\s0 and then return a | |
634 | boolean success or failure. | |
635 | .PP | |
aac4ff6f | 636 | .Vb 36 |
984263bc MD |
637 | \& int generic_load_engine_fn(const char *engine_id, |
638 | \& const char **pre_cmds, int pre_num, | |
639 | \& const char **post_cmds, int post_num) | |
640 | \& { | |
641 | \& ENGINE *e = ENGINE_by_id(engine_id); | |
642 | \& if(!e) return 0; | |
aac4ff6f | 643 | \& while(pre_num--) { |
984263bc | 644 | \& if(!ENGINE_ctrl_cmd_string(e, pre_cmds[0], pre_cmds[1], 0)) { |
aac4ff6f | 645 | \& fprintf(stderr, "Failed command (%s - %s:%s)\en", engine_id, |
984263bc MD |
646 | \& pre_cmds[0], pre_cmds[1] ? pre_cmds[1] : "(NULL)"); |
647 | \& ENGINE_free(e); | |
648 | \& return 0; | |
649 | \& } | |
650 | \& pre_cmds += 2; | |
651 | \& } | |
652 | \& if(!ENGINE_init(e)) { | |
653 | \& fprintf(stderr, "Failed initialisation\en"); | |
654 | \& ENGINE_free(e); | |
655 | \& return 0; | |
656 | \& } | |
657 | \& /* ENGINE_init() returned a functional reference, so free the structural | |
658 | \& * reference from ENGINE_by_id(). */ | |
659 | \& ENGINE_free(e); | |
aac4ff6f | 660 | \& while(post_num--) { |
984263bc | 661 | \& if(!ENGINE_ctrl_cmd_string(e, post_cmds[0], post_cmds[1], 0)) { |
aac4ff6f | 662 | \& fprintf(stderr, "Failed command (%s - %s:%s)\en", engine_id, |
984263bc MD |
663 | \& post_cmds[0], post_cmds[1] ? post_cmds[1] : "(NULL)"); |
664 | \& ENGINE_finish(e); | |
665 | \& return 0; | |
666 | \& } | |
667 | \& post_cmds += 2; | |
668 | \& } | |
669 | \& ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND); | |
670 | \& /* Success */ | |
671 | \& return 1; | |
672 | \& } | |
673 | .Ve | |
8b0cefbb | 674 | .PP |
984263bc MD |
675 | Note that \fIENGINE_ctrl_cmd_string()\fR accepts a boolean argument that can |
676 | relax the semantics of the function \- if set non-zero it will only return | |
677 | failure if the \s-1ENGINE\s0 supported the given command name but failed while | |
678 | executing it, if the \s-1ENGINE\s0 doesn't support the command name it will simply | |
679 | return success without doing anything. In this case we assume the user is | |
680 | only supplying commands specific to the given \s-1ENGINE\s0 so we set this to | |
8b0cefbb | 681 | \&\s-1FALSE\s0. |
984263bc | 682 | .PP |
8b0cefbb | 683 | \&\fIDiscovering supported control commands\fR |
984263bc | 684 | .PP |
aac4ff6f | 685 | It is possible to discover at run-time the names, numerical\-ids, descriptions |
a561f9ff SS |
686 | and input parameters of the control commands supported by an \s-1ENGINE\s0 using a |
687 | structural reference. Note that some control commands are defined by OpenSSL | |
688 | itself and it will intercept and handle these control commands on behalf of the | |
689 | \&\s-1ENGINE\s0, ie. the \s-1ENGINE\s0's \fIctrl()\fR handler is not used for the control command. | |
690 | openssl/engine.h defines an index, \s-1ENGINE_CMD_BASE\s0, that all control commands | |
691 | implemented by ENGINEs should be numbered from. Any command value lower than | |
692 | this symbol is considered a \*(L"generic\*(R" command is handled directly by the | |
693 | OpenSSL core routines. | |
984263bc MD |
694 | .PP |
695 | It is using these \*(L"core\*(R" control commands that one can discover the the control | |
696 | commands implemented by a given \s-1ENGINE\s0, specifically the commands; | |
697 | .PP | |
698 | .Vb 9 | |
699 | \& #define ENGINE_HAS_CTRL_FUNCTION 10 | |
700 | \& #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 | |
701 | \& #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 | |
702 | \& #define ENGINE_CTRL_GET_CMD_FROM_NAME 13 | |
703 | \& #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 | |
704 | \& #define ENGINE_CTRL_GET_NAME_FROM_CMD 15 | |
705 | \& #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 | |
706 | \& #define ENGINE_CTRL_GET_DESC_FROM_CMD 17 | |
707 | \& #define ENGINE_CTRL_GET_CMD_FLAGS 18 | |
708 | .Ve | |
8b0cefbb | 709 | .PP |
984263bc | 710 | Whilst these commands are automatically processed by the OpenSSL framework code, |
a561f9ff SS |
711 | they use various properties exposed by each \s-1ENGINE\s0 to process these |
712 | queries. An \s-1ENGINE\s0 has 3 properties it exposes that can affect how this behaves; | |
984263bc MD |
713 | it can supply a \fIctrl()\fR handler, it can specify \s-1ENGINE_FLAGS_MANUAL_CMD_CTRL\s0 in |
714 | the \s-1ENGINE\s0's flags, and it can expose an array of control command descriptions. | |
715 | If an \s-1ENGINE\s0 specifies the \s-1ENGINE_FLAGS_MANUAL_CMD_CTRL\s0 flag, then it will | |
716 | simply pass all these \*(L"core\*(R" control commands directly to the \s-1ENGINE\s0's \fIctrl()\fR | |
717 | handler (and thus, it must have supplied one), so it is up to the \s-1ENGINE\s0 to | |
718 | reply to these \*(L"discovery\*(R" commands itself. If that flag is not set, then the | |
719 | OpenSSL framework code will work with the following rules; | |
720 | .PP | |
721 | .Vb 9 | |
722 | \& if no ctrl() handler supplied; | |
723 | \& ENGINE_HAS_CTRL_FUNCTION returns FALSE (zero), | |
724 | \& all other commands fail. | |
725 | \& if a ctrl() handler was supplied but no array of control commands; | |
726 | \& ENGINE_HAS_CTRL_FUNCTION returns TRUE, | |
727 | \& all other commands fail. | |
728 | \& if a ctrl() handler and array of control commands was supplied; | |
729 | \& ENGINE_HAS_CTRL_FUNCTION returns TRUE, | |
730 | \& all other commands proceed processing ... | |
731 | .Ve | |
8b0cefbb | 732 | .PP |
984263bc MD |
733 | If the \s-1ENGINE\s0's array of control commands is empty then all other commands will |
734 | fail, otherwise; \s-1ENGINE_CTRL_GET_FIRST_CMD_TYPE\s0 returns the identifier of | |
735 | the first command supported by the \s-1ENGINE\s0, \s-1ENGINE_GET_NEXT_CMD_TYPE\s0 takes the | |
736 | identifier of a command supported by the \s-1ENGINE\s0 and returns the next command | |
737 | identifier or fails if there are no more, \s-1ENGINE_CMD_FROM_NAME\s0 takes a string | |
738 | name for a command and returns the corresponding identifier or fails if no such | |
739 | command name exists, and the remaining commands take a command identifier and | |
740 | return properties of the corresponding commands. All except | |
8b0cefbb | 741 | \&\s-1ENGINE_CTRL_GET_FLAGS\s0 return the string length of a command name or description, |
984263bc | 742 | or populate a supplied character buffer with a copy of the command name or |
aac4ff6f | 743 | description. \s-1ENGINE_CTRL_GET_FLAGS\s0 returns a bitwise\-OR'd mask of the following |
984263bc MD |
744 | possible values; |
745 | .PP | |
746 | .Vb 4 | |
747 | \& #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 | |
748 | \& #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 | |
749 | \& #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 | |
750 | \& #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 | |
751 | .Ve | |
8b0cefbb | 752 | .PP |
984263bc MD |
753 | If the \s-1ENGINE_CMD_FLAG_INTERNAL\s0 flag is set, then any other flags are purely |
754 | informational to the caller \- this flag will prevent the command being usable | |
755 | for any higher-level \s-1ENGINE\s0 functions such as \fIENGINE_ctrl_cmd_string()\fR. | |
8b0cefbb | 756 | \&\*(L"\s-1INTERNAL\s0\*(R" commands are not intended to be exposed to text-based configuration |
984263bc MD |
757 | by applications, administrations, users, etc. These can support arbitrary |
758 | operations via \fIENGINE_ctrl()\fR, including passing to and/or from the control | |
759 | commands data of any arbitrary type. These commands are supported in the | |
760 | discovery mechanisms simply to allow applications determinie if an \s-1ENGINE\s0 | |
761 | supports certain specific commands it might want to use (eg. application \*(L"foo\*(R" | |
762 | might query various ENGINEs to see if they implement \*(L"\s-1FOO_GET_VENDOR_LOGO_GIF\s0\*(R" \- | |
763 | and \s-1ENGINE\s0 could therefore decide whether or not to support this \*(L"foo\*(R"\-specific | |
764 | extension). | |
765 | .Sh "Future developments" | |
8b0cefbb | 766 | .IX Subsection "Future developments" |
984263bc MD |
767 | The \s-1ENGINE\s0 \s-1API\s0 and internal architecture is currently being reviewed. Slated for |
768 | possible release in 0.9.8 is support for transparent loading of \*(L"dynamic\*(R" | |
aac4ff6f PA |
769 | ENGINEs (built as self-contained shared\-libraries). This would allow \s-1ENGINE\s0 |
770 | implementations to be provided independently of OpenSSL libraries and/or | |
8b0cefbb | 771 | OpenSSL-based applications, and would also remove any requirement for |
984263bc MD |
772 | applications to explicitly use the \*(L"dynamic\*(R" \s-1ENGINE\s0 to bind to shared-library |
773 | implementations. | |
774 | .SH "SEE ALSO" | |
74dab6c2 | 775 | .IX Header "SEE ALSO" |
a561f9ff | 776 | \&\fIrsa\fR\|(3), \fIdsa\fR\|(3), \fIdh\fR\|(3), \fIrand\fR\|(3) |