diff options
Diffstat (limited to 'src/lib/libcrypto/man/ENGINE_ctrl.3')
| -rw-r--r-- | src/lib/libcrypto/man/ENGINE_ctrl.3 | 428 |
1 files changed, 428 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/ENGINE_ctrl.3 b/src/lib/libcrypto/man/ENGINE_ctrl.3 new file mode 100644 index 0000000000..1672f2976e --- /dev/null +++ b/src/lib/libcrypto/man/ENGINE_ctrl.3 | |||
| @@ -0,0 +1,428 @@ | |||
| 1 | .\" $OpenBSD: ENGINE_ctrl.3,v 1.1 2018/04/15 01:43:45 schwarze Exp $ | ||
| 2 | .\" content checked up to: | ||
| 3 | .\" OpenSSL ENGINE_add 1f13ad31 Dec 25 17:50:39 2017 +0800 | ||
| 4 | .\" | ||
| 5 | .\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> | ||
| 6 | .\" | ||
| 7 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 8 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 9 | .\" copyright notice and this permission notice appear in all copies. | ||
| 10 | .\" | ||
| 11 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 12 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 13 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 14 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 15 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 16 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 17 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 18 | .\" | ||
| 19 | .Dd $Mdocdate: April 15 2018 $ | ||
| 20 | .Dt ENGINE_CTRL 3 | ||
| 21 | .Os | ||
| 22 | .Sh NAME | ||
| 23 | .Nm ENGINE_ctrl , | ||
| 24 | .Nm ENGINE_cmd_is_executable , | ||
| 25 | .Nm ENGINE_ctrl_cmd , | ||
| 26 | .Nm ENGINE_ctrl_cmd_string , | ||
| 27 | .Nm ENGINE_set_ctrl_function , | ||
| 28 | .Nm ENGINE_get_ctrl_function , | ||
| 29 | .Nm ENGINE_set_cmd_defns , | ||
| 30 | .Nm ENGINE_get_cmd_defns | ||
| 31 | .Nd control commands for ENGINE objects | ||
| 32 | .Sh SYNOPSIS | ||
| 33 | .In openssl/engine.h | ||
| 34 | .Fo ENGINE_ctrl | ||
| 35 | .Fa "ENGINE *e" | ||
| 36 | .Fa "int cmd" | ||
| 37 | .Fa "long i" | ||
| 38 | .Fa "void *p" | ||
| 39 | .Fa "void (*f)(void)" | ||
| 40 | .Fc | ||
| 41 | .Ft int | ||
| 42 | .Fo ENGINE_cmd_is_executable | ||
| 43 | .Fa "ENGINE *e" | ||
| 44 | .Fa "int cmd" | ||
| 45 | .Fc | ||
| 46 | .Ft int | ||
| 47 | .Fo ENGINE_ctrl_cmd | ||
| 48 | .Fa "ENGINE *e" | ||
| 49 | .Fa "const char *cmd_name" | ||
| 50 | .Fa "long i" | ||
| 51 | .Fa "void *p" | ||
| 52 | .Fa "void (*f)(void)" | ||
| 53 | .Fa "int cmd_optional" | ||
| 54 | .Fc | ||
| 55 | .Ft int | ||
| 56 | .Fo ENGINE_ctrl_cmd_string | ||
| 57 | .Fa "ENGINE *e" | ||
| 58 | .Fa "const char *cmd_name" | ||
| 59 | .Fa "const char *arg" | ||
| 60 | .Fa "int cmd_optional" | ||
| 61 | .Fc | ||
| 62 | .Ft typedef int | ||
| 63 | .Fo (*ENGINE_CTRL_FUNC_PTR) | ||
| 64 | .Fa "ENGINE *e" | ||
| 65 | .Fa "int cmd" | ||
| 66 | .Fa "long i" | ||
| 67 | .Fa "void *p" | ||
| 68 | .Fa "void (*f)(void)" | ||
| 69 | .Fc | ||
| 70 | .Ft int | ||
| 71 | .Fo ENGINE_set_ctrl_function | ||
| 72 | .Fa "ENGINE *e" | ||
| 73 | .Fa "ENGINE_CTRL_FUNC_PTR ctrl_f" | ||
| 74 | .Fc | ||
| 75 | .Ft ENGINE_CTRL_FUNC_PTR | ||
| 76 | .Fo ENGINE_get_ctrl_function | ||
| 77 | .Fa "const ENGINE *e" | ||
| 78 | .Fc | ||
| 79 | .Ft int | ||
| 80 | .Fo ENGINE_set_cmd_defns | ||
| 81 | .Fa "ENGINE *e" | ||
| 82 | .Fa "const ENGINE_CMD_DEFN *defns" | ||
| 83 | .Fc | ||
| 84 | .Ft const ENGINE_CMD_DEFN * | ||
| 85 | .Fo ENGINE_get_cmd_defns | ||
| 86 | .Fa "const ENGINE *e" | ||
| 87 | .Fc | ||
| 88 | .Sh DESCRIPTION | ||
| 89 | .Fn ENGINE_ctrl | ||
| 90 | calls the built-in or user-defined | ||
| 91 | .Fa cmd | ||
| 92 | for the engine | ||
| 93 | .Fa e , | ||
| 94 | passing the arguments | ||
| 95 | .Fa i | ||
| 96 | and | ||
| 97 | .Fa p . | ||
| 98 | .Pp | ||
| 99 | Most built-in commands operate on user-defined commands installed with | ||
| 100 | .Fn ENGINE_set_cmd_defns , | ||
| 101 | either using the | ||
| 102 | .Fa p | ||
| 103 | argument to indicate the user-defined command with the command name | ||
| 104 | .Fa cmd_name | ||
| 105 | or using the | ||
| 106 | .Fa i | ||
| 107 | argument to indicate the user-defined command with the command number | ||
| 108 | .Fa cmd_num . | ||
| 109 | The | ||
| 110 | .Fa cmd | ||
| 111 | arguments to call the built-in commands are as follows: | ||
| 112 | .Bl -tag -width Ds | ||
| 113 | .It Dv ENGINE_CTRL_GET_CMD_FLAGS | ||
| 114 | Return the | ||
| 115 | .Fa cmd_flags | ||
| 116 | of the user-defined command with the number | ||
| 117 | .Fa i , | ||
| 118 | or a number less than or equal to 0 if an error occurs or | ||
| 119 | the command number does not exist. | ||
| 120 | A return value of 0 indicates failure if | ||
| 121 | .Fa e | ||
| 122 | is | ||
| 123 | .Dv NULL | ||
| 124 | or has a reference count of 0, or success if | ||
| 125 | .Fa e | ||
| 126 | is valid. | ||
| 127 | .It Dv ENGINE_CTRL_GET_CMD_FROM_NAME | ||
| 128 | Return the positive command number | ||
| 129 | of the user-defined command with the name | ||
| 130 | .Fa p , | ||
| 131 | or a number less than or equal to 0 if an error occurs or no | ||
| 132 | matching name is found. | ||
| 133 | .It Dv ENGINE_CTRL_GET_DESC_FROM_CMD | ||
| 134 | Copy the description of the user-defined command with the number | ||
| 135 | .Fa i | ||
| 136 | into the buffer | ||
| 137 | .Fa p | ||
| 138 | and NUL-terminate it. | ||
| 139 | It is the reponsability of the caller to make sure that the buffer | ||
| 140 | .Fa p | ||
| 141 | is large enough, either by calling | ||
| 142 | .Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD | ||
| 143 | first or using knowledge about the array passed to | ||
| 144 | .Fn ENGINE_set_cmd_defns . | ||
| 145 | The return value is the number of bytes written | ||
| 146 | .Em including | ||
| 147 | the terminating NUL byte, or a number less than or equal to 0 | ||
| 148 | if an error occurs. | ||
| 149 | .It Dv ENGINE_CTRL_GET_DESC_LEN_FROM_CMD | ||
| 150 | Return the length in bytes | ||
| 151 | .Em excluding | ||
| 152 | the terminating NUL byte | ||
| 153 | of the description of the user-defined command with the number | ||
| 154 | .Fa i , | ||
| 155 | or a number less than or equal to 0 if an error occurs. | ||
| 156 | A return value of 0 indicates failure if | ||
| 157 | .Fa e | ||
| 158 | is | ||
| 159 | .Dv NULL | ||
| 160 | or has a reference count of 0, or success if | ||
| 161 | .Fa e | ||
| 162 | is valid. | ||
| 163 | .It Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE | ||
| 164 | Return the positive command number | ||
| 165 | of the first user-defined command installed with | ||
| 166 | .Fn ENGINE_set_cmd_defns | ||
| 167 | or a number less than or equal to 0 if an error occurs or no | ||
| 168 | user-defined command has been installed. | ||
| 169 | .It Dv ENGINE_CTRL_GET_NAME_FROM_CMD | ||
| 170 | Copy the name of the user-defined command with the number | ||
| 171 | .Fa i | ||
| 172 | into the buffer | ||
| 173 | .Fa p | ||
| 174 | and NUL-terminate it. | ||
| 175 | It is the reponsability of the caller to make sure that the buffer | ||
| 176 | .Fa p | ||
| 177 | is large enough, either by calling | ||
| 178 | .Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD | ||
| 179 | first or using knowledge about the array passed to | ||
| 180 | .Fn ENGINE_set_cmd_defns . | ||
| 181 | The return value is the number of bytes written | ||
| 182 | .Em including | ||
| 183 | the terminating NUL byte, or a number less than or equal to 0 | ||
| 184 | if an error occurs. | ||
| 185 | .It Dv ENGINE_CTRL_GET_NAME_LEN_FROM_CMD | ||
| 186 | Return the length in bytes | ||
| 187 | .Em excluding | ||
| 188 | the terminating NULL byte | ||
| 189 | of the name of the user-defined command with the number | ||
| 190 | .Fa i , | ||
| 191 | or a number less than or equal to 0 if an error occurs. | ||
| 192 | A return value of 0 indicates failure if | ||
| 193 | .Fa e | ||
| 194 | is | ||
| 195 | .Dv NULL | ||
| 196 | or has a reference count of 0, or success if | ||
| 197 | .Fa e | ||
| 198 | is valid. | ||
| 199 | .It Dv ENGINE_CTRL_GET_NEXT_CMD_TYPE | ||
| 200 | Return the positive command number of the next user-defined command | ||
| 201 | after the user-defined command with the number | ||
| 202 | .Fa i , | ||
| 203 | or a number less than or equal to 0 if an error occurs or if | ||
| 204 | .Fa i | ||
| 205 | is the last user-defined command. | ||
| 206 | Together with | ||
| 207 | .Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE , | ||
| 208 | this can be used to iterate the user-defined commands installed with | ||
| 209 | .Fn ENGINE_set_cmd_defns . | ||
| 210 | .It Dv ENGINE_CTRL_HAS_CTRL_FUNCTION | ||
| 211 | Return 1 if | ||
| 212 | .Fa e | ||
| 213 | has its own | ||
| 214 | .Fa ctrl_f | ||
| 215 | installed with | ||
| 216 | .Fn ENGINE_set_ctrl_function | ||
| 217 | or 0 otherwise. | ||
| 218 | .El | ||
| 219 | .Pp | ||
| 220 | .Fn ENGINE_ctrl_cmd | ||
| 221 | translates the | ||
| 222 | .Fa cmd_name | ||
| 223 | of a user-defined command to a | ||
| 224 | .Fa cmd | ||
| 225 | number and calls | ||
| 226 | .Fn ENGINE_ctrl | ||
| 227 | on it. | ||
| 228 | If | ||
| 229 | .Fa cmd_optional | ||
| 230 | is non-zero, lack of a | ||
| 231 | .Fa ctrl_f | ||
| 232 | in | ||
| 233 | .Fa e | ||
| 234 | and translation failure with | ||
| 235 | .Dv ENGINE_CTRL_GET_CMD_FROM_NAME | ||
| 236 | are considered success, and the command has no effect. | ||
| 237 | Otherwise, these problems cause | ||
| 238 | .Fn ENGINE_ctrl_cmd | ||
| 239 | to fail. | ||
| 240 | .Pp | ||
| 241 | .Fn ENGINE_ctrl_cmd_string | ||
| 242 | translates the | ||
| 243 | .Fa cmd_name | ||
| 244 | of a user-defined command to a | ||
| 245 | .Fa cmd | ||
| 246 | number. | ||
| 247 | If that command has the | ||
| 248 | .Dv ENGINE_CMD_FLAG_NO_INPUT | ||
| 249 | flag set, | ||
| 250 | .Fa arg | ||
| 251 | must be | ||
| 252 | .Dv NULL | ||
| 253 | and | ||
| 254 | .Fn ENGINE_ctrl | ||
| 255 | is called with | ||
| 256 | .Fa i | ||
| 257 | set to 0 and | ||
| 258 | .Fa p | ||
| 259 | set to | ||
| 260 | .Dv NULL . | ||
| 261 | Otherwise, | ||
| 262 | .Fa arg | ||
| 263 | must not be | ||
| 264 | .Dv NULL . | ||
| 265 | If the command accepts string input, | ||
| 266 | .Fa i | ||
| 267 | is set to 0 and | ||
| 268 | .Fa arg | ||
| 269 | is passed as the | ||
| 270 | .Fa p | ||
| 271 | argument to | ||
| 272 | .Fn ENGINE_ctrl . | ||
| 273 | Otherwise, | ||
| 274 | .Fa arg | ||
| 275 | is converted with | ||
| 276 | .Xr strtol 3 | ||
| 277 | and passed as the | ||
| 278 | .Fa i | ||
| 279 | argument to | ||
| 280 | .Fn ENGINE_ctrl , | ||
| 281 | setting | ||
| 282 | .Fa p | ||
| 283 | to | ||
| 284 | .Dv NULL . | ||
| 285 | .Pp | ||
| 286 | .Fn ENGINE_set_ctrl_function | ||
| 287 | installs | ||
| 288 | .Fa ctrl_f | ||
| 289 | as the engine-specific control function for | ||
| 290 | .Fa e . | ||
| 291 | Future calls to | ||
| 292 | .Fn ENGINE_ctrl | ||
| 293 | will call that function, passing on their arguments unchanged, if the | ||
| 294 | .Fa cmd | ||
| 295 | is not built-in to the library or if the | ||
| 296 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 297 | flag is set in | ||
| 298 | .Fa e . | ||
| 299 | Let the | ||
| 300 | .Fa ctrl_f | ||
| 301 | return positive values on success or negative values on failure. | ||
| 302 | Avoid return values of 0 because they cause dangerous ambiguity. | ||
| 303 | In particular, | ||
| 304 | .Fn ENGINE_ctrl_cmd | ||
| 305 | and | ||
| 306 | .Fn ENGINE_ctrl_cmd_string | ||
| 307 | cannot be used with user-defined commands | ||
| 308 | that may return 0 on success. | ||
| 309 | .Pp | ||
| 310 | .Fn ENGINE_set_cmd_defns | ||
| 311 | install an array of command definitions in | ||
| 312 | .Fa e . | ||
| 313 | .Pp | ||
| 314 | The structure | ||
| 315 | .Vt ENGINE_CMD_DEFN | ||
| 316 | has the following fields: | ||
| 317 | .Bl -tag -width Ds | ||
| 318 | .It Fa "unsigned int cmd_num" | ||
| 319 | A positive, unique, monotonically increasing command number. | ||
| 320 | Avoid using numbers below | ||
| 321 | .Dv ENGINE_CMD_BASE . | ||
| 322 | .It Fa "const char *cmd_name" | ||
| 323 | The unique name of the command. | ||
| 324 | .It Fa "const char *cmd_desc" | ||
| 325 | A short description of the command. | ||
| 326 | .It Fa "unsigned int cmd_flags" | ||
| 327 | The bitwise OR of zero or more of the following flags: | ||
| 328 | .Bl -tag -width Ds | ||
| 329 | .It Dv ENGINE_CMD_FLAG_NUMERIC | ||
| 330 | The command uses | ||
| 331 | .Fa i . | ||
| 332 | .It Dv ENGINE_CMD_FLAG_STRING | ||
| 333 | The command uses | ||
| 334 | .Fa p . | ||
| 335 | .It Dv ENGINE_CMD_FLAG_NO_INPUT | ||
| 336 | The command neither uses | ||
| 337 | .Fa i | ||
| 338 | nor | ||
| 339 | .Fa p . | ||
| 340 | .It Dv ENGINE_CMD_FLAG_INTERNAL | ||
| 341 | This flag has no effect and is only provided for compatibility. | ||
| 342 | .El | ||
| 343 | .El | ||
| 344 | .Pp | ||
| 345 | The last element of | ||
| 346 | .Fa defns | ||
| 347 | does not specify a command, but must have a | ||
| 348 | .Fa cmd_num | ||
| 349 | of 0 and a | ||
| 350 | .Fa cmd_name | ||
| 351 | of | ||
| 352 | .Dv NULL | ||
| 353 | to indicate the end of the array. | ||
| 354 | .Sh RETURN VALUES | ||
| 355 | For | ||
| 356 | .Fn ENGINE_ctrl , | ||
| 357 | positive return values indicate success and negative return values | ||
| 358 | indicate failure. | ||
| 359 | The meaning of a zero return value depends on the particular | ||
| 360 | .Fa cmd | ||
| 361 | and may indicate both success and failure, which is pathetic. | ||
| 362 | .Pp | ||
| 363 | Regardless of the | ||
| 364 | .Fa cmd , | ||
| 365 | .Fn ENGINE_ctrl | ||
| 366 | returns 0 if | ||
| 367 | .Fa e | ||
| 368 | is | ||
| 369 | .Dv NULL | ||
| 370 | or has a reference count of 0. | ||
| 371 | This is quite unfortunate for commands like | ||
| 372 | .Dv ENGINE_CTRL_GET_CMD_FLAGS | ||
| 373 | where 0 may indicate success, so make sure | ||
| 374 | .Fa e | ||
| 375 | is valid before issuing a control command. | ||
| 376 | .Pp | ||
| 377 | For built-in commands except | ||
| 378 | .Dv ENGINE_CTRL_HAS_CTRL_FUNCTION , | ||
| 379 | .Fn ENGINE_ctrl | ||
| 380 | returns \-1 if | ||
| 381 | .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL | ||
| 382 | is set but no | ||
| 383 | .Fa ctrl_f | ||
| 384 | has been installed with | ||
| 385 | .Fn ENGINE_set_ctrl_function . | ||
| 386 | .Pp | ||
| 387 | For commands that are not built in, | ||
| 388 | .Fn ENGINE_ctrl | ||
| 389 | returns 0 if no | ||
| 390 | .Fa ctrl_f | ||
| 391 | has been installed with | ||
| 392 | .Fn ENGINE_set_ctrl_function . | ||
| 393 | .Pp | ||
| 394 | .Fn ENGINE_cmd_is_executable | ||
| 395 | returns 1 if the user-defined | ||
| 396 | .Fa cmd | ||
| 397 | is executable and has at least one of the flags | ||
| 398 | .Dv ENGINE_CMD_FLAG_NUMERIC , | ||
| 399 | .Dv ENGINE_CMD_FLAG_STRING , | ||
| 400 | and | ||
| 401 | .Dv ENGINE_CMD_FLAG_NO_INPUT | ||
| 402 | set, or 0 otherwise. | ||
| 403 | .Pp | ||
| 404 | .Fn ENGINE_ctrl_cmd | ||
| 405 | and | ||
| 406 | .Fn ENGINE_ctrl_cmd_string | ||
| 407 | return 1 on success or 0 on error. | ||
| 408 | .Pp | ||
| 409 | .Fn ENGINE_set_ctrl_function | ||
| 410 | and | ||
| 411 | .Fn ENGINE_set_cmd_defns | ||
| 412 | always return 1. | ||
| 413 | .Pp | ||
| 414 | .Fn ENGINE_get_ctrl_function | ||
| 415 | returns a pointer to the function | ||
| 416 | .Fa ctrl_f | ||
| 417 | installed with | ||
| 418 | .Fn ENGINE_set_ctrl_function , | ||
| 419 | or | ||
| 420 | .Dv NULL | ||
| 421 | if none has been installed. | ||
| 422 | .Pp | ||
| 423 | .Fn ENGINE_get_cmd_defns | ||
| 424 | returns the array of command definitions installed in | ||
| 425 | .Fa e | ||
| 426 | or | ||
| 427 | .Dv NULL | ||
| 428 | if none is installed. | ||
