diff options
Diffstat (limited to 'src/lib/libcrypto/man')
| -rw-r--r-- | src/lib/libcrypto/man/Makefile | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/man/engine.3 | 535 |
2 files changed, 1 insertions, 537 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index 695485aeeb..c8e5d51fd6 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.140 2018/04/15 17:02:03 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.141 2018/04/18 01:13:37 schwarze Exp $ |
| 2 | 2 | ||
| 3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> |
| 4 | 4 | ||
| @@ -302,7 +302,6 @@ MAN= \ | |||
| 302 | d2i_X509_REQ.3 \ | 302 | d2i_X509_REQ.3 \ |
| 303 | d2i_X509_SIG.3 \ | 303 | d2i_X509_SIG.3 \ |
| 304 | des_read_pw.3 \ | 304 | des_read_pw.3 \ |
| 305 | engine.3 \ | ||
| 306 | evp.3 \ | 305 | evp.3 \ |
| 307 | get_rfc3526_prime_8192.3 \ | 306 | get_rfc3526_prime_8192.3 \ |
| 308 | i2d_PKCS7_bio_stream.3 \ | 307 | i2d_PKCS7_bio_stream.3 \ |
diff --git a/src/lib/libcrypto/man/engine.3 b/src/lib/libcrypto/man/engine.3 deleted file mode 100644 index ebcc95f310..0000000000 --- a/src/lib/libcrypto/man/engine.3 +++ /dev/null | |||
| @@ -1,535 +0,0 @@ | |||
| 1 | .\" $OpenBSD: engine.3,v 1.16 2018/04/15 17:02:03 schwarze Exp $ | ||
| 2 | .\" full merge up to: OpenSSL crypto/engine e6390aca Jul 21 10:06:03 2015 -0400 | ||
| 3 | .\" selective merge up to: man3/ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 | ||
| 4 | .\" | ||
| 5 | .\" This file was written by Geoff Thorpe <geoff@openssl.org> | ||
| 6 | .\" with contributions from Paul Yang <yang.yang@baishancloud.com>. | ||
| 7 | .\" Copyright (c) 2002, 2004, 2007, 2015, 2017 The OpenSSL Project. | ||
| 8 | .\" All rights reserved. | ||
| 9 | .\" | ||
| 10 | .\" Redistribution and use in source and binary forms, with or without | ||
| 11 | .\" modification, are permitted provided that the following conditions | ||
| 12 | .\" are met: | ||
| 13 | .\" | ||
| 14 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 15 | .\" notice, this list of conditions and the following disclaimer. | ||
| 16 | .\" | ||
| 17 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 18 | .\" notice, this list of conditions and the following disclaimer in | ||
| 19 | .\" the documentation and/or other materials provided with the | ||
| 20 | .\" distribution. | ||
| 21 | .\" | ||
| 22 | .\" 3. All advertising materials mentioning features or use of this | ||
| 23 | .\" software must display the following acknowledgment: | ||
| 24 | .\" "This product includes software developed by the OpenSSL Project | ||
| 25 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 26 | .\" | ||
| 27 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 28 | .\" endorse or promote products derived from this software without | ||
| 29 | .\" prior written permission. For written permission, please contact | ||
| 30 | .\" openssl-core@openssl.org. | ||
| 31 | .\" | ||
| 32 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 33 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 34 | .\" permission of the OpenSSL Project. | ||
| 35 | .\" | ||
| 36 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 37 | .\" acknowledgment: | ||
| 38 | .\" "This product includes software developed by the OpenSSL Project | ||
| 39 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 40 | .\" | ||
| 41 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 42 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 44 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 45 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 46 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 47 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 48 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 49 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 50 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 51 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 52 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 53 | .\" | ||
| 54 | .Dd $Mdocdate: April 15 2018 $ | ||
| 55 | .Dt ENGINE 3 | ||
| 56 | .Os | ||
| 57 | .Sh NAME | ||
| 58 | .Nm engine | ||
| 59 | .Nd ENGINE cryptographic module support | ||
| 60 | .Sh DESCRIPTION | ||
| 61 | These functions create, manipulate, and use cryptographic modules | ||
| 62 | in the form of | ||
| 63 | .Vt ENGINE | ||
| 64 | objects. | ||
| 65 | These objects act as containers for implementations of cryptographic | ||
| 66 | algorithms, and support a reference-counted mechanism to allow them to | ||
| 67 | be dynamically loaded in and out of the running application. | ||
| 68 | .Pp | ||
| 69 | The cryptographic functionality that can be provided by an | ||
| 70 | .Vt ENGINE | ||
| 71 | implementation includes the following abstractions: | ||
| 72 | .Pp | ||
| 73 | .Bl -bullet -compact | ||
| 74 | .It | ||
| 75 | .Vt RSA_METHOD : | ||
| 76 | for providing alternative RSA implementations | ||
| 77 | .It | ||
| 78 | .Vt DSA_METHOD , DH_METHOD , RAND_METHOD , ECDH_METHOD , | ||
| 79 | .Vt ECDSA_METHOD , STORE_METHOD : | ||
| 80 | similarly for other OpenSSL APIs | ||
| 81 | .It | ||
| 82 | .Vt EVP_CIPHER : | ||
| 83 | potentially multiple cipher algorithms (indexed by 'nid') | ||
| 84 | .It | ||
| 85 | .Vt EVP_DIGEST : | ||
| 86 | potentially multiple hash algorithms (indexed by 'nid') | ||
| 87 | .It | ||
| 88 | key-loading: loading public and/or private EVP_PKEY keys | ||
| 89 | .El | ||
| 90 | .Ss Reference counting and handles | ||
| 91 | Due to the modular nature of the | ||
| 92 | .Nm engine | ||
| 93 | API, pointers to | ||
| 94 | .Vt ENGINE Ns s | ||
| 95 | need to be treated as handles - i.e. not only as pointers, but also | ||
| 96 | as references to the underlying | ||
| 97 | .Vt ENGINE | ||
| 98 | object. | ||
| 99 | One should obtain a new reference when making copies of an | ||
| 100 | .Vt ENGINE | ||
| 101 | pointer if the copies will be used (and released) independently. | ||
| 102 | .Pp | ||
| 103 | .Vt ENGINE | ||
| 104 | objects have two levels of reference-counting to match the way in | ||
| 105 | which the objects are used. | ||
| 106 | At the most basic level, each | ||
| 107 | .Vt ENGINE | ||
| 108 | pointer is inherently a | ||
| 109 | .Sy structural | ||
| 110 | reference - a structural reference is required to use the pointer value | ||
| 111 | at all, as this kind of reference is a guarantee that the structure cannot | ||
| 112 | be deallocated until the reference is released. | ||
| 113 | .Pp | ||
| 114 | However, a structural reference provides no guarantee that the | ||
| 115 | .Vt ENGINE | ||
| 116 | is initialised and able to use any of its cryptographic implementations. | ||
| 117 | Indeed it's quite possible that most | ||
| 118 | .Vt ENGINE Ns s | ||
| 119 | will not initialise at all in typical environments, as | ||
| 120 | .Vt ENGINE Ns s | ||
| 121 | are typically used to support specialised hardware. | ||
| 122 | To use an | ||
| 123 | .Vt ENGINE Ap s | ||
| 124 | functionality, you need a | ||
| 125 | .Sy functional | ||
| 126 | reference. | ||
| 127 | This kind of reference can be considered a specialised form of | ||
| 128 | structural reference, because each functional reference implicitly | ||
| 129 | contains a structural reference as well - however to avoid | ||
| 130 | difficult-to-find programming bugs, it is recommended to treat the two | ||
| 131 | kinds of reference independently. | ||
| 132 | If you have a functional reference to an | ||
| 133 | .Vt ENGINE , | ||
| 134 | you have a guarantee that the | ||
| 135 | .Vt ENGINE | ||
| 136 | has been initialised and is ready to perform cryptographic operations and | ||
| 137 | will remain uninitialised until after you have released your | ||
| 138 | reference. | ||
| 139 | .Pp | ||
| 140 | .Em Structural references | ||
| 141 | .Pp | ||
| 142 | This basic type of reference is used for instantiating new | ||
| 143 | .Vt ENGINE Ns s , | ||
| 144 | iterating across OpenSSL's internal linked-list of loaded | ||
| 145 | .Vt ENGINE Ns s , | ||
| 146 | reading information about an | ||
| 147 | .Vt ENGINE , | ||
| 148 | etc. | ||
| 149 | Essentially a structural reference is sufficient if you only need to | ||
| 150 | query or manipulate the data of an | ||
| 151 | .Vt ENGINE | ||
| 152 | implementation rather than use its functionality. | ||
| 153 | .Ss Application requirements | ||
| 154 | This section will explain the basic things an application programmer | ||
| 155 | should support to make the most useful elements of the | ||
| 156 | .Nm engine | ||
| 157 | functionality available to the user. | ||
| 158 | The first thing to consider is whether the programmer wishes to make | ||
| 159 | alternative | ||
| 160 | .Vt ENGINE | ||
| 161 | modules available to the application and user. | ||
| 162 | OpenSSL maintains an internal linked list of "visible" | ||
| 163 | .Vt ENGINE Ns s | ||
| 164 | from which it has to operate. | ||
| 165 | At start-up, this list is empty, and in fact if an application does | ||
| 166 | not call any | ||
| 167 | .Nm engine | ||
| 168 | API calls and it uses static | ||
| 169 | linking against openssl, then the resulting application binary will | ||
| 170 | not contain any alternative | ||
| 171 | .Nm engine | ||
| 172 | code at all. | ||
| 173 | So the first consideration is whether any/all available | ||
| 174 | .Vt ENGINE | ||
| 175 | implementations should be made visible to OpenSSL. | ||
| 176 | .Pp | ||
| 177 | Having called any of these functions, | ||
| 178 | .Vt ENGINE | ||
| 179 | objects would have been dynamically allocated and populated with | ||
| 180 | these implementations and linked into OpenSSL's internal linked | ||
| 181 | list. | ||
| 182 | .Pp | ||
| 183 | The fact that | ||
| 184 | .Vt ENGINE Ns s | ||
| 185 | are made visible to OpenSSL (and thus are linked into the program | ||
| 186 | and loaded into memory at run-time) does not mean they are "registered" | ||
| 187 | or called into use by OpenSSL automatically - that behaviour is | ||
| 188 | something for the application to control. | ||
| 189 | Some applications will want to allow the user to specify exactly which | ||
| 190 | .Vt ENGINE | ||
| 191 | they want used if any is to be used at all. | ||
| 192 | Others may prefer to load all support and have OpenSSL automatically use | ||
| 193 | at run-time any | ||
| 194 | .Vt ENGINE | ||
| 195 | that is able to successfully initialised - i.e. to assume that this | ||
| 196 | corresponds to acceleration hardware attached to the machine or | ||
| 197 | some such thing. | ||
| 198 | There are probably numerous other ways in which applications may prefer | ||
| 199 | to handle things, so we will simply illustrate the consequences as they | ||
| 200 | apply to a couple of simple cases and leave developers to consider these | ||
| 201 | and the source code to openssl's builtin utilities as guides. | ||
| 202 | .Pp | ||
| 203 | .Em Using a specific ENGINE implementation | ||
| 204 | .Pp | ||
| 205 | Here we'll assume an application has been configured by its user or | ||
| 206 | admin to want to use the "ACME" | ||
| 207 | .Vt ENGINE | ||
| 208 | if it is available in the version of OpenSSL the application was | ||
| 209 | compiled with. | ||
| 210 | If it is available, it should be used by default for all RSA, DSA, and | ||
| 211 | symmetric cipher operations, otherwise OpenSSL should use its builtin | ||
| 212 | software as usual. | ||
| 213 | The following code illustrates how to approach this: | ||
| 214 | .Bd -literal | ||
| 215 | ENGINE *e; | ||
| 216 | const char *engine_id = "ACME"; | ||
| 217 | ENGINE_load_builtin_engines(); | ||
| 218 | e = ENGINE_by_id(engine_id); | ||
| 219 | if (!e) | ||
| 220 | /* the engine isn't available */ | ||
| 221 | return; | ||
| 222 | if (!ENGINE_init(e)) { | ||
| 223 | /* the engine couldn't initialise, release 'e' */ | ||
| 224 | ENGINE_free(e); | ||
| 225 | return; | ||
| 226 | } | ||
| 227 | if (!ENGINE_set_default_RSA(e)) | ||
| 228 | /* This should only happen when 'e' can't initialise, but the previous | ||
| 229 | * statement suggests it did. */ | ||
| 230 | abort(); | ||
| 231 | ENGINE_set_default_DSA(e); | ||
| 232 | ENGINE_set_default_ciphers(e); | ||
| 233 | /* Release the functional reference from ENGINE_init() */ | ||
| 234 | ENGINE_finish(e); | ||
| 235 | /* Release the structural reference from ENGINE_by_id() */ | ||
| 236 | ENGINE_free(e); | ||
| 237 | .Ed | ||
| 238 | .Pp | ||
| 239 | .Em Automatically using builtin ENGINE implementations | ||
| 240 | .Pp | ||
| 241 | Here we'll assume we want to load and register all | ||
| 242 | .Vt ENGINE | ||
| 243 | implementations bundled with OpenSSL, such that for any cryptographic | ||
| 244 | algorithm required by OpenSSL - if there is an | ||
| 245 | .Vt ENGINE | ||
| 246 | that implements it and can be initialised, it should be used. | ||
| 247 | The following code illustrates how this can work; | ||
| 248 | .Bd -literal | ||
| 249 | /* Load all bundled ENGINEs into memory and make them visible */ | ||
| 250 | ENGINE_load_builtin_engines(); | ||
| 251 | /* Register all of them for every algorithm they collectively implement */ | ||
| 252 | ENGINE_register_all_complete(); | ||
| 253 | .Ed | ||
| 254 | .Pp | ||
| 255 | That's all that's required. | ||
| 256 | For example, the next time OpenSSL tries to set up an RSA key, any bundled | ||
| 257 | .Vt ENGINE Ns s | ||
| 258 | that implement | ||
| 259 | .Vt RSA_METHOD | ||
| 260 | will be passed to | ||
| 261 | .Xr ENGINE_init 3 | ||
| 262 | and if any of those succeed, that | ||
| 263 | .Vt ENGINE | ||
| 264 | will be set as the default for RSA use from then on. | ||
| 265 | .Ss Advanced configuration support | ||
| 266 | There is a mechanism supported by the | ||
| 267 | .Nm engine | ||
| 268 | framework that allows each | ||
| 269 | .Vt ENGINE | ||
| 270 | implementation to define an arbitrary set of configuration | ||
| 271 | "commands" and expose them to OpenSSL and any applications based on | ||
| 272 | OpenSSL. | ||
| 273 | This mechanism is entirely based on the use of name-value pairs | ||
| 274 | and assumes ASCII input (no unicode or UTF for now!), so it is ideal if | ||
| 275 | applications want to provide a transparent way for users to provide | ||
| 276 | arbitrary configuration "directives" directly to such | ||
| 277 | .Vt ENGINE Ns s . | ||
| 278 | It is also possible for the application to dynamically interrogate the | ||
| 279 | loaded | ||
| 280 | .Vt ENGINE | ||
| 281 | implementations for the names, descriptions, and input flags of | ||
| 282 | their available "control commands", providing a more flexible | ||
| 283 | configuration scheme. | ||
| 284 | However, if the user is expected to know which | ||
| 285 | .Vt ENGINE | ||
| 286 | device he/she is using (in the case of specialised hardware, this | ||
| 287 | goes without saying) then applications may not need to concern | ||
| 288 | themselves with discovering the supported control commands and | ||
| 289 | simply prefer to pass settings into | ||
| 290 | .Vt ENGINE s | ||
| 291 | exactly as they are provided by the user. | ||
| 292 | .Pp | ||
| 293 | Before illustrating how control commands work, it is worth mentioning | ||
| 294 | what they are typically used for. | ||
| 295 | Broadly speaking there are two uses for control commands; the first is | ||
| 296 | to provide the necessary details to the implementation (which may know | ||
| 297 | nothing at all specific to the host system) so that it can be | ||
| 298 | initialised for use. | ||
| 299 | This could include the path to any driver or config files it needs to | ||
| 300 | load, required network addresses, smart-card identifiers, passwords to | ||
| 301 | initialise protected devices, logging information, etc. | ||
| 302 | This class of commands typically needs to be passed to an | ||
| 303 | .Vt ENGINE | ||
| 304 | .Sy before | ||
| 305 | attempting to initialise it, i.e. before calling | ||
| 306 | .Xr ENGINE_init 3 . | ||
| 307 | The other class of commands consist of settings or operations that tweak | ||
| 308 | certain behaviour or cause certain operations to take place, and these | ||
| 309 | commands may work either before or after | ||
| 310 | .Xr ENGINE_init 3 , | ||
| 311 | or in some cases both. | ||
| 312 | .Vt ENGINE | ||
| 313 | implementations should provide indications of this in the descriptions | ||
| 314 | attached to builtin control commands and/or in external product | ||
| 315 | documentation. | ||
| 316 | .Pp | ||
| 317 | .Em Issuing control commands to an ENGINE | ||
| 318 | .Pp | ||
| 319 | Let's illustrate by example; a function for which the caller supplies | ||
| 320 | the name of the | ||
| 321 | .Vt ENGINE | ||
| 322 | it wishes to use, a table of string-pairs for use before initialisation, | ||
| 323 | and another table for use after initialisation. | ||
| 324 | Note that the string-pairs used for control commands consist of a | ||
| 325 | command "name" followed by the command "parameter" - the parameter | ||
| 326 | could be | ||
| 327 | .Dv NULL | ||
| 328 | in some cases but the name cannot. | ||
| 329 | This function should initialise the | ||
| 330 | .Vt ENGINE | ||
| 331 | (issuing the "pre" commands beforehand and the "post" commands | ||
| 332 | afterwards) and set it as the default for everything except RAND | ||
| 333 | and then return a boolean success or failure. | ||
| 334 | .Bd -literal | ||
| 335 | int | ||
| 336 | generic_load_engine_fn(const char *engine_id, | ||
| 337 | const char **pre_cmds, int pre_num, | ||
| 338 | const char **post_cmds, int post_num) | ||
| 339 | { | ||
| 340 | ENGINE *e = ENGINE_by_id(engine_id); | ||
| 341 | |||
| 342 | if (!e) | ||
| 343 | return 0; | ||
| 344 | while (pre_num--) { | ||
| 345 | if (!ENGINE_ctrl_cmd_string(e, | ||
| 346 | pre_cmds[0], pre_cmds[1], 0)) { | ||
| 347 | fprintf(stderr, | ||
| 348 | "Failed command (%s - %s:%s)\en", | ||
| 349 | engine_id, pre_cmds[0], | ||
| 350 | pre_cmds[1] ? pre_cmds[1] : "(NULL)"); | ||
| 351 | ENGINE_free(e); | ||
| 352 | return 0; | ||
| 353 | } | ||
| 354 | pre_cmds += 2; | ||
| 355 | } | ||
| 356 | if (!ENGINE_init(e)) { | ||
| 357 | fprintf(stderr, "Failed initialisation\en"); | ||
| 358 | ENGINE_free(e); | ||
| 359 | return 0; | ||
| 360 | } | ||
| 361 | /* | ||
| 362 | * ENGINE_init() returned a functional reference, | ||
| 363 | * so free the structural reference from | ||
| 364 | * ENGINE_by_id(). | ||
| 365 | */ | ||
| 366 | ENGINE_free(e); | ||
| 367 | while (post_num--) { | ||
| 368 | if (!ENGINE_ctrl_cmd_string(e, | ||
| 369 | post_cmds[0], post_cmds[1], 0)) { | ||
| 370 | fprintf(stderr, | ||
| 371 | "Failed command (%s - %s:%s)\en", | ||
| 372 | engine_id, post_cmds[0], | ||
| 373 | post_cmds[1] ? post_cmds[1] : "(NULL)"); | ||
| 374 | ENGINE_finish(e); | ||
| 375 | return 0; | ||
| 376 | } | ||
| 377 | post_cmds += 2; | ||
| 378 | } | ||
| 379 | ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND); | ||
| 380 | /* Success */ | ||
| 381 | return 1; | ||
| 382 | } | ||
| 383 | .Ed | ||
| 384 | .Pp | ||
| 385 | Note that | ||
| 386 | .Fn ENGINE_ctrl_cmd_string | ||
| 387 | accepts a boolean argument that can relax the semantics of the function. | ||
| 388 | If set to non-zero it will only return failure if the | ||
| 389 | .Vt ENGINE | ||
| 390 | supported the given command name but failed while executing it, if the | ||
| 391 | .Vt ENGINE | ||
| 392 | doesn't support the command name it will simply return success without | ||
| 393 | doing anything. | ||
| 394 | In this case we assume the user is only supplying commands specific to | ||
| 395 | the given | ||
| 396 | .Vt ENGINE | ||
| 397 | so we set this to FALSE. | ||
| 398 | .Pp | ||
| 399 | .Em Discovering supported control commands | ||
| 400 | .Pp | ||
| 401 | It is possible to discover at run-time the names, numerical-ids, | ||
| 402 | descriptions and input parameters of the control commands supported by an | ||
| 403 | .Vt ENGINE | ||
| 404 | using a structural reference. | ||
| 405 | Note that some control commands are defined by OpenSSL itself and it | ||
| 406 | will intercept and handle these control commands on behalf of the | ||
| 407 | .Vt ENGINE , | ||
| 408 | i.e. the | ||
| 409 | .Vt ENGINE Ap s | ||
| 410 | ctrl() handler is not used for the control command. | ||
| 411 | .In openssl/engine.h | ||
| 412 | defines an index, | ||
| 413 | .Dv ENGINE_CMD_BASE , | ||
| 414 | that all control commands implemented by | ||
| 415 | .Vt ENGINE Ns s | ||
| 416 | should be numbered from. | ||
| 417 | Any command value lower than this symbol is considered a "generic" | ||
| 418 | command is handled directly by the OpenSSL core routines. | ||
| 419 | .Pp | ||
| 420 | It is using these "core" control commands that one can discover the | ||
| 421 | control commands implemented by a given | ||
| 422 | .Vt ENGINE , | ||
| 423 | specifically the commands: | ||
| 424 | .Bd -literal | ||
| 425 | #define ENGINE_HAS_CTRL_FUNCTION 10 | ||
| 426 | #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 | ||
| 427 | #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 | ||
| 428 | #define ENGINE_CTRL_GET_CMD_FROM_NAME 13 | ||
| 429 | #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 | ||
| 430 | #define ENGINE_CTRL_GET_NAME_FROM_CMD 15 | ||
| 431 | #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 | ||
| 432 | #define ENGINE_CTRL_GET_DESC_FROM_CMD 17 | ||
| 433 | #define ENGINE_CTRL_GET_CMD_FLAGS 18 | ||
| 434 | .Ed | ||
| 435 | .Pp | ||
| 436 | Whilst these commands are automatically processed by the OpenSSL | ||
| 437 | framework code, they use various properties exposed by each | ||
| 438 | .Vt ENGINE | ||
| 439 | to process these queries. | ||
| 440 | An | ||
| 441 | .Vt ENGINE | ||
| 442 | has 3 properties it exposes that can affect how this behaves; | ||
| 443 | it can supply a ctrl() handler, it can specify | ||
| 444 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 445 | in the | ||
| 446 | .Vt ENGINE Ap s | ||
| 447 | flags, and it can expose an array of control command descriptions. | ||
| 448 | If an | ||
| 449 | .Vt ENGINE | ||
| 450 | specifies the | ||
| 451 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 452 | flag, then it will simply pass all these "core" control commands | ||
| 453 | directly to the | ||
| 454 | .Vt ENGINE Ap s | ||
| 455 | ctrl() handler (and thus, it must have supplied one), so it is up | ||
| 456 | to the | ||
| 457 | .Vt ENGINE | ||
| 458 | to reply to these "discovery" commands itself. | ||
| 459 | If that flag is not set, then the OpenSSL framework code will work with | ||
| 460 | the following rules; | ||
| 461 | .Bl -tag -width Ds | ||
| 462 | .It If no ctrl() handler is supplied: | ||
| 463 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 464 | returns FALSE (zero), all other commands fail. | ||
| 465 | .It If a ctrl() handler was supplied but no array of control commands: | ||
| 466 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 467 | returns TRUE, all other commands fail. | ||
| 468 | .It If a ctrl() handler and array of control commands was supplied: | ||
| 469 | .Dv ENGINE_HAS_CTRL_FUNCTION | ||
| 470 | returns TRUE, all other commands proceed processing... | ||
| 471 | .El | ||
| 472 | .Pp | ||
| 473 | If the | ||
| 474 | .Vt ENGINE Ns s | ||
| 475 | array of control commands is empty, then all other commands will fail. | ||
| 476 | Otherwise | ||
| 477 | .Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE | ||
| 478 | returns the identifier of the first command supported by the | ||
| 479 | .Vt ENGINE , | ||
| 480 | .Dv ENGINE_GET_NEXT_CMD_TYPE | ||
| 481 | takes the identifier of a command supported by the | ||
| 482 | .Vt ENGINE | ||
| 483 | and returns the next command identifier or fails if there are no more, | ||
| 484 | .Dv ENGINE_CMD_FROM_NAME | ||
| 485 | takes a string name for a command and returns the corresponding | ||
| 486 | identifier or fails if no such command name exists, and the remaining | ||
| 487 | commands take a command identifier and return properties of the | ||
| 488 | corresponding commands. | ||
| 489 | All except | ||
| 490 | .Dv ENGINE_CTRL_GET_FLAGS | ||
| 491 | return the string length of a command name or description, or | ||
| 492 | populate a supplied character buffer with a copy of the command | ||
| 493 | name or description. | ||
| 494 | .Dv ENGINE_CTRL_GET_FLAGS | ||
| 495 | returns a bitwise-OR'd mask of the following possible values: | ||
| 496 | .Bd -literal | ||
| 497 | #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 | ||
| 498 | #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 | ||
| 499 | #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 | ||
| 500 | #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 | ||
| 501 | .Ed | ||
| 502 | .Pp | ||
| 503 | If the | ||
| 504 | .Dv ENGINE_CMD_FLAG_INTERNAL | ||
| 505 | flag is set, then any other flags are purely informational to the caller. | ||
| 506 | This flag will prevent the command being usable for any higher-level | ||
| 507 | .Vt ENGINE | ||
| 508 | functions such as | ||
| 509 | .Fn ENGINE_ctrl_cmd_string . | ||
| 510 | "INTERNAL" commands are not intended to be exposed to text-based | ||
| 511 | configuration by applications, administrations, users, etc. | ||
| 512 | These can support arbitrary operations via | ||
| 513 | .Fn ENGINE_ctrl , | ||
| 514 | including passing to and/or from the control commands data of any | ||
| 515 | arbitrary type. | ||
| 516 | These commands are supported in the discovery mechanisms simply allow | ||
| 517 | applications to determine if an | ||
| 518 | .Vt ENGINE | ||
| 519 | supports certain specific commands it might want to use (e.g. | ||
| 520 | application "foo" might query various | ||
| 521 | .Vt ENGINE Ns s | ||
| 522 | to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and | ||
| 523 | .Vt ENGINE | ||
| 524 | could therefore decide whether or not to support this "foo"-specific | ||
| 525 | extension). | ||
| 526 | .Sh SEE ALSO | ||
| 527 | .Xr DH_new 3 , | ||
| 528 | .Xr DSA_new 3 , | ||
| 529 | .Xr ENGINE_add_conf_module 3 , | ||
| 530 | .Xr ENGINE_set_ex_data 3 , | ||
| 531 | .Xr RSA_new 3 | ||
| 532 | .Sh HISTORY | ||
| 533 | The engine API first appeared in OpenSSL 0.9.7 | ||
| 534 | and has been available since | ||
| 535 | .Ox 3.2 . | ||
