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