diff options
Diffstat (limited to 'src/lib/libcrypto/man/engine.3')
| -rw-r--r-- | src/lib/libcrypto/man/engine.3 | 1187 |
1 files changed, 1187 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/engine.3 b/src/lib/libcrypto/man/engine.3 new file mode 100644 index 0000000000..3624fa76e4 --- /dev/null +++ b/src/lib/libcrypto/man/engine.3 | |||
| @@ -0,0 +1,1187 @@ | |||
| 1 | .Dd $Mdocdate: November 5 2016 $ | ||
| 2 | .Dt ENGINE 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm ENGINE_add , | ||
| 6 | .Nm ENGINE_by_id , | ||
| 7 | .Nm ENGINE_finish , | ||
| 8 | .Nm ENGINE_get_first , | ||
| 9 | .Nm ENGINE_get_last , | ||
| 10 | .Nm ENGINE_get_next , | ||
| 11 | .Nm ENGINE_get_prev , | ||
| 12 | .Nm ENGINE_init , | ||
| 13 | .Nm ENGINE_load_builtin_engines , | ||
| 14 | .Nm ENGINE_remove | ||
| 15 | .Nd ENGINE cryptographic module support | ||
| 16 | .Sh SYNOPSIS | ||
| 17 | .In openssl/engine.h | ||
| 18 | .Ft ENGINE * | ||
| 19 | .Fn ENGINE_get_first void | ||
| 20 | .Ft ENGINE * | ||
| 21 | .Fn ENGINE_get_last void | ||
| 22 | .Ft ENGINE * | ||
| 23 | .Fo ENGINE_get_next | ||
| 24 | .Fa "ENGINE *e" | ||
| 25 | .Fc | ||
| 26 | .Ft ENGINE * | ||
| 27 | .Fo ENGINE_get_prev | ||
| 28 | .Fa "ENGINE *e" | ||
| 29 | .Fc | ||
| 30 | .Ft int | ||
| 31 | .Fo ENGINE_add | ||
| 32 | .Fa "ENGINE *e" | ||
| 33 | .Fc | ||
| 34 | .Ft int | ||
| 35 | .Fo ENGINE_remove | ||
| 36 | .Fa "ENGINE *e" | ||
| 37 | .Fc | ||
| 38 | .Ft ENGINE * | ||
| 39 | .Fo ENGINE_by_id | ||
| 40 | .Fa "const char *id" | ||
| 41 | .Fc | ||
| 42 | .Ft int | ||
| 43 | .Fo ENGINE_init | ||
| 44 | .Fa "ENGINE *e" | ||
| 45 | .Fc | ||
| 46 | .Ft int | ||
| 47 | .Fo ENGINE_finish | ||
| 48 | .Fa "ENGINE *e" | ||
| 49 | .Fc | ||
| 50 | .Ft void | ||
| 51 | .Fn ENGINE_load_openssl void | ||
| 52 | .Ft void | ||
| 53 | .Fn ENGINE_load_dynamic void | ||
| 54 | .Ft void | ||
| 55 | .Fn ENGINE_load_cryptodev void | ||
| 56 | .Ft void | ||
| 57 | .Fn ENGINE_load_builtin_engines void | ||
| 58 | .Ft void | ||
| 59 | .Fn ENGINE_cleanup void | ||
| 60 | .Ft ENGINE * | ||
| 61 | .Fn ENGINE_get_default_RSA void | ||
| 62 | .Ft ENGINE * | ||
| 63 | .Fn ENGINE_get_default_DSA void | ||
| 64 | .Ft ENGINE * | ||
| 65 | .Fn ENGINE_get_default_ECDH void | ||
| 66 | .Ft ENGINE * | ||
| 67 | .Fn ENGINE_get_default_ECDSA void | ||
| 68 | .Ft ENGINE * | ||
| 69 | .Fn ENGINE_get_default_DH void | ||
| 70 | .Ft ENGINE * | ||
| 71 | .Fn ENGINE_get_default_RAND void | ||
| 72 | .Ft ENGINE * | ||
| 73 | .Fo ENGINE_get_cipher_engine | ||
| 74 | .Fa "int nid" | ||
| 75 | .Fc | ||
| 76 | .Ft ENGINE * | ||
| 77 | .Fo ENGINE_get_digest_engine | ||
| 78 | .Fa "int nid" | ||
| 79 | .Fc | ||
| 80 | .Ft int | ||
| 81 | .Fo ENGINE_set_default_RSA | ||
| 82 | .Fa "ENGINE *e" | ||
| 83 | .Fc | ||
| 84 | .Ft int | ||
| 85 | .Fo ENGINE_set_default_DSA | ||
| 86 | .Fa "ENGINE *e" | ||
| 87 | .Fc | ||
| 88 | .Ft int | ||
| 89 | .Fo ENGINE_set_default_ECDH | ||
| 90 | .Fa "ENGINE *e" | ||
| 91 | .Fc | ||
| 92 | .Ft int | ||
| 93 | .Fo ENGINE_set_default_ECDSA | ||
| 94 | .Fa "ENGINE *e" | ||
| 95 | .Fc | ||
| 96 | .Ft int | ||
| 97 | .Fo ENGINE_set_default_DH | ||
| 98 | .Fa "ENGINE *e" | ||
| 99 | .Fc | ||
| 100 | .Ft int | ||
| 101 | .Fo ENGINE_set_default_RAND | ||
| 102 | .Fa "ENGINE *e" | ||
| 103 | .Fc | ||
| 104 | .Ft int | ||
| 105 | .Fo ENGINE_set_default_ciphers | ||
| 106 | .Fa "ENGINE *e" | ||
| 107 | .Fc | ||
| 108 | .Ft int | ||
| 109 | .Fo ENGINE_set_default_digests | ||
| 110 | .Fa "ENGINE *e" | ||
| 111 | .Fc | ||
| 112 | .Ft int | ||
| 113 | .Fo ENGINE_set_default_string | ||
| 114 | .Fa "ENGINE *e" | ||
| 115 | .Fa "const char *list" | ||
| 116 | .Fc | ||
| 117 | .Ft int | ||
| 118 | .Fo ENGINE_set_default | ||
| 119 | .Fa "ENGINE *e" | ||
| 120 | .Fa "unsigned int flags" | ||
| 121 | .Fc | ||
| 122 | .Ft unsigned int | ||
| 123 | .Fn ENGINE_get_table_flags void | ||
| 124 | .Ft void | ||
| 125 | .Fo ENGINE_set_table_flags | ||
| 126 | .Fa "unsigned int flags" | ||
| 127 | .Fc | ||
| 128 | .Ft int | ||
| 129 | .Fo ENGINE_register_RSA | ||
| 130 | .Fa "ENGINE *e" | ||
| 131 | .Fc | ||
| 132 | .Ft void | ||
| 133 | .Fo ENGINE_unregister_RSA | ||
| 134 | .Fa "ENGINE *e" | ||
| 135 | .Fc | ||
| 136 | .Ft void | ||
| 137 | .Fn ENGINE_register_all_RSA void | ||
| 138 | .Ft int | ||
| 139 | .Fo ENGINE_register_DSA | ||
| 140 | .Fa "ENGINE *e" | ||
| 141 | .Fc | ||
| 142 | .Ft void | ||
| 143 | .Fo ENGINE_unregister_DSA | ||
| 144 | .Fa "ENGINE *e" | ||
| 145 | .Fc | ||
| 146 | .Ft void | ||
| 147 | .Fn ENGINE_register_all_DSA void | ||
| 148 | .Ft int | ||
| 149 | .Fo ENGINE_register_ECDH | ||
| 150 | .Fa "ENGINE *e" | ||
| 151 | .Fc | ||
| 152 | .Ft void | ||
| 153 | .Fo ENGINE_unregister_ECDH | ||
| 154 | .Fa "ENGINE *e" | ||
| 155 | .Fc | ||
| 156 | .Ft void | ||
| 157 | .Fn ENGINE_register_all_ECDH void | ||
| 158 | .Ft int | ||
| 159 | .Fo ENGINE_register_ECDSA | ||
| 160 | .Fa "ENGINE *e" | ||
| 161 | .Fc | ||
| 162 | .Ft void | ||
| 163 | .Fo ENGINE_unregister_ECDSA | ||
| 164 | .Fa "ENGINE *e" | ||
| 165 | .Fc | ||
| 166 | .Ft void | ||
| 167 | .Fn ENGINE_register_all_ECDSA void | ||
| 168 | .Ft int | ||
| 169 | .Fo ENGINE_register_DH | ||
| 170 | .Fa "ENGINE *e" | ||
| 171 | .Fc | ||
| 172 | .Ft void | ||
| 173 | .Fo ENGINE_unregister_DH | ||
| 174 | .Fa "ENGINE *e" | ||
| 175 | .Fc | ||
| 176 | .Ft void | ||
| 177 | .Fn ENGINE_register_all_DH void | ||
| 178 | .Ft int | ||
| 179 | .Fo ENGINE_register_RAND | ||
| 180 | .Fa "ENGINE *e" | ||
| 181 | .Fc | ||
| 182 | .Ft void | ||
| 183 | .Fo ENGINE_unregister_RAND | ||
| 184 | .Fa "ENGINE *e" | ||
| 185 | .Fc | ||
| 186 | .Ft void | ||
| 187 | .Fn ENGINE_register_all_RAND void | ||
| 188 | .Ft int | ||
| 189 | .Fo ENGINE_register_STORE | ||
| 190 | .Fa "ENGINE *e" | ||
| 191 | .Fc | ||
| 192 | .Ft void | ||
| 193 | .Fo ENGINE_unregister_STORE | ||
| 194 | .Fa "ENGINE *e" | ||
| 195 | .Fc | ||
| 196 | .Ft void | ||
| 197 | .Fn ENGINE_register_all_STORE void | ||
| 198 | .Ft int | ||
| 199 | .Fo ENGINE_register_ciphers | ||
| 200 | .Fa "ENGINE *e" | ||
| 201 | .Fc | ||
| 202 | .Ft void | ||
| 203 | .Fo ENGINE_unregister_ciphers | ||
| 204 | .Fa "ENGINE *e" | ||
| 205 | .Fc | ||
| 206 | .Ft void | ||
| 207 | .Fn ENGINE_register_all_ciphers void | ||
| 208 | .Ft int | ||
| 209 | .Fo ENGINE_register_digests | ||
| 210 | .Fa "ENGINE *e" | ||
| 211 | .Fc | ||
| 212 | .Ft void | ||
| 213 | .Fo ENGINE_unregister_digests | ||
| 214 | .Fa "ENGINE *e" | ||
| 215 | .Fc | ||
| 216 | .Ft void | ||
| 217 | .Fn ENGINE_register_all_digests void | ||
| 218 | .Ft int | ||
| 219 | .Fo ENGINE_register_complete | ||
| 220 | .Fa "ENGINE *e" | ||
| 221 | .Fc | ||
| 222 | .Ft int | ||
| 223 | .Fn ENGINE_register_all_complete void | ||
| 224 | .Ft int | ||
| 225 | .Fo ENGINE_ctrl | ||
| 226 | .Fa "ENGINE *e" | ||
| 227 | .Fa "int cmd" | ||
| 228 | .Fa "long i" | ||
| 229 | .Fa "void *p" | ||
| 230 | .Fa "void (*f)(void)" | ||
| 231 | .Fc | ||
| 232 | .Ft int | ||
| 233 | .Fo ENGINE_cmd_is_executable | ||
| 234 | .Fa "ENGINE *e" | ||
| 235 | .Fa "int cmd" | ||
| 236 | .Fc | ||
| 237 | .Ft int | ||
| 238 | .Fo ENGINE_ctrl_cmd | ||
| 239 | .Fa "ENGINE *e" | ||
| 240 | .Fa "const char *cmd_name" | ||
| 241 | .Fa "long i" | ||
| 242 | .Fa "void *p" | ||
| 243 | .Fa "void (*f)(void)" | ||
| 244 | .Fa "int cmd_optional" | ||
| 245 | .Fc | ||
| 246 | .Ft int | ||
| 247 | .Fo ENGINE_ctrl_cmd_string | ||
| 248 | .Fa "ENGINE *e" | ||
| 249 | .Fa "const char *cmd_name" | ||
| 250 | .Fa "const char *arg" | ||
| 251 | .Fa "int cmd_optional" | ||
| 252 | .Fc | ||
| 253 | .Ft int | ||
| 254 | .Fo ENGINE_set_ex_data | ||
| 255 | .Fa "ENGINE *e" | ||
| 256 | .Fa "int idx" | ||
| 257 | .Fa "void *arg" | ||
| 258 | .Fc | ||
| 259 | .Ft void * | ||
| 260 | .Fo ENGINE_get_ex_data | ||
| 261 | .Fa "const ENGINE *e" | ||
| 262 | .Fa "int idx" | ||
| 263 | .Fc | ||
| 264 | .Ft int | ||
| 265 | .Fo ENGINE_get_ex_new_index | ||
| 266 | .Fa "long argl" | ||
| 267 | .Fa "void *argp" | ||
| 268 | .Fa "CRYPTO_EX_new *new_func" | ||
| 269 | .Fa "CRYPTO_EX_dup *dup_func" | ||
| 270 | .Fa "CRYPTO_EX_free *free_func" | ||
| 271 | .Fc | ||
| 272 | .Ft ENGINE * | ||
| 273 | .Fn ENGINE_new void | ||
| 274 | .Ft int | ||
| 275 | .Fo ENGINE_free | ||
| 276 | .Fa "ENGINE *e" | ||
| 277 | .Fc | ||
| 278 | .Ft int | ||
| 279 | .Fo ENGINE_up_ref | ||
| 280 | .Fa "ENGINE *e" | ||
| 281 | .Fc | ||
| 282 | .Ft int | ||
| 283 | .Fo ENGINE_set_id | ||
| 284 | .Fa "ENGINE *e" | ||
| 285 | .Fa "const char *id" | ||
| 286 | .Fc | ||
| 287 | .Ft int | ||
| 288 | .Fo ENGINE_set_name | ||
| 289 | .Fa "ENGINE *e" | ||
| 290 | .Fa "const char *name" | ||
| 291 | .Fc | ||
| 292 | .Ft int | ||
| 293 | .Fo ENGINE_set_RSA | ||
| 294 | .Fa "ENGINE *e" | ||
| 295 | .Fa "const RSA_METHOD *rsa_meth" | ||
| 296 | .Fc | ||
| 297 | .Ft int | ||
| 298 | .Fo ENGINE_set_DSA | ||
| 299 | .Fa "ENGINE *e" | ||
| 300 | .Fa "const DSA_METHOD *dsa_meth" | ||
| 301 | .Fc | ||
| 302 | .Ft int | ||
| 303 | .Fo ENGINE_set_ECDH | ||
| 304 | .Fa "ENGINE *e" | ||
| 305 | .Fa "const ECDH_METHOD *dh_meth" | ||
| 306 | .Fc | ||
| 307 | .Ft int | ||
| 308 | .Fo ENGINE_set_ECDSA | ||
| 309 | .Fa "ENGINE *e" | ||
| 310 | .Fa "const ECDSA_METHOD *dh_meth" | ||
| 311 | .Fc | ||
| 312 | .Ft int | ||
| 313 | .Fo ENGINE_set_DH | ||
| 314 | .Fa "ENGINE *e" | ||
| 315 | .Fa "const DH_METHOD *dh_meth" | ||
| 316 | .Fc | ||
| 317 | .Ft int | ||
| 318 | .Fo ENGINE_set_RAND | ||
| 319 | .Fa "ENGINE *e" | ||
| 320 | .Fa "const RAND_METHOD *rand_meth" | ||
| 321 | .Fc | ||
| 322 | .Ft int | ||
| 323 | .Fo ENGINE_set_STORE | ||
| 324 | .Fa "ENGINE *e" | ||
| 325 | .Fa "const STORE_METHOD *rand_meth" | ||
| 326 | .Fc | ||
| 327 | .Ft int | ||
| 328 | .Fo ENGINE_set_destroy_function | ||
| 329 | .Fa "ENGINE *e" | ||
| 330 | .Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f" | ||
| 331 | .Fc | ||
| 332 | .Ft int | ||
| 333 | .Fo ENGINE_set_init_function | ||
| 334 | .Fa "ENGINE *e" | ||
| 335 | .Fa "ENGINE_GEN_INT_FUNC_PTR init_f" | ||
| 336 | .Fc | ||
| 337 | .Ft int | ||
| 338 | .Fo ENGINE_set_finish_function | ||
| 339 | .Fa "ENGINE *e" | ||
| 340 | .Fa "ENGINE_GEN_INT_FUNC_PTR finish_f" | ||
| 341 | .Fc | ||
| 342 | .Ft int | ||
| 343 | .Fo ENGINE_set_ctrl_function | ||
| 344 | .Fa "ENGINE *e" | ||
| 345 | .Fa "ENGINE_CTRL_FUNC_PTR ctrl_f" | ||
| 346 | .Fc | ||
| 347 | .Ft int | ||
| 348 | .Fo ENGINE_set_load_privkey_function | ||
| 349 | .Fa "ENGINE *e" | ||
| 350 | .Fa "ENGINE_LOAD_KEY_PTR loadpriv_f" | ||
| 351 | .Fc | ||
| 352 | .Ft int | ||
| 353 | .Fo ENGINE_set_load_pubkey_function | ||
| 354 | .Fa "ENGINE *e" | ||
| 355 | .Fa "ENGINE_LOAD_KEY_PTR loadpub_f" | ||
| 356 | .Fc | ||
| 357 | .Ft int | ||
| 358 | .Fo ENGINE_set_ciphers | ||
| 359 | .Fa "ENGINE *e" | ||
| 360 | .Fa "ENGINE_CIPHERS_PTR f" | ||
| 361 | .Fc | ||
| 362 | .Ft int | ||
| 363 | .Fo ENGINE_set_digests | ||
| 364 | .Fa "ENGINE *e" | ||
| 365 | .Fa "ENGINE_DIGESTS_PTR f" | ||
| 366 | .Fc | ||
| 367 | .Ft int | ||
| 368 | .Fo ENGINE_set_flags | ||
| 369 | .Fa "ENGINE *e" | ||
| 370 | .Fa "int flags" | ||
| 371 | .Fc | ||
| 372 | .Ft int | ||
| 373 | .Fo ENGINE_set_cmd_defns | ||
| 374 | .Fa "ENGINE *e" | ||
| 375 | .Fa "const ENGINE_CMD_DEFN *defns" | ||
| 376 | .Fc | ||
| 377 | .Ft const char * | ||
| 378 | .Fo ENGINE_get_id | ||
| 379 | .Fa "const ENGINE *e" | ||
| 380 | .Fc | ||
| 381 | .Ft const char * | ||
| 382 | .Fo ENGINE_get_name | ||
| 383 | .Fa "const ENGINE *e" | ||
| 384 | .Fc | ||
| 385 | .Ft const RSA_METHOD * | ||
| 386 | .Fo ENGINE_get_RSA | ||
| 387 | .Fa "const ENGINE *e" | ||
| 388 | .Fc | ||
| 389 | .Ft const DSA_METHOD * | ||
| 390 | .Fo ENGINE_get_DSA | ||
| 391 | .Fa "const ENGINE *e" | ||
| 392 | .Fc | ||
| 393 | .Ft const ECDH_METHOD * | ||
| 394 | .Fo ENGINE_get_ECDH | ||
| 395 | .Fa "const ENGINE *e" | ||
| 396 | .Fc | ||
| 397 | .Ft const ECDSA_METHOD * | ||
| 398 | .Fo ENGINE_get_ECDSA | ||
| 399 | .Fa "const ENGINE *e" | ||
| 400 | .Fc | ||
| 401 | .Ft const DH_METHOD * | ||
| 402 | .Fo ENGINE_get_DH | ||
| 403 | .Fa "const ENGINE *e" | ||
| 404 | .Fc | ||
| 405 | .Ft const RAND_METHOD * | ||
| 406 | .Fo ENGINE_get_RAND | ||
| 407 | .Fa "const ENGINE *e" | ||
| 408 | .Fc | ||
| 409 | .Ft const STORE_METHOD * | ||
| 410 | .Fo ENGINE_get_STORE | ||
| 411 | .Fa "const ENGINE *e" | ||
| 412 | .Fc | ||
| 413 | .Ft ENGINE_GEN_INT_FUNC_PTR | ||
| 414 | .Fo ENGINE_get_destroy_function | ||
| 415 | .Fa "const ENGINE *e" | ||
| 416 | .Fc | ||
| 417 | .Ft ENGINE_GEN_INT_FUNC_PTR | ||
| 418 | .Fo ENGINE_get_init_function | ||
| 419 | .Fa "const ENGINE *e" | ||
| 420 | .Fc | ||
| 421 | .Ft ENGINE_GEN_INT_FUNC_PTR | ||
| 422 | .Fo ENGINE_get_finish_function | ||
| 423 | .Fa "const ENGINE *e" | ||
| 424 | .Fc | ||
| 425 | .Ft ENGINE_CTRL_FUNC_PTR | ||
| 426 | .Fo ENGINE_get_ctrl_function | ||
| 427 | .Fa "const ENGINE *e" | ||
| 428 | .Fc | ||
| 429 | .Ft ENGINE_LOAD_KEY_PTR | ||
| 430 | .Fo ENGINE_get_load_privkey_function | ||
| 431 | .Fa "const ENGINE *e" | ||
| 432 | .Fc | ||
| 433 | .Ft ENGINE_LOAD_KEY_PTR | ||
| 434 | .Fo ENGINE_get_load_pubkey_function | ||
| 435 | .Fa "const ENGINE *e" | ||
| 436 | .Fc | ||
| 437 | .Ft ENGINE_CIPHERS_PTR | ||
| 438 | .Fo ENGINE_get_ciphers | ||
| 439 | .Fa "const ENGINE *e" | ||
| 440 | .Fc | ||
| 441 | .Ft ENGINE_DIGESTS_PTR | ||
| 442 | .Fo ENGINE_get_digests | ||
| 443 | .Fa "const ENGINE *e" | ||
| 444 | .Fc | ||
| 445 | .Ft const EVP_CIPHER * | ||
| 446 | .Fo ENGINE_get_cipher | ||
| 447 | .Fa "ENGINE *e" | ||
| 448 | .Fa "int nid" | ||
| 449 | .Fc | ||
| 450 | .Ft const EVP_MD * | ||
| 451 | .Fo ENGINE_get_digest | ||
| 452 | .Fa "ENGINE *e" | ||
| 453 | .Fa "int nid" | ||
| 454 | .Fc | ||
| 455 | .Ft int | ||
| 456 | .Fo ENGINE_get_flags | ||
| 457 | .Fa "const ENGINE *e" | ||
| 458 | .Fc | ||
| 459 | .Ft const ENGINE_CMD_DEFN * | ||
| 460 | .Fo ENGINE_get_cmd_defns | ||
| 461 | .Fa "const ENGINE *e" | ||
| 462 | .Fc | ||
| 463 | .Ft EVP_PKEY * | ||
| 464 | .Fo ENGINE_load_private_key | ||
| 465 | .Fa "ENGINE *e" | ||
| 466 | .Fa "const char *key_id" | ||
| 467 | .Fa "UI_METHOD *ui_method" | ||
| 468 | .Fa "void *callback_data" | ||
| 469 | .Fc | ||
| 470 | .Ft EVP_PKEY * | ||
| 471 | .Fo ENGINE_load_public_key | ||
| 472 | .Fa "ENGINE *e" | ||
| 473 | .Fa "const char *key_id" | ||
| 474 | .Fa "UI_METHOD *ui_method" | ||
| 475 | .Fa "void *callback_data" | ||
| 476 | .Fc | ||
| 477 | .Ft void | ||
| 478 | .Fn ENGINE_add_conf_module void | ||
| 479 | .Sh DESCRIPTION | ||
| 480 | These functions create, manipulate, and use cryptographic modules | ||
| 481 | in the form of | ||
| 482 | .Vt ENGINE | ||
| 483 | objects. | ||
| 484 | These objects act as containers for implementations of cryptographic | ||
| 485 | algorithms, and support a reference-counted mechanism to allow them to | ||
| 486 | be dynamically loaded in and out of the running application. | ||
| 487 | .Pp | ||
| 488 | The cryptographic functionality that can be provided by an | ||
| 489 | .Vt ENGINE | ||
| 490 | implementation includes the following abstractions: | ||
| 491 | .Pp | ||
| 492 | .Bl -bullet -compact | ||
| 493 | .It | ||
| 494 | .Vt RSA_METHOD : | ||
| 495 | for providing alternative RSA implementations | ||
| 496 | .It | ||
| 497 | .Vt DSA_METHOD , DH_METHOD , RAND_METHOD , ECDH_METHOD , | ||
| 498 | .Vt ECDSA_METHOD , STORE_METHOD : | ||
| 499 | similarly for other OpenSSL APIs | ||
| 500 | .It | ||
| 501 | .Vt EVP_CIPHER : | ||
| 502 | potentially multiple cipher algorithms (indexed by 'nid') | ||
| 503 | .It | ||
| 504 | .Vt EVP_DIGEST : | ||
| 505 | potentially multiple hash algorithms (indexed by 'nid') | ||
| 506 | .It | ||
| 507 | key-loading: loading public and/or private EVP_PKEY keys | ||
| 508 | .El | ||
| 509 | .Ss Reference counting and handles | ||
| 510 | Due to the modular nature of the | ||
| 511 | .Nm engine | ||
| 512 | API, pointers to | ||
| 513 | .Vt ENGINE Ns s | ||
| 514 | need to be treated as handles - ie. not only as pointers, but also | ||
| 515 | as references to the underlying | ||
| 516 | .Vt ENGINE | ||
| 517 | object. | ||
| 518 | One should obtain a new reference when making copies of an | ||
| 519 | .Vt ENGINE | ||
| 520 | pointer if the copies will be used (and released) independently. | ||
| 521 | .Pp | ||
| 522 | .Vt ENGINE | ||
| 523 | objects have two levels of reference-counting to match the way in | ||
| 524 | which the objects are used. | ||
| 525 | At the most basic level, each | ||
| 526 | .Vt ENGINE | ||
| 527 | pointer is inherently a | ||
| 528 | .Sy structural | ||
| 529 | reference - a structural reference is required to use the pointer value | ||
| 530 | at all, as this kind of reference is a guarantee that the structure can | ||
| 531 | not be deallocated until the reference is released. | ||
| 532 | .Pp | ||
| 533 | However, a structural reference provides no guarantee that the | ||
| 534 | .Vt ENGINE | ||
| 535 | is initialised and able to use any of its cryptographic implementations. | ||
| 536 | Indeed it's quite possible that most | ||
| 537 | .Vt ENGINE Ns s | ||
| 538 | will not initialise at all in typical environments, as | ||
| 539 | .Vt ENGINE Ns s | ||
| 540 | are typically used to support specialised hardware. | ||
| 541 | To use an | ||
| 542 | .Vt ENGINE Ap s | ||
| 543 | functionality, you need a | ||
| 544 | .Sy functional | ||
| 545 | reference. | ||
| 546 | This kind of reference can be considered a specialised form of | ||
| 547 | structural reference, because each functional reference implicitly | ||
| 548 | contains a structural reference as well - however to avoid | ||
| 549 | difficult-to-find programming bugs, it is recommended to treat the two | ||
| 550 | kinds of reference independently. | ||
| 551 | If you have a functional reference to an | ||
| 552 | .Vt ENGINE , | ||
| 553 | you have a guarantee that the | ||
| 554 | .Vt ENGINE | ||
| 555 | has been initialised ready to perform cryptographic operations and | ||
| 556 | will remain uninitialised until after you have released your | ||
| 557 | reference. | ||
| 558 | .Pp | ||
| 559 | .Em Structural references | ||
| 560 | .Pp | ||
| 561 | This basic type of reference is used for instantiating new | ||
| 562 | .Vt ENGINE Ns s, | ||
| 563 | iterating across OpenSSL's internal linked-list of loaded | ||
| 564 | .Vt ENGINE Ns s, | ||
| 565 | reading information about an | ||
| 566 | .Vt ENGINE , | ||
| 567 | etc. | ||
| 568 | Essentially a structural reference is sufficient if you only need to | ||
| 569 | query or manipulate the data of an | ||
| 570 | .Vt ENGINE | ||
| 571 | implementation rather than use its functionality. | ||
| 572 | .Pp | ||
| 573 | The | ||
| 574 | .Fn ENGINE_new | ||
| 575 | function returns a structural reference to a new (empty) | ||
| 576 | .Vt ENGINE | ||
| 577 | object. | ||
| 578 | There are other | ||
| 579 | .Nm engine | ||
| 580 | API functions that return structural references such as | ||
| 581 | .Fn ENGINE_by_id , | ||
| 582 | .Fn ENGINE_get_first , | ||
| 583 | .Fn ENGINE_get_last , | ||
| 584 | .Fn ENGINE_get_next , | ||
| 585 | and | ||
| 586 | .Fn ENGINE_get_prev . | ||
| 587 | All structural references should be released by a corresponding call | ||
| 588 | to the | ||
| 589 | .Fn ENGINE_free | ||
| 590 | function. | ||
| 591 | The | ||
| 592 | .Vt ENGINE | ||
| 593 | object itself will only actually be cleaned up and deallocated when | ||
| 594 | the last structural reference is released. | ||
| 595 | .Pp | ||
| 596 | It should also be noted that many | ||
| 597 | .Nm engine | ||
| 598 | API function calls that accept a structural reference will internally | ||
| 599 | obtain another reference. | ||
| 600 | Typically this happens whenever the supplied | ||
| 601 | .Vt ENGINE | ||
| 602 | will be needed by OpenSSL after the function has returned. | ||
| 603 | For example, the function to add a new | ||
| 604 | .Vt ENGINE | ||
| 605 | to OpenSSL's internal list is | ||
| 606 | .Fn ENGINE_add . | ||
| 607 | If this function returns success, OpenSSL will have stored a new | ||
| 608 | structural reference internally so the caller is still responsible for | ||
| 609 | freeing their own reference with | ||
| 610 | .Fn ENGINE_free | ||
| 611 | when they are finished with it. | ||
| 612 | In a similar way, some functions will automatically release the | ||
| 613 | structural reference passed to it if part of the function's job is | ||
| 614 | to do so. | ||
| 615 | For example, the | ||
| 616 | .Fn ENGINE_get_next | ||
| 617 | and | ||
| 618 | .Fn ENGINE_get_prev | ||
| 619 | functions are used for iterating across the internal | ||
| 620 | .Vt ENGINE | ||
| 621 | list. | ||
| 622 | They | ||
| 623 | will return a new structural reference to the next (or previous) | ||
| 624 | .Vt ENGINE | ||
| 625 | in the list or | ||
| 626 | .Dv NULL | ||
| 627 | if at the end (or beginning) of the list, but in either case the | ||
| 628 | structural reference passed to the function is released on behalf | ||
| 629 | of the caller. | ||
| 630 | .Pp | ||
| 631 | To clarify a particular function's handling of references, one should | ||
| 632 | always consult that function's manual page, or failing that the | ||
| 633 | .In openssl/engine.h | ||
| 634 | header file includes some hints. | ||
| 635 | .Pp | ||
| 636 | .Em Functional references | ||
| 637 | .Pp | ||
| 638 | As mentioned, functional references exist when the cryptographic | ||
| 639 | functionality of an | ||
| 640 | .Vt ENGINE | ||
| 641 | is required to be available. | ||
| 642 | A functional reference can be obtained in one of two ways; from an | ||
| 643 | existing structural reference to the required | ||
| 644 | .Vt ENGINE , | ||
| 645 | or by asking OpenSSL for the default operational | ||
| 646 | .Vt ENGINE | ||
| 647 | for a given cryptographic purpose. | ||
| 648 | .Pp | ||
| 649 | To obtain a functional reference from an existing structural reference, | ||
| 650 | call the | ||
| 651 | .Fn ENGINE_init | ||
| 652 | function. | ||
| 653 | This returns zero if the | ||
| 654 | .Vt ENGINE | ||
| 655 | was not already operational and couldn't be successfully initialised | ||
| 656 | (eg. lack of system drivers, no special hardware attached, etc.), | ||
| 657 | otherwise it will return non-zero to indicate that the | ||
| 658 | .Vt ENGINE | ||
| 659 | is now operational and will have allocated a new | ||
| 660 | .Sy functional | ||
| 661 | reference to the | ||
| 662 | .Vt ENGINE . | ||
| 663 | All functional references are released by calling | ||
| 664 | .Fn ENGINE_finish , | ||
| 665 | which removes the implicit structural reference as well. | ||
| 666 | .Pp | ||
| 667 | The second way to get a functional reference is by asking OpenSSL for a | ||
| 668 | default implementation for a given task, eg. | ||
| 669 | by | ||
| 670 | .Fn ENGINE_get_default_RSA , | ||
| 671 | .Fn ENGINE_get_default_cipher_engine , | ||
| 672 | etc. | ||
| 673 | These are discussed in the next section, though they are not usually | ||
| 674 | required by application programmers as they are used automatically when | ||
| 675 | creating and using the relevant algorithm-specific types in OpenSSL, | ||
| 676 | such as RSA, DSA, EVP_CIPHER_CTX, etc. | ||
| 677 | .Ss Default implementations | ||
| 678 | For each supported abstraction, the | ||
| 679 | .Nm engine | ||
| 680 | code maintains an internal table of state to control which | ||
| 681 | implementations are available for a given abstraction and which | ||
| 682 | should be used by default. | ||
| 683 | These implementations are registered in the tables and indexed by an | ||
| 684 | .Fa nid | ||
| 685 | value, because abstractions like | ||
| 686 | .Vt EVP_CIPHER | ||
| 687 | and | ||
| 688 | .Vt EVP_DIGEST | ||
| 689 | support many distinct algorithms and modes, and | ||
| 690 | .Vt ENGINE Ns s | ||
| 691 | can support arbitrarily many of them. | ||
| 692 | In the case of other abstractions like RSA, DSA, etc., there is | ||
| 693 | only one "algorithm" so all implementations implicitly register | ||
| 694 | using the same | ||
| 695 | .Fa nid | ||
| 696 | index. | ||
| 697 | .Pp | ||
| 698 | When a default | ||
| 699 | .Vt ENGINE | ||
| 700 | is requested for a given abstraction/algorithm/mode, (eg. when | ||
| 701 | calling | ||
| 702 | .Fn RSA_new_method NULL ) , | ||
| 703 | a "get_default" call will be made to the | ||
| 704 | .Nm engine | ||
| 705 | subsystem to process the corresponding state table and return | ||
| 706 | a functional reference to an initialised | ||
| 707 | .Vt ENGINE | ||
| 708 | whose implementation should be used. | ||
| 709 | If no | ||
| 710 | .Vt ENGINE | ||
| 711 | should (or can) be used, it will return | ||
| 712 | .Dv NULL | ||
| 713 | and the caller will operate with a | ||
| 714 | .Dv NULL | ||
| 715 | .Vt ENGINE | ||
| 716 | handle. | ||
| 717 | This usually equates to using the conventional software implementation. | ||
| 718 | In the latter case, OpenSSL will from then on behave the way it used to | ||
| 719 | before the | ||
| 720 | .Nm engine | ||
| 721 | API existed. | ||
| 722 | .Pp | ||
| 723 | Each state table has a flag to note whether it has processed this | ||
| 724 | "get_default" query since the table was last modified, because to | ||
| 725 | process this question it must iterate across all the registered | ||
| 726 | .Vt ENGINE Ns s | ||
| 727 | in the table trying to initialise each of them in turn, in case one of | ||
| 728 | them is operational. | ||
| 729 | If it returns a functional reference to an | ||
| 730 | .Vt ENGINE , | ||
| 731 | it will also cache another reference to speed up processing future | ||
| 732 | queries (without needing to iterate across the table). | ||
| 733 | Likewise, it will cache a | ||
| 734 | .Dv NULL | ||
| 735 | response if no | ||
| 736 | .Vt ENGINE | ||
| 737 | was available so that future queries won't repeat the same iteration | ||
| 738 | unless the state table changes. | ||
| 739 | This behaviour can also be changed; if the | ||
| 740 | .Dv ENGINE_TABLE_FLAG_NOINIT | ||
| 741 | flag is set (using | ||
| 742 | .Fn ENGINE_set_table_flags ) , | ||
| 743 | no attempted initialisations will take place, instead the only way for | ||
| 744 | the state table to return a | ||
| 745 | .Pf non- Dv NULL | ||
| 746 | .Vt ENGINE | ||
| 747 | to the "get_default" query will be if one is expressly set in the table. | ||
| 748 | For example, | ||
| 749 | .Fn ENGINE_set_default_RSA | ||
| 750 | does the same job as | ||
| 751 | .Fn ENGINE_register_RSA | ||
| 752 | except that it also sets the state table's cached response for the | ||
| 753 | "get_default" query. | ||
| 754 | In the case of abstractions like | ||
| 755 | .Vt EVP_CIPHER , | ||
| 756 | where implementations are indexed by | ||
| 757 | .Fa nid , | ||
| 758 | these flags and cached-responses are distinct for each | ||
| 759 | .Fa nid | ||
| 760 | value. | ||
| 761 | .Ss Application requirements | ||
| 762 | This section will explain the basic things an application programmer | ||
| 763 | should support to make the most useful elements of the | ||
| 764 | .Nm engine | ||
| 765 | functionality available to the user. | ||
| 766 | The first thing to consider is whether the programmer wishes to make | ||
| 767 | alternative | ||
| 768 | .Vt ENGINE | ||
| 769 | modules available to the application and user. | ||
| 770 | OpenSSL maintains an internal linked list of "visible" | ||
| 771 | .Vt ENGINE Ns s | ||
| 772 | from which it has to operate. | ||
| 773 | At start-up, this list is empty, and in fact if an application does | ||
| 774 | not call any | ||
| 775 | .Nm engine | ||
| 776 | API calls and it uses static | ||
| 777 | linking against openssl, then the resulting application binary will | ||
| 778 | not contain any alternative | ||
| 779 | .Nm engine | ||
| 780 | code at all. | ||
| 781 | So the first consideration is whether any/all available | ||
| 782 | .Vt ENGINE | ||
| 783 | implementations should be made visible to OpenSSL. | ||
| 784 | This is controlled by calling the various "load" functions, eg. | ||
| 785 | .Fn ENGINE_load_builtin_engines | ||
| 786 | to make all | ||
| 787 | .Vt ENGINE | ||
| 788 | implementations bundled with OpenSSL available. | ||
| 789 | .Pp | ||
| 790 | Note that | ||
| 791 | .Fn ENGINE_load_dynamic | ||
| 792 | is a placeholder and does not enable dynamic engine loading support. | ||
| 793 | .Pp | ||
| 794 | Having called any of these functions, | ||
| 795 | .Vt ENGINE | ||
| 796 | objects would have been dynamically allocated and populated with | ||
| 797 | these implementations and linked into OpenSSL's internal linked | ||
| 798 | list. | ||
| 799 | .Pp | ||
| 800 | If no | ||
| 801 | .Nm engine | ||
| 802 | API functions are called at all in an application, then there are | ||
| 803 | no inherent memory leaks to worry about from the | ||
| 804 | .Nm engine | ||
| 805 | functionality, however if any | ||
| 806 | .Vt ENGINE Ns s | ||
| 807 | are loaded, even if they are never registered or used, it is necessary | ||
| 808 | to use the | ||
| 809 | .Fn ENGINE_cleanup | ||
| 810 | function to correspondingly cleanup before program exit, if the caller | ||
| 811 | wishes to avoid memory leaks. | ||
| 812 | This mechanism uses an internal callback registration table so that any | ||
| 813 | .Nm engine | ||
| 814 | API functionality that knows it requires cleanup can register its | ||
| 815 | cleanup details to be called during | ||
| 816 | .Fn ENGINE_cleanup . | ||
| 817 | This approach allows | ||
| 818 | .Fn ENGINE_cleanup | ||
| 819 | to clean up after any | ||
| 820 | .Nm engine | ||
| 821 | functionality at all that your program uses, yet doesn't automatically | ||
| 822 | create linker dependencies to all possible | ||
| 823 | .Nm engine | ||
| 824 | functionality - only the cleanup callbacks required by the functionality | ||
| 825 | you do use will be required by the linker. | ||
| 826 | .Pp | ||
| 827 | The fact that | ||
| 828 | .Vt ENGINE Ns s | ||
| 829 | are made visible to OpenSSL (and thus are linked into the program | ||
| 830 | and loaded into memory at run-time) does not mean they are "registered" | ||
| 831 | or called into use by OpenSSL automatically - that behaviour is | ||
| 832 | something for the application to control. | ||
| 833 | Some applications will want to allow the user to specify exactly which | ||
| 834 | .Vt ENGINE | ||
| 835 | they want used if any is to be used at all. | ||
| 836 | Others may prefer to load all support and have OpenSSL automatically use | ||
| 837 | at run-time any | ||
| 838 | .Vt ENGINE | ||
| 839 | that is able to successfully initialised - ie. to assume that this | ||
| 840 | corresponds to acceleration hardware attached to the machine or | ||
| 841 | some such thing. | ||
| 842 | There are probably numerous other ways in which applications may prefer | ||
| 843 | to handle things, so we will simply illustrate the consequences as they | ||
| 844 | apply to a couple of simple cases and leave developers to consider these | ||
| 845 | and the source code to openssl's builtin utilities as guides. | ||
| 846 | .Pp | ||
| 847 | .Em Using a specific ENGINE implementation | ||
| 848 | .Pp | ||
| 849 | Here we'll assume an application has been configured by its user or | ||
| 850 | admin to want to use the "ACME" | ||
| 851 | .Vt ENGINE | ||
| 852 | if it is available in the version of OpenSSL the application was | ||
| 853 | compiled with. | ||
| 854 | If it is available, it should be used by default for all RSA, DSA, and | ||
| 855 | symmetric cipher operation, otherwise OpenSSL should use its builtin | ||
| 856 | software as usual. | ||
| 857 | The following code illustrates how to approach this: | ||
| 858 | .Bd -literal | ||
| 859 | ENGINE *e; | ||
| 860 | const char *engine_id = "ACME"; | ||
| 861 | ENGINE_load_builtin_engines(); | ||
| 862 | e = ENGINE_by_id(engine_id); | ||
| 863 | if (!e) | ||
| 864 | /* the engine isn't available */ | ||
| 865 | return; | ||
| 866 | if (!ENGINE_init(e)) { | ||
| 867 | /* the engine couldn't initialise, release 'e' */ | ||
| 868 | ENGINE_free(e); | ||
| 869 | return; | ||
| 870 | } | ||
| 871 | if (!ENGINE_set_default_RSA(e)) | ||
| 872 | /* This should only happen when 'e' can't initialise, but the previous | ||
| 873 | * statement suggests it did. */ | ||
| 874 | abort(); | ||
| 875 | ENGINE_set_default_DSA(e); | ||
| 876 | ENGINE_set_default_ciphers(e); | ||
| 877 | /* Release the functional reference from ENGINE_init() */ | ||
| 878 | ENGINE_finish(e); | ||
| 879 | /* Release the structural reference from ENGINE_by_id() */ | ||
| 880 | ENGINE_free(e); | ||
| 881 | .Ed | ||
| 882 | .Pp | ||
| 883 | .Em Automatically using builtin ENGINE implementations | ||
| 884 | .Pp | ||
| 885 | Here we'll assume we want to load and register all | ||
| 886 | .Vt ENGINE | ||
| 887 | implementations bundled with OpenSSL, such that for any cryptographic | ||
| 888 | algorithm required by OpenSSL - if there is an | ||
| 889 | .Vt ENGINE | ||
| 890 | that implements it and can be initialise, it should be used. | ||
| 891 | The following code illustrates how this can work; | ||
| 892 | .Bd -literal | ||
| 893 | /* Load all bundled ENGINEs into memory and make them visible */ | ||
| 894 | ENGINE_load_builtin_engines(); | ||
| 895 | /* Register all of them for every algorithm they collectively implement */ | ||
| 896 | ENGINE_register_all_complete(); | ||
| 897 | .Ed | ||
| 898 | .Pp | ||
| 899 | That's all that's required. | ||
| 900 | For example, the next time OpenSSL tries to set up an RSA key, any bundled | ||
| 901 | .Vt ENGINE Ns s | ||
| 902 | that implement | ||
| 903 | .Vt RSA_METHOD | ||
| 904 | will be passed to | ||
| 905 | .Fn ENGINE_init | ||
| 906 | and if any of those succeed, that | ||
| 907 | .Vt ENGINE | ||
| 908 | will be set as the default for RSA use from then on. | ||
| 909 | .Ss Advanced configuration support | ||
| 910 | There is a mechanism supported by the | ||
| 911 | .Nm engine | ||
| 912 | framework that allows each | ||
| 913 | .Vt ENGINE | ||
| 914 | implementation to define an arbitrary set of configuration | ||
| 915 | "commands" and expose them to OpenSSL and any applications based on | ||
| 916 | OpenSSL. | ||
| 917 | This mechanism is entirely based on the use of name-value pairs | ||
| 918 | and assumes ASCII input (no unicode or UTF for now!), so it is ideal if | ||
| 919 | applications want to provide a transparent way for users to provide | ||
| 920 | arbitrary configuration "directives" directly to such | ||
| 921 | .Vt ENGINE Ns s. | ||
| 922 | It is also possible for the application to dynamically interrogate the | ||
| 923 | loaded | ||
| 924 | .Vt ENGINE | ||
| 925 | implementations for the names, descriptions, and input flags of | ||
| 926 | their available "control commands", providing a more flexible | ||
| 927 | configuration scheme. | ||
| 928 | However, if the user is expected to know which | ||
| 929 | .Vt ENGINE | ||
| 930 | device he/she is using (in the case of specialised hardware, this | ||
| 931 | goes without saying) then applications may not need to concern | ||
| 932 | themselves with discovering the supported control commands and | ||
| 933 | simply prefer to pass settings into | ||
| 934 | .Vt ENGINE s | ||
| 935 | exactly as they are provided by the user. | ||
| 936 | .Pp | ||
| 937 | Before illustrating how control commands work, it is worth mentioning | ||
| 938 | what they are typically used for. | ||
| 939 | Broadly speaking there are two uses for control commands; the first is | ||
| 940 | to provide the necessary details to the implementation (which may know | ||
| 941 | nothing at all specific to the host system) so that it can be | ||
| 942 | initialised for use. | ||
| 943 | This could include the path to any driver or config files it needs to | ||
| 944 | load, required network addresses, smart-card identifiers, passwords to | ||
| 945 | initialise protected devices, logging information, etc etc. | ||
| 946 | This class of commands typically needs to be passed to an | ||
| 947 | .Vt ENGINE | ||
| 948 | .Sy before | ||
| 949 | attempting to initialise it, ie. before calling | ||
| 950 | .Fn ENGINE_init . | ||
| 951 | The other class of commands consist of settings or operations that tweak | ||
| 952 | certain behaviour or cause certain operations to take place, and these | ||
| 953 | commands may work either before or after | ||
| 954 | .Fn ENGINE_init , | ||
| 955 | or in some cases both. | ||
| 956 | .Vt ENGINE | ||
| 957 | implementations should provide indications of this in the descriptions | ||
| 958 | attached to builtin control commands and/or in external product | ||
| 959 | documentation. | ||
| 960 | .Pp | ||
| 961 | .Em Issuing control commands to an ENGINE | ||
| 962 | .Pp | ||
| 963 | Let's illustrate by example; a function for which the caller supplies | ||
| 964 | the name of the | ||
| 965 | .Vt ENGINE | ||
| 966 | it wishes to use, a table of string-pairs for use before initialisation, | ||
| 967 | and another table for use after initialisation. | ||
| 968 | Note that the string-pairs used for control commands consist of a | ||
| 969 | command "name" followed by the command "parameter" - the parameter | ||
| 970 | could be | ||
| 971 | .Dv NULL | ||
| 972 | in some cases but the name can not. | ||
| 973 | This function should initialise the | ||
| 974 | .Vt ENGINE | ||
| 975 | (issuing the "pre" commands beforehand and the "post" commands | ||
| 976 | afterwards) and set it as the default for everything except RAND | ||
| 977 | and then return a boolean success or failure. | ||
| 978 | .Bd -literal | ||
| 979 | int | ||
| 980 | generic_load_engine_fn(const char *engine_id, | ||
| 981 | const char **pre_cmds, int pre_num, | ||
| 982 | const char **post_cmds, int post_num) | ||
| 983 | { | ||
| 984 | ENGINE *e = ENGINE_by_id(engine_id); | ||
| 985 | |||
| 986 | if (!e) | ||
| 987 | return 0; | ||
| 988 | while (pre_num--) { | ||
| 989 | if (!ENGINE_ctrl_cmd_string(e, | ||
| 990 | pre_cmds[0], pre_cmds[1], 0)) { | ||
| 991 | fprintf(stderr, | ||
| 992 | "Failed command (%s - %s:%s)\en", | ||
| 993 | engine_id, pre_cmds[0], | ||
| 994 | pre_cmds[1] ? pre_cmds[1] : "(NULL)"); | ||
| 995 | ENGINE_free(e); | ||
| 996 | return 0; | ||
| 997 | } | ||
| 998 | pre_cmds += 2; | ||
| 999 | } | ||
| 1000 | if (!ENGINE_init(e)) { | ||
| 1001 | fprintf(stderr, "Failed initialisation\en"); | ||
| 1002 | ENGINE_free(e); | ||
| 1003 | return 0; | ||
| 1004 | } | ||
| 1005 | /* | ||
| 1006 | * ENGINE_init() returned a functional reference, | ||
| 1007 | * so free the structural reference from | ||
| 1008 | * ENGINE_by_id(). | ||
| 1009 | */ | ||
| 1010 | ENGINE_free(e); | ||
| 1011 | while (post_num--) { | ||
| 1012 | if (!ENGINE_ctrl_cmd_string(e, | ||
| 1013 | post_cmds[0], post_cmds[1], 0)) { | ||
| 1014 | fprintf(stderr, | ||
| 1015 | "Failed command (%s - %s:%s)\en", | ||
| 1016 | engine_id, post_cmds[0], | ||
| 1017 | post_cmds[1] ? post_cmds[1] : "(NULL)"); | ||
| 1018 | ENGINE_finish(e); | ||
| 1019 | return 0; | ||
| 1020 | } | ||
| 1021 | post_cmds += 2; | ||
| 1022 | } | ||
| 1023 | ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND); | ||
| 1024 | /* Success */ | ||
| 1025 | return 1; | ||
| 1026 | } | ||
| 1027 | .Ed | ||
| 1028 | .Pp | ||
| 1029 | Note that | ||
| 1030 | .Fn ENGINE_ctrl_cmd_string | ||
| 1031 | accepts a boolean argument that can relax the semantics of the function. | ||
| 1032 | If set to non-zero it will only return failure if the | ||
| 1033 | .Vt ENGINE | ||
| 1034 | supported the given command name but failed while executing it, if the | ||
| 1035 | .Vt ENGINE | ||
| 1036 | doesn't support the command name it will simply return success without | ||
| 1037 | doing anything. | ||
| 1038 | In this case we assume the user is only supplying commands specific to | ||
| 1039 | the given | ||
| 1040 | .Vt ENGINE | ||
| 1041 | so we set this to FALSE. | ||
| 1042 | .Pp | ||
| 1043 | .Em Discovering supported control commands | ||
| 1044 | .Pp | ||
| 1045 | It is possible to discover at run-time the names, numerical-ids, | ||
| 1046 | descriptions and input parameters of the control commands supported by an | ||
| 1047 | .Vt ENGINE | ||
| 1048 | using a structural reference. | ||
| 1049 | Note that some control commands are defined by OpenSSL itself and it | ||
| 1050 | will intercept and handle these control commands on behalf of the | ||
| 1051 | .Vt ENGINE , | ||
| 1052 | ie. the | ||
| 1053 | .Vt ENGINE Ap s | ||
| 1054 | ctrl() handler is not used for the control command. | ||
| 1055 | .In openssl/engine.h | ||
| 1056 | defines an index, | ||
| 1057 | .Dv ENGINE_CMD_BASE , | ||
| 1058 | that all control commands implemented by | ||
| 1059 | .Vt ENGINE Ns s | ||
| 1060 | should be numbered from. | ||
| 1061 | Any command value lower than this symbol is considered a "generic" | ||
| 1062 | command is handled directly by the OpenSSL core routines. | ||
| 1063 | .Pp | ||
| 1064 | It is using these "core" control commands that one can discover the | ||
| 1065 | control commands implemented by a given | ||
| 1066 | .Vt ENGINE , | ||
| 1067 | specifically the commands: | ||
| 1068 | .Bd -literal | ||
| 1069 | #define ENGINE_HAS_CTRL_FUNCTION 10 | ||
| 1070 | #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 | ||
| 1071 | #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 | ||
| 1072 | #define ENGINE_CTRL_GET_CMD_FROM_NAME 13 | ||
| 1073 | #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 | ||
| 1074 | #define ENGINE_CTRL_GET_NAME_FROM_CMD 15 | ||
| 1075 | #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 | ||
| 1076 | #define ENGINE_CTRL_GET_DESC_FROM_CMD 17 | ||
| 1077 | #define ENGINE_CTRL_GET_CMD_FLAGS 18 | ||
| 1078 | .Ed | ||
| 1079 | .Pp | ||
| 1080 | Whilst these commands are automatically processed by the OpenSSL | ||
| 1081 | framework code, they use various properties exposed by each | ||
| 1082 | .Vt ENGINE | ||
| 1083 | to process these queries. | ||
| 1084 | An | ||
| 1085 | .Vt ENGINE | ||
| 1086 | has 3 properties it exposes that can affect how this behaves; | ||
| 1087 | it can supply a ctrl() handler, it can specify | ||
| 1088 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 1089 | in the | ||
| 1090 | .Vt ENGINE Ap s | ||
| 1091 | flags, and it can expose an array of control command descriptions. | ||
| 1092 | If an | ||
| 1093 | .Vt ENGINE | ||
| 1094 | specifies the | ||
| 1095 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 1096 | flag, then it will simply pass all these "core" control commands | ||
| 1097 | directly to the | ||
| 1098 | .Vt ENGINE Ap s | ||
| 1099 | ctrl() handler (and thus, it must have supplied one), so it is up | ||
| 1100 | to the | ||
| 1101 | .Vt ENGINE | ||
| 1102 | to reply to these "discovery" commands itself. | ||
| 1103 | If that flag is not set, then the OpenSSL framework code will work with | ||
| 1104 | the following rules; | ||
| 1105 | .Bl -tag -width Ds | ||
| 1106 | .It If no ctrl() handler is supplied: | ||
| 1107 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 1108 | returns FALSE (zero), all other commands fail. | ||
| 1109 | .It If a ctrl() handler was supplied but no array of control commands: | ||
| 1110 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 1111 | returns TRUE, all other commands fail. | ||
| 1112 | .It If a ctrl() handler and array of control commands was supplied: | ||
| 1113 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 1114 | returns TRUE, all other commands proceed processing... | ||
| 1115 | .El | ||
| 1116 | .Pp | ||
| 1117 | If the | ||
| 1118 | .Vt ENGINE Ns s | ||
| 1119 | array of control commands is empty, then all other commands will fail. | ||
| 1120 | Otherwise | ||
| 1121 | .Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE | ||
| 1122 | returns the identifier of the first command supported by the | ||
| 1123 | .Vt ENGINE , | ||
| 1124 | .Dv ENGINE_GET_NEXT_CMD_TYPE | ||
| 1125 | takes the identifier of a command supported by the | ||
| 1126 | .Vt ENGINE | ||
| 1127 | and returns the next command identifier or fails if there are no more, | ||
| 1128 | .Dv ENGINE_CMD_FROM_NAME | ||
| 1129 | takes a string name for a command and returns the corresponding | ||
| 1130 | identifier or fails if no such command name exists, and the remaining | ||
| 1131 | commands take a command identifier and return properties of the | ||
| 1132 | corresponding commands. | ||
| 1133 | All except | ||
| 1134 | .Dv ENGINE_CTRL_GET_FLAGS | ||
| 1135 | return the string length of a command name or description, or | ||
| 1136 | populate a supplied character buffer with a copy of the command | ||
| 1137 | name or description. | ||
| 1138 | .Dv ENGINE_CTRL_GET_FLAGS | ||
| 1139 | returns a bitwise-OR'd mask of the following possible values: | ||
| 1140 | .Bd -literal | ||
| 1141 | #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 | ||
| 1142 | #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 | ||
| 1143 | #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 | ||
| 1144 | #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 | ||
| 1145 | .Ed | ||
| 1146 | .Pp | ||
| 1147 | If the | ||
| 1148 | .Dv ENGINE_CMD_FLAG_INTERNAL | ||
| 1149 | flag is set, then any other flags are purely informational to the caller. | ||
| 1150 | This flag will prevent the command being usable for any higher-level | ||
| 1151 | .Vt ENGINE | ||
| 1152 | functions such as | ||
| 1153 | .Fn ENGINE_ctrl_cmd_string . | ||
| 1154 | "INTERNAL" commands are not intended to be exposed to text-based | ||
| 1155 | configuration by applications, administrations, users, etc. | ||
| 1156 | These can support arbitrary operations via | ||
| 1157 | .Fn ENGINE_ctrl , | ||
| 1158 | including passing to and/or from the control commands data of any | ||
| 1159 | arbitrary type. | ||
| 1160 | These commands are supported in the discovery mechanisms simply allow | ||
| 1161 | applications to determine if an | ||
| 1162 | .Vt ENGINE | ||
| 1163 | supports certain specific commands it might want to use (eg. | ||
| 1164 | application "foo" might query various | ||
| 1165 | .Vt ENGINE Ns s | ||
| 1166 | to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and | ||
| 1167 | .Vt ENGINE | ||
| 1168 | could therefore decide whether or not to support this "foo"-specific | ||
| 1169 | extension). | ||
| 1170 | .Ss Future developments | ||
| 1171 | The | ||
| 1172 | .Nm engine | ||
| 1173 | API and internal architecture is currently being reviewed. | ||
| 1174 | Slated for possible release in 0.9.8 is support for transparent loading | ||
| 1175 | of "dynamic" | ||
| 1176 | .Vt ENGINE Ns s (built as self-contained shared libraries). | ||
| 1177 | This would allow | ||
| 1178 | .Vt ENGINE | ||
| 1179 | implementations to be provided independently of | ||
| 1180 | OpenSSL libraries and/or OpenSSL-based applications, and would also | ||
| 1181 | remove any requirement for applications to explicitly use the "dynamic" | ||
| 1182 | .Vt ENGINE | ||
| 1183 | to bind to shared-library implementations. | ||
| 1184 | .Sh SEE ALSO | ||
| 1185 | .Xr dh 3 , | ||
| 1186 | .Xr dsa 3 , | ||
| 1187 | .Xr rsa 3 | ||
