diff options
Diffstat (limited to 'src/lib/libcrypto/doc/engine.pod')
-rw-r--r-- | src/lib/libcrypto/doc/engine.pod | 212 |
1 files changed, 95 insertions, 117 deletions
diff --git a/src/lib/libcrypto/doc/engine.pod b/src/lib/libcrypto/doc/engine.pod index c77dad5562..f5ab1c3e50 100644 --- a/src/lib/libcrypto/doc/engine.pod +++ b/src/lib/libcrypto/doc/engine.pod | |||
@@ -23,21 +23,26 @@ engine - ENGINE cryptographic module support | |||
23 | 23 | ||
24 | void ENGINE_load_openssl(void); | 24 | void ENGINE_load_openssl(void); |
25 | void ENGINE_load_dynamic(void); | 25 | void ENGINE_load_dynamic(void); |
26 | void ENGINE_load_cswift(void); | 26 | #ifndef OPENSSL_NO_STATIC_ENGINE |
27 | void ENGINE_load_chil(void); | 27 | void ENGINE_load_4758cca(void); |
28 | void ENGINE_load_aep(void); | ||
28 | void ENGINE_load_atalla(void); | 29 | void ENGINE_load_atalla(void); |
30 | void ENGINE_load_chil(void); | ||
31 | void ENGINE_load_cswift(void); | ||
32 | void ENGINE_load_gmp(void); | ||
29 | void ENGINE_load_nuron(void); | 33 | void ENGINE_load_nuron(void); |
30 | void ENGINE_load_ubsec(void); | ||
31 | void ENGINE_load_aep(void); | ||
32 | void ENGINE_load_sureware(void); | 34 | void ENGINE_load_sureware(void); |
33 | void ENGINE_load_4758cca(void); | 35 | void ENGINE_load_ubsec(void); |
34 | void ENGINE_load_openbsd_dev_crypto(void); | 36 | #endif |
37 | void ENGINE_load_cryptodev(void); | ||
35 | void ENGINE_load_builtin_engines(void); | 38 | void ENGINE_load_builtin_engines(void); |
36 | 39 | ||
37 | void ENGINE_cleanup(void); | 40 | void ENGINE_cleanup(void); |
38 | 41 | ||
39 | ENGINE *ENGINE_get_default_RSA(void); | 42 | ENGINE *ENGINE_get_default_RSA(void); |
40 | ENGINE *ENGINE_get_default_DSA(void); | 43 | ENGINE *ENGINE_get_default_DSA(void); |
44 | ENGINE *ENGINE_get_default_ECDH(void); | ||
45 | ENGINE *ENGINE_get_default_ECDSA(void); | ||
41 | ENGINE *ENGINE_get_default_DH(void); | 46 | ENGINE *ENGINE_get_default_DH(void); |
42 | ENGINE *ENGINE_get_default_RAND(void); | 47 | ENGINE *ENGINE_get_default_RAND(void); |
43 | ENGINE *ENGINE_get_cipher_engine(int nid); | 48 | ENGINE *ENGINE_get_cipher_engine(int nid); |
@@ -45,6 +50,8 @@ engine - ENGINE cryptographic module support | |||
45 | 50 | ||
46 | int ENGINE_set_default_RSA(ENGINE *e); | 51 | int ENGINE_set_default_RSA(ENGINE *e); |
47 | int ENGINE_set_default_DSA(ENGINE *e); | 52 | int ENGINE_set_default_DSA(ENGINE *e); |
53 | int ENGINE_set_default_ECDH(ENGINE *e); | ||
54 | int ENGINE_set_default_ECDSA(ENGINE *e); | ||
48 | int ENGINE_set_default_DH(ENGINE *e); | 55 | int ENGINE_set_default_DH(ENGINE *e); |
49 | int ENGINE_set_default_RAND(ENGINE *e); | 56 | int ENGINE_set_default_RAND(ENGINE *e); |
50 | int ENGINE_set_default_ciphers(ENGINE *e); | 57 | int ENGINE_set_default_ciphers(ENGINE *e); |
@@ -62,12 +69,21 @@ engine - ENGINE cryptographic module support | |||
62 | int ENGINE_register_DSA(ENGINE *e); | 69 | int ENGINE_register_DSA(ENGINE *e); |
63 | void ENGINE_unregister_DSA(ENGINE *e); | 70 | void ENGINE_unregister_DSA(ENGINE *e); |
64 | void ENGINE_register_all_DSA(void); | 71 | void ENGINE_register_all_DSA(void); |
72 | int ENGINE_register_ECDH(ENGINE *e); | ||
73 | void ENGINE_unregister_ECDH(ENGINE *e); | ||
74 | void ENGINE_register_all_ECDH(void); | ||
75 | int ENGINE_register_ECDSA(ENGINE *e); | ||
76 | void ENGINE_unregister_ECDSA(ENGINE *e); | ||
77 | void ENGINE_register_all_ECDSA(void); | ||
65 | int ENGINE_register_DH(ENGINE *e); | 78 | int ENGINE_register_DH(ENGINE *e); |
66 | void ENGINE_unregister_DH(ENGINE *e); | 79 | void ENGINE_unregister_DH(ENGINE *e); |
67 | void ENGINE_register_all_DH(void); | 80 | void ENGINE_register_all_DH(void); |
68 | int ENGINE_register_RAND(ENGINE *e); | 81 | int ENGINE_register_RAND(ENGINE *e); |
69 | void ENGINE_unregister_RAND(ENGINE *e); | 82 | void ENGINE_unregister_RAND(ENGINE *e); |
70 | void ENGINE_register_all_RAND(void); | 83 | void ENGINE_register_all_RAND(void); |
84 | int ENGINE_register_STORE(ENGINE *e); | ||
85 | void ENGINE_unregister_STORE(ENGINE *e); | ||
86 | void ENGINE_register_all_STORE(void); | ||
71 | int ENGINE_register_ciphers(ENGINE *e); | 87 | int ENGINE_register_ciphers(ENGINE *e); |
72 | void ENGINE_unregister_ciphers(ENGINE *e); | 88 | void ENGINE_unregister_ciphers(ENGINE *e); |
73 | void ENGINE_register_all_ciphers(void); | 89 | void ENGINE_register_all_ciphers(void); |
@@ -77,12 +93,12 @@ engine - ENGINE cryptographic module support | |||
77 | int ENGINE_register_complete(ENGINE *e); | 93 | int ENGINE_register_complete(ENGINE *e); |
78 | int ENGINE_register_all_complete(void); | 94 | int ENGINE_register_all_complete(void); |
79 | 95 | ||
80 | int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()); | 96 | int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); |
81 | int ENGINE_cmd_is_executable(ENGINE *e, int cmd); | 97 | int ENGINE_cmd_is_executable(ENGINE *e, int cmd); |
82 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, | 98 | int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, |
83 | long i, void *p, void (*f)(), int cmd_optional); | 99 | long i, void *p, void (*f)(void), int cmd_optional); |
84 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, | 100 | int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, |
85 | int cmd_optional); | 101 | int cmd_optional); |
86 | 102 | ||
87 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); | 103 | int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); |
88 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); | 104 | void *ENGINE_get_ex_data(const ENGINE *e, int idx); |
@@ -92,13 +108,17 @@ engine - ENGINE cryptographic module support | |||
92 | 108 | ||
93 | ENGINE *ENGINE_new(void); | 109 | ENGINE *ENGINE_new(void); |
94 | int ENGINE_free(ENGINE *e); | 110 | int ENGINE_free(ENGINE *e); |
111 | int ENGINE_up_ref(ENGINE *e); | ||
95 | 112 | ||
96 | int ENGINE_set_id(ENGINE *e, const char *id); | 113 | int ENGINE_set_id(ENGINE *e, const char *id); |
97 | int ENGINE_set_name(ENGINE *e, const char *name); | 114 | int ENGINE_set_name(ENGINE *e, const char *name); |
98 | int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); | 115 | int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); |
99 | int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); | 116 | int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); |
117 | int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *dh_meth); | ||
118 | int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *dh_meth); | ||
100 | int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); | 119 | int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); |
101 | int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); | 120 | int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); |
121 | int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *rand_meth); | ||
102 | int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); | 122 | int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); |
103 | int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); | 123 | int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); |
104 | int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); | 124 | int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); |
@@ -114,8 +134,11 @@ engine - ENGINE cryptographic module support | |||
114 | const char *ENGINE_get_name(const ENGINE *e); | 134 | const char *ENGINE_get_name(const ENGINE *e); |
115 | const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); | 135 | const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); |
116 | const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); | 136 | const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); |
137 | const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); | ||
138 | const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); | ||
117 | const DH_METHOD *ENGINE_get_DH(const ENGINE *e); | 139 | const DH_METHOD *ENGINE_get_DH(const ENGINE *e); |
118 | const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); | 140 | const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); |
141 | const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); | ||
119 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); | 142 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); |
120 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); | 143 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); |
121 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); | 144 | ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); |
@@ -148,7 +171,8 @@ The cryptographic functionality that can be provided by an B<ENGINE> | |||
148 | implementation includes the following abstractions; | 171 | implementation includes the following abstractions; |
149 | 172 | ||
150 | RSA_METHOD - for providing alternative RSA implementations | 173 | RSA_METHOD - for providing alternative RSA implementations |
151 | DSA_METHOD, DH_METHOD, RAND_METHOD - alternative DSA, DH, and RAND | 174 | DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD, |
175 | STORE_METHOD - similarly for other OpenSSL APIs | ||
152 | EVP_CIPHER - potentially multiple cipher algorithms (indexed by 'nid') | 176 | EVP_CIPHER - potentially multiple cipher algorithms (indexed by 'nid') |
153 | EVP_DIGEST - potentially multiple hash algorithms (indexed by 'nid') | 177 | EVP_DIGEST - potentially multiple hash algorithms (indexed by 'nid') |
154 | key-loading - loading public and/or private EVP_PKEY keys | 178 | key-loading - loading public and/or private EVP_PKEY keys |
@@ -157,52 +181,45 @@ implementation includes the following abstractions; | |||
157 | 181 | ||
158 | Due to the modular nature of the ENGINE API, pointers to ENGINEs need to be | 182 | Due to the modular nature of the ENGINE API, pointers to ENGINEs need to be |
159 | treated as handles - ie. not only as pointers, but also as references to | 183 | treated as handles - ie. not only as pointers, but also as references to |
160 | the underlying ENGINE object. Ie. you should obtain a new reference when | 184 | the underlying ENGINE object. Ie. one should obtain a new reference when |
161 | making copies of an ENGINE pointer if the copies will be used (and | 185 | making copies of an ENGINE pointer if the copies will be used (and |
162 | released) independantly. | 186 | released) independently. |
163 | 187 | ||
164 | ENGINE objects have two levels of reference-counting to match the way in | 188 | ENGINE objects have two levels of reference-counting to match the way in |
165 | which the objects are used. At the most basic level, each ENGINE pointer is | 189 | which the objects are used. At the most basic level, each ENGINE pointer is |
166 | inherently a B<structural> reference - you need a structural reference | 190 | inherently a B<structural> reference - a structural reference is required |
167 | simply to refer to the pointer value at all, as this kind of reference is | 191 | to use the pointer value at all, as this kind of reference is a guarantee |
168 | your guarantee that the structure can not be deallocated until you release | 192 | that the structure can not be deallocated until the reference is released. |
169 | your reference. | 193 | |
170 | 194 | However, a structural reference provides no guarantee that the ENGINE is | |
171 | However, a structural reference provides no guarantee that the ENGINE has | 195 | initiliased and able to use any of its cryptographic |
172 | been initiliased to be usable to perform any of its cryptographic | 196 | implementations. Indeed it's quite possible that most ENGINEs will not |
173 | implementations - and indeed it's quite possible that most ENGINEs will not | 197 | initialise at all in typical environments, as ENGINEs are typically used to |
174 | initialised at all on standard setups, as ENGINEs are typically used to | ||
175 | support specialised hardware. To use an ENGINE's functionality, you need a | 198 | support specialised hardware. To use an ENGINE's functionality, you need a |
176 | B<functional> reference. This kind of reference can be considered a | 199 | B<functional> reference. This kind of reference can be considered a |
177 | specialised form of structural reference, because each functional reference | 200 | specialised form of structural reference, because each functional reference |
178 | implicitly contains a structural reference as well - however to avoid | 201 | implicitly contains a structural reference as well - however to avoid |
179 | difficult-to-find programming bugs, it is recommended to treat the two | 202 | difficult-to-find programming bugs, it is recommended to treat the two |
180 | kinds of reference independantly. If you have a functional reference to an | 203 | kinds of reference independently. If you have a functional reference to an |
181 | ENGINE, you have a guarantee that the ENGINE has been initialised ready to | 204 | ENGINE, you have a guarantee that the ENGINE has been initialised ready to |
182 | perform cryptographic operations and will not be uninitialised or cleaned | 205 | perform cryptographic operations and will remain uninitialised |
183 | up until after you have released your reference. | 206 | until after you have released your reference. |
184 | |||
185 | We will discuss the two kinds of reference separately, including how to | ||
186 | tell which one you are dealing with at any given point in time (after all | ||
187 | they are both simply (ENGINE *) pointers, the difference is in the way they | ||
188 | are used). | ||
189 | 207 | ||
190 | I<Structural references> | 208 | I<Structural references> |
191 | 209 | ||
192 | This basic type of reference is typically used for creating new ENGINEs | 210 | This basic type of reference is used for instantiating new ENGINEs, |
193 | dynamically, iterating across OpenSSL's internal linked-list of loaded | 211 | iterating across OpenSSL's internal linked-list of loaded |
194 | ENGINEs, reading information about an ENGINE, etc. Essentially a structural | 212 | ENGINEs, reading information about an ENGINE, etc. Essentially a structural |
195 | reference is sufficient if you only need to query or manipulate the data of | 213 | reference is sufficient if you only need to query or manipulate the data of |
196 | an ENGINE implementation rather than use its functionality. | 214 | an ENGINE implementation rather than use its functionality. |
197 | 215 | ||
198 | The ENGINE_new() function returns a structural reference to a new (empty) | 216 | The ENGINE_new() function returns a structural reference to a new (empty) |
199 | ENGINE object. Other than that, structural references come from return | 217 | ENGINE object. There are other ENGINE API functions that return structural |
200 | values to various ENGINE API functions such as; ENGINE_by_id(), | 218 | references such as; ENGINE_by_id(), ENGINE_get_first(), ENGINE_get_last(), |
201 | ENGINE_get_first(), ENGINE_get_last(), ENGINE_get_next(), | 219 | ENGINE_get_next(), ENGINE_get_prev(). All structural references should be |
202 | ENGINE_get_prev(). All structural references should be released by a | 220 | released by a corresponding to call to the ENGINE_free() function - the |
203 | corresponding to call to the ENGINE_free() function - the ENGINE object | 221 | ENGINE object itself will only actually be cleaned up and deallocated when |
204 | itself will only actually be cleaned up and deallocated when the last | 222 | the last structural reference is released. |
205 | structural reference is released. | ||
206 | 223 | ||
207 | It should also be noted that many ENGINE API function calls that accept a | 224 | It should also be noted that many ENGINE API function calls that accept a |
208 | structural reference will internally obtain another reference - typically | 225 | structural reference will internally obtain another reference - typically |
@@ -237,15 +254,9 @@ call the ENGINE_init() function. This returns zero if the ENGINE was not | |||
237 | already operational and couldn't be successfully initialised (eg. lack of | 254 | already operational and couldn't be successfully initialised (eg. lack of |
238 | system drivers, no special hardware attached, etc), otherwise it will | 255 | system drivers, no special hardware attached, etc), otherwise it will |
239 | return non-zero to indicate that the ENGINE is now operational and will | 256 | return non-zero to indicate that the ENGINE is now operational and will |
240 | have allocated a new B<functional> reference to the ENGINE. In this case, | 257 | have allocated a new B<functional> reference to the ENGINE. All functional |
241 | the supplied ENGINE pointer is, from the point of the view of the caller, | 258 | references are released by calling ENGINE_finish() (which removes the |
242 | both a structural reference and a functional reference - so if the caller | 259 | implicit structural reference as well). |
243 | intends to use it as a functional reference it should free the structural | ||
244 | reference with ENGINE_free() first. If the caller wishes to use it only as | ||
245 | a structural reference (eg. if the ENGINE_init() call was simply to test if | ||
246 | the ENGINE seems available/online), then it should free the functional | ||
247 | reference; all functional references are released by the ENGINE_finish() | ||
248 | function. | ||
249 | 260 | ||
250 | The second way to get a functional reference is by asking OpenSSL for a | 261 | The second way to get a functional reference is by asking OpenSSL for a |
251 | default implementation for a given task, eg. by ENGINE_get_default_RSA(), | 262 | default implementation for a given task, eg. by ENGINE_get_default_RSA(), |
@@ -259,26 +270,21 @@ algorithm-specific types in OpenSSL, such as RSA, DSA, EVP_CIPHER_CTX, etc. | |||
259 | For each supported abstraction, the ENGINE code maintains an internal table | 270 | For each supported abstraction, the ENGINE code maintains an internal table |
260 | of state to control which implementations are available for a given | 271 | of state to control which implementations are available for a given |
261 | abstraction and which should be used by default. These implementations are | 272 | abstraction and which should be used by default. These implementations are |
262 | registered in the tables separated-out by an 'nid' index, because | 273 | registered in the tables and indexed by an 'nid' value, because |
263 | abstractions like EVP_CIPHER and EVP_DIGEST support many distinct | 274 | abstractions like EVP_CIPHER and EVP_DIGEST support many distinct |
264 | algorithms and modes - ENGINEs will support different numbers and | 275 | algorithms and modes, and ENGINEs can support arbitrarily many of them. |
265 | combinations of these. In the case of other abstractions like RSA, DSA, | 276 | In the case of other abstractions like RSA, DSA, etc, there is only one |
266 | etc, there is only one "algorithm" so all implementations implicitly | 277 | "algorithm" so all implementations implicitly register using the same 'nid' |
267 | register using the same 'nid' index. ENGINEs can be B<registered> into | 278 | index. |
268 | these tables to make themselves available for use automatically by the | 279 | |
269 | various abstractions, eg. RSA. For illustrative purposes, we continue with | 280 | When a default ENGINE is requested for a given abstraction/algorithm/mode, (eg. |
270 | the RSA example, though all comments apply similarly to the other | 281 | when calling RSA_new_method(NULL)), a "get_default" call will be made to the |
271 | abstractions (they each get their own table and linkage to the | 282 | ENGINE subsystem to process the corresponding state table and return a |
272 | corresponding section of openssl code). | 283 | functional reference to an initialised ENGINE whose implementation should be |
273 | 284 | used. If no ENGINE should (or can) be used, it will return NULL and the caller | |
274 | When a new RSA key is being created, ie. in RSA_new_method(), a | 285 | will operate with a NULL ENGINE handle - this usually equates to using the |
275 | "get_default" call will be made to the ENGINE subsystem to process the RSA | 286 | conventional software implementation. In the latter case, OpenSSL will from |
276 | state table and return a functional reference to an initialised ENGINE | 287 | then on behave the way it used to before the ENGINE API existed. |
277 | whose RSA_METHOD should be used. If no ENGINE should (or can) be used, it | ||
278 | will return NULL and the RSA key will operate with a NULL ENGINE handle by | ||
279 | using the conventional RSA implementation in OpenSSL (and will from then on | ||
280 | behave the way it used to before the ENGINE API existed - for details see | ||
281 | L<RSA_new_method(3)|RSA_new_method(3)>). | ||
282 | 288 | ||
283 | Each state table has a flag to note whether it has processed this | 289 | Each state table has a flag to note whether it has processed this |
284 | "get_default" query since the table was last modified, because to process | 290 | "get_default" query since the table was last modified, because to process |
@@ -295,36 +301,9 @@ instead the only way for the state table to return a non-NULL ENGINE to the | |||
295 | "get_default" query will be if one is expressly set in the table. Eg. | 301 | "get_default" query will be if one is expressly set in the table. Eg. |
296 | ENGINE_set_default_RSA() does the same job as ENGINE_register_RSA() except | 302 | ENGINE_set_default_RSA() does the same job as ENGINE_register_RSA() except |
297 | that it also sets the state table's cached response for the "get_default" | 303 | that it also sets the state table's cached response for the "get_default" |
298 | query. | 304 | query. In the case of abstractions like EVP_CIPHER, where implementations are |
299 | 305 | indexed by 'nid', these flags and cached-responses are distinct for each 'nid' | |
300 | In the case of abstractions like EVP_CIPHER, where implementations are | 306 | value. |
301 | indexed by 'nid', these flags and cached-responses are distinct for each | ||
302 | 'nid' value. | ||
303 | |||
304 | It is worth illustrating the difference between "registration" of ENGINEs | ||
305 | into these per-algorithm state tables and using the alternative | ||
306 | "set_default" functions. The latter handles both "registration" and also | ||
307 | setting the cached "default" ENGINE in each relevant state table - so | ||
308 | registered ENGINEs will only have a chance to be initialised for use as a | ||
309 | default if a default ENGINE wasn't already set for the same state table. | ||
310 | Eg. if ENGINE X supports cipher nids {A,B} and RSA, ENGINE Y supports | ||
311 | ciphers {A} and DSA, and the following code is executed; | ||
312 | |||
313 | ENGINE_register_complete(X); | ||
314 | ENGINE_set_default(Y, ENGINE_METHOD_ALL); | ||
315 | e1 = ENGINE_get_default_RSA(); | ||
316 | e2 = ENGINE_get_cipher_engine(A); | ||
317 | e3 = ENGINE_get_cipher_engine(B); | ||
318 | e4 = ENGINE_get_default_DSA(); | ||
319 | e5 = ENGINE_get_cipher_engine(C); | ||
320 | |||
321 | The results would be as follows; | ||
322 | |||
323 | assert(e1 == X); | ||
324 | assert(e2 == Y); | ||
325 | assert(e3 == X); | ||
326 | assert(e4 == Y); | ||
327 | assert(e5 == NULL); | ||
328 | 307 | ||
329 | =head2 Application requirements | 308 | =head2 Application requirements |
330 | 309 | ||
@@ -360,7 +339,7 @@ mention an important API function; | |||
360 | 339 | ||
361 | If no ENGINE API functions are called at all in an application, then there | 340 | If no ENGINE API functions are called at all in an application, then there |
362 | are no inherent memory leaks to worry about from the ENGINE functionality, | 341 | are no inherent memory leaks to worry about from the ENGINE functionality, |
363 | however if any ENGINEs are "load"ed, even if they are never registered or | 342 | however if any ENGINEs are loaded, even if they are never registered or |
364 | used, it is necessary to use the ENGINE_cleanup() function to | 343 | used, it is necessary to use the ENGINE_cleanup() function to |
365 | correspondingly cleanup before program exit, if the caller wishes to avoid | 344 | correspondingly cleanup before program exit, if the caller wishes to avoid |
366 | memory leaks. This mechanism uses an internal callback registration table | 345 | memory leaks. This mechanism uses an internal callback registration table |
@@ -375,7 +354,7 @@ linker. | |||
375 | The fact that ENGINEs are made visible to OpenSSL (and thus are linked into | 354 | The fact that ENGINEs are made visible to OpenSSL (and thus are linked into |
376 | the program and loaded into memory at run-time) does not mean they are | 355 | the program and loaded into memory at run-time) does not mean they are |
377 | "registered" or called into use by OpenSSL automatically - that behaviour | 356 | "registered" or called into use by OpenSSL automatically - that behaviour |
378 | is something for the application to have control over. Some applications | 357 | is something for the application to control. Some applications |
379 | will want to allow the user to specify exactly which ENGINE they want used | 358 | will want to allow the user to specify exactly which ENGINE they want used |
380 | if any is to be used at all. Others may prefer to load all support and have | 359 | if any is to be used at all. Others may prefer to load all support and have |
381 | OpenSSL automatically use at run-time any ENGINE that is able to | 360 | OpenSSL automatically use at run-time any ENGINE that is able to |
@@ -433,7 +412,7 @@ it should be used. The following code illustrates how this can work; | |||
433 | That's all that's required. Eg. the next time OpenSSL tries to set up an | 412 | That's all that's required. Eg. the next time OpenSSL tries to set up an |
434 | RSA key, any bundled ENGINEs that implement RSA_METHOD will be passed to | 413 | RSA key, any bundled ENGINEs that implement RSA_METHOD will be passed to |
435 | ENGINE_init() and if any of those succeed, that ENGINE will be set as the | 414 | ENGINE_init() and if any of those succeed, that ENGINE will be set as the |
436 | default for use with RSA from then on. | 415 | default for RSA use from then on. |
437 | 416 | ||
438 | =head2 Advanced configuration support | 417 | =head2 Advanced configuration support |
439 | 418 | ||
@@ -441,7 +420,7 @@ There is a mechanism supported by the ENGINE framework that allows each | |||
441 | ENGINE implementation to define an arbitrary set of configuration | 420 | ENGINE implementation to define an arbitrary set of configuration |
442 | "commands" and expose them to OpenSSL and any applications based on | 421 | "commands" and expose them to OpenSSL and any applications based on |
443 | OpenSSL. This mechanism is entirely based on the use of name-value pairs | 422 | OpenSSL. This mechanism is entirely based on the use of name-value pairs |
444 | and and assumes ASCII input (no unicode or UTF for now!), so it is ideal if | 423 | and assumes ASCII input (no unicode or UTF for now!), so it is ideal if |
445 | applications want to provide a transparent way for users to provide | 424 | applications want to provide a transparent way for users to provide |
446 | arbitrary configuration "directives" directly to such ENGINEs. It is also | 425 | arbitrary configuration "directives" directly to such ENGINEs. It is also |
447 | possible for the application to dynamically interrogate the loaded ENGINE | 426 | possible for the application to dynamically interrogate the loaded ENGINE |
@@ -450,8 +429,8 @@ available "control commands", providing a more flexible configuration | |||
450 | scheme. However, if the user is expected to know which ENGINE device he/she | 429 | scheme. However, if the user is expected to know which ENGINE device he/she |
451 | is using (in the case of specialised hardware, this goes without saying) | 430 | is using (in the case of specialised hardware, this goes without saying) |
452 | then applications may not need to concern themselves with discovering the | 431 | then applications may not need to concern themselves with discovering the |
453 | supported control commands and simply prefer to allow settings to passed | 432 | supported control commands and simply prefer to pass settings into ENGINEs |
454 | into ENGINEs exactly as they are provided by the user. | 433 | exactly as they are provided by the user. |
455 | 434 | ||
456 | Before illustrating how control commands work, it is worth mentioning what | 435 | Before illustrating how control commands work, it is worth mentioning what |
457 | they are typically used for. Broadly speaking there are two uses for | 436 | they are typically used for. Broadly speaking there are two uses for |
@@ -459,13 +438,13 @@ control commands; the first is to provide the necessary details to the | |||
459 | implementation (which may know nothing at all specific to the host system) | 438 | implementation (which may know nothing at all specific to the host system) |
460 | so that it can be initialised for use. This could include the path to any | 439 | so that it can be initialised for use. This could include the path to any |
461 | driver or config files it needs to load, required network addresses, | 440 | driver or config files it needs to load, required network addresses, |
462 | smart-card identifiers, passwords to initialise password-protected devices, | 441 | smart-card identifiers, passwords to initialise protected devices, |
463 | logging information, etc etc. This class of commands typically needs to be | 442 | logging information, etc etc. This class of commands typically needs to be |
464 | passed to an ENGINE B<before> attempting to initialise it, ie. before | 443 | passed to an ENGINE B<before> attempting to initialise it, ie. before |
465 | calling ENGINE_init(). The other class of commands consist of settings or | 444 | calling ENGINE_init(). The other class of commands consist of settings or |
466 | operations that tweak certain behaviour or cause certain operations to take | 445 | operations that tweak certain behaviour or cause certain operations to take |
467 | place, and these commands may work either before or after ENGINE_init(), or | 446 | place, and these commands may work either before or after ENGINE_init(), or |
468 | in same cases both. ENGINE implementations should provide indications of | 447 | in some cases both. ENGINE implementations should provide indications of |
469 | this in the descriptions attached to builtin control commands and/or in | 448 | this in the descriptions attached to builtin control commands and/or in |
470 | external product documentation. | 449 | external product documentation. |
471 | 450 | ||
@@ -529,14 +508,14 @@ FALSE. | |||
529 | I<Discovering supported control commands> | 508 | I<Discovering supported control commands> |
530 | 509 | ||
531 | It is possible to discover at run-time the names, numerical-ids, descriptions | 510 | It is possible to discover at run-time the names, numerical-ids, descriptions |
532 | and input parameters of the control commands supported from a structural | 511 | and input parameters of the control commands supported by an ENGINE using a |
533 | reference to any ENGINE. It is first important to note that some control | 512 | structural reference. Note that some control commands are defined by OpenSSL |
534 | commands are defined by OpenSSL itself and it will intercept and handle these | 513 | itself and it will intercept and handle these control commands on behalf of the |
535 | control commands on behalf of the ENGINE, ie. the ENGINE's ctrl() handler is not | 514 | ENGINE, ie. the ENGINE's ctrl() handler is not used for the control command. |
536 | used for the control command. openssl/engine.h defines a symbol, | 515 | openssl/engine.h defines an index, ENGINE_CMD_BASE, that all control commands |
537 | ENGINE_CMD_BASE, that all control commands implemented by ENGINEs from. Any | 516 | implemented by ENGINEs should be numbered from. Any command value lower than |
538 | command value lower than this symbol is considered a "generic" command is | 517 | this symbol is considered a "generic" command is handled directly by the |
539 | handled directly by the OpenSSL core routines. | 518 | OpenSSL core routines. |
540 | 519 | ||
541 | It is using these "core" control commands that one can discover the the control | 520 | It is using these "core" control commands that one can discover the the control |
542 | commands implemented by a given ENGINE, specifically the commands; | 521 | commands implemented by a given ENGINE, specifically the commands; |
@@ -552,8 +531,8 @@ commands implemented by a given ENGINE, specifically the commands; | |||
552 | #define ENGINE_CTRL_GET_CMD_FLAGS 18 | 531 | #define ENGINE_CTRL_GET_CMD_FLAGS 18 |
553 | 532 | ||
554 | Whilst these commands are automatically processed by the OpenSSL framework code, | 533 | Whilst these commands are automatically processed by the OpenSSL framework code, |
555 | they use various properties exposed by each ENGINE by which to process these | 534 | they use various properties exposed by each ENGINE to process these |
556 | queries. An ENGINE has 3 properties it exposes that can affect this behaviour; | 535 | queries. An ENGINE has 3 properties it exposes that can affect how this behaves; |
557 | it can supply a ctrl() handler, it can specify ENGINE_FLAGS_MANUAL_CMD_CTRL in | 536 | it can supply a ctrl() handler, it can specify ENGINE_FLAGS_MANUAL_CMD_CTRL in |
558 | the ENGINE's flags, and it can expose an array of control command descriptions. | 537 | the ENGINE's flags, and it can expose an array of control command descriptions. |
559 | If an ENGINE specifies the ENGINE_FLAGS_MANUAL_CMD_CTRL flag, then it will | 538 | If an ENGINE specifies the ENGINE_FLAGS_MANUAL_CMD_CTRL flag, then it will |
@@ -608,14 +587,13 @@ extension). | |||
608 | The ENGINE API and internal architecture is currently being reviewed. Slated for | 587 | The ENGINE API and internal architecture is currently being reviewed. Slated for |
609 | possible release in 0.9.8 is support for transparent loading of "dynamic" | 588 | possible release in 0.9.8 is support for transparent loading of "dynamic" |
610 | ENGINEs (built as self-contained shared-libraries). This would allow ENGINE | 589 | ENGINEs (built as self-contained shared-libraries). This would allow ENGINE |
611 | implementations to be provided independantly of OpenSSL libraries and/or | 590 | implementations to be provided independently of OpenSSL libraries and/or |
612 | OpenSSL-based applications, and would also remove any requirement for | 591 | OpenSSL-based applications, and would also remove any requirement for |
613 | applications to explicitly use the "dynamic" ENGINE to bind to shared-library | 592 | applications to explicitly use the "dynamic" ENGINE to bind to shared-library |
614 | implementations. | 593 | implementations. |
615 | 594 | ||
616 | =head1 SEE ALSO | 595 | =head1 SEE ALSO |
617 | 596 | ||
618 | L<rsa(3)|rsa(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>, L<rand(3)|rand(3)>, | 597 | L<rsa(3)|rsa(3)>, L<dsa(3)|dsa(3)>, L<dh(3)|dh(3)>, L<rand(3)|rand(3)> |
619 | L<RSA_new_method(3)|RSA_new_method(3)> | ||
620 | 598 | ||
621 | =cut | 599 | =cut |