1 .\" $OpenBSD: engine.3,v 1.10 2017/01/06 20:35:23 schwarze Exp $
2 .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
4 .\" This file was written by Geoff Thorpe <geoff@openssl.org>.
5 .\" Copyright (c) 2002, 2004, 2007, 2015 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: January 6 2017 $
59 .Nm ENGINE_get_first ,
64 .Nm ENGINE_load_builtin_engines ,
66 .Nd ENGINE cryptographic module support
70 .Fn ENGINE_get_first void
72 .Fn ENGINE_get_last void
102 .Fn ENGINE_load_openssl void
104 .Fn ENGINE_load_dynamic void
106 .Fn ENGINE_load_cryptodev void
108 .Fn ENGINE_load_builtin_engines void
110 .Fn ENGINE_cleanup void
112 .Fn ENGINE_get_default_RSA void
114 .Fn ENGINE_get_default_DSA void
116 .Fn ENGINE_get_default_ECDH void
118 .Fn ENGINE_get_default_ECDSA void
120 .Fn ENGINE_get_default_DH void
122 .Fn ENGINE_get_default_RAND void
124 .Fo ENGINE_get_cipher_engine
128 .Fo ENGINE_get_digest_engine
132 .Fo ENGINE_set_default_RSA
136 .Fo ENGINE_set_default_DSA
140 .Fo ENGINE_set_default_ECDH
144 .Fo ENGINE_set_default_ECDSA
148 .Fo ENGINE_set_default_DH
152 .Fo ENGINE_set_default_RAND
156 .Fo ENGINE_set_default_ciphers
160 .Fo ENGINE_set_default_digests
164 .Fo ENGINE_set_default_string
166 .Fa "const char *list"
169 .Fo ENGINE_set_default
171 .Fa "unsigned int flags"
174 .Fn ENGINE_get_table_flags void
176 .Fo ENGINE_set_table_flags
177 .Fa "unsigned int flags"
180 .Fo ENGINE_register_RSA
184 .Fo ENGINE_unregister_RSA
188 .Fn ENGINE_register_all_RSA void
190 .Fo ENGINE_register_DSA
194 .Fo ENGINE_unregister_DSA
198 .Fn ENGINE_register_all_DSA void
200 .Fo ENGINE_register_ECDH
204 .Fo ENGINE_unregister_ECDH
208 .Fn ENGINE_register_all_ECDH void
210 .Fo ENGINE_register_ECDSA
214 .Fo ENGINE_unregister_ECDSA
218 .Fn ENGINE_register_all_ECDSA void
220 .Fo ENGINE_register_DH
224 .Fo ENGINE_unregister_DH
228 .Fn ENGINE_register_all_DH void
230 .Fo ENGINE_register_RAND
234 .Fo ENGINE_unregister_RAND
238 .Fn ENGINE_register_all_RAND void
240 .Fo ENGINE_register_STORE
244 .Fo ENGINE_unregister_STORE
248 .Fn ENGINE_register_all_STORE void
250 .Fo ENGINE_register_ciphers
254 .Fo ENGINE_unregister_ciphers
258 .Fn ENGINE_register_all_ciphers void
260 .Fo ENGINE_register_digests
264 .Fo ENGINE_unregister_digests
268 .Fn ENGINE_register_all_digests void
270 .Fo ENGINE_register_complete
274 .Fn ENGINE_register_all_complete void
281 .Fa "void (*f)(void)"
284 .Fo ENGINE_cmd_is_executable
291 .Fa "const char *cmd_name"
294 .Fa "void (*f)(void)"
295 .Fa "int cmd_optional"
298 .Fo ENGINE_ctrl_cmd_string
300 .Fa "const char *cmd_name"
301 .Fa "const char *arg"
302 .Fa "int cmd_optional"
322 .Fa "const char *name"
327 .Fa "const RSA_METHOD *rsa_meth"
332 .Fa "const DSA_METHOD *dsa_meth"
337 .Fa "const ECDH_METHOD *dh_meth"
342 .Fa "const ECDSA_METHOD *dh_meth"
347 .Fa "const DH_METHOD *dh_meth"
352 .Fa "const RAND_METHOD *rand_meth"
357 .Fa "const STORE_METHOD *rand_meth"
360 .Fo ENGINE_set_destroy_function
362 .Fa "ENGINE_GEN_INT_FUNC_PTR destroy_f"
365 .Fo ENGINE_set_init_function
367 .Fa "ENGINE_GEN_INT_FUNC_PTR init_f"
370 .Fo ENGINE_set_finish_function
372 .Fa "ENGINE_GEN_INT_FUNC_PTR finish_f"
375 .Fo ENGINE_set_ctrl_function
377 .Fa "ENGINE_CTRL_FUNC_PTR ctrl_f"
380 .Fo ENGINE_set_load_privkey_function
382 .Fa "ENGINE_LOAD_KEY_PTR loadpriv_f"
385 .Fo ENGINE_set_load_pubkey_function
387 .Fa "ENGINE_LOAD_KEY_PTR loadpub_f"
390 .Fo ENGINE_set_ciphers
392 .Fa "ENGINE_CIPHERS_PTR f"
395 .Fo ENGINE_set_digests
397 .Fa "ENGINE_DIGESTS_PTR f"
405 .Fo ENGINE_set_cmd_defns
407 .Fa "const ENGINE_CMD_DEFN *defns"
411 .Fa "const ENGINE *e"
415 .Fa "const ENGINE *e"
417 .Ft const RSA_METHOD *
419 .Fa "const ENGINE *e"
421 .Ft const DSA_METHOD *
423 .Fa "const ENGINE *e"
425 .Ft const ECDH_METHOD *
427 .Fa "const ENGINE *e"
429 .Ft const ECDSA_METHOD *
431 .Fa "const ENGINE *e"
433 .Ft const DH_METHOD *
435 .Fa "const ENGINE *e"
437 .Ft const RAND_METHOD *
439 .Fa "const ENGINE *e"
441 .Ft const STORE_METHOD *
443 .Fa "const ENGINE *e"
445 .Ft ENGINE_GEN_INT_FUNC_PTR
446 .Fo ENGINE_get_destroy_function
447 .Fa "const ENGINE *e"
449 .Ft ENGINE_GEN_INT_FUNC_PTR
450 .Fo ENGINE_get_init_function
451 .Fa "const ENGINE *e"
453 .Ft ENGINE_GEN_INT_FUNC_PTR
454 .Fo ENGINE_get_finish_function
455 .Fa "const ENGINE *e"
457 .Ft ENGINE_CTRL_FUNC_PTR
458 .Fo ENGINE_get_ctrl_function
459 .Fa "const ENGINE *e"
461 .Ft ENGINE_LOAD_KEY_PTR
462 .Fo ENGINE_get_load_privkey_function
463 .Fa "const ENGINE *e"
465 .Ft ENGINE_LOAD_KEY_PTR
466 .Fo ENGINE_get_load_pubkey_function
467 .Fa "const ENGINE *e"
469 .Ft ENGINE_CIPHERS_PTR
470 .Fo ENGINE_get_ciphers
471 .Fa "const ENGINE *e"
473 .Ft ENGINE_DIGESTS_PTR
474 .Fo ENGINE_get_digests
475 .Fa "const ENGINE *e"
477 .Ft const EVP_CIPHER *
478 .Fo ENGINE_get_cipher
483 .Fo ENGINE_get_digest
489 .Fa "const ENGINE *e"
491 .Ft const ENGINE_CMD_DEFN *
492 .Fo ENGINE_get_cmd_defns
493 .Fa "const ENGINE *e"
496 .Fo ENGINE_load_private_key
498 .Fa "const char *key_id"
499 .Fa "UI_METHOD *ui_method"
500 .Fa "void *callback_data"
503 .Fo ENGINE_load_public_key
505 .Fa "const char *key_id"
506 .Fa "UI_METHOD *ui_method"
507 .Fa "void *callback_data"
510 These functions create, manipulate, and use cryptographic modules
514 These objects act as containers for implementations of cryptographic
515 algorithms, and support a reference-counted mechanism to allow them to
516 be dynamically loaded in and out of the running application.
518 The cryptographic functionality that can be provided by an
520 implementation includes the following abstractions:
525 for providing alternative RSA implementations
527 .Vt DSA_METHOD , DH_METHOD , RAND_METHOD , ECDH_METHOD ,
528 .Vt ECDSA_METHOD , STORE_METHOD :
529 similarly for other OpenSSL APIs
532 potentially multiple cipher algorithms (indexed by 'nid')
535 potentially multiple hash algorithms (indexed by 'nid')
537 key-loading: loading public and/or private EVP_PKEY keys
539 .Ss Reference counting and handles
540 Due to the modular nature of the
544 need to be treated as handles - i.e. not only as pointers, but also
545 as references to the underlying
548 One should obtain a new reference when making copies of an
550 pointer if the copies will be used (and released) independently.
553 objects have two levels of reference-counting to match the way in
554 which the objects are used.
555 At the most basic level, each
557 pointer is inherently a
559 reference - a structural reference is required to use the pointer value
560 at all, as this kind of reference is a guarantee that the structure cannot
561 be deallocated until the reference is released.
563 However, a structural reference provides no guarantee that the
565 is initialised and able to use any of its cryptographic implementations.
566 Indeed it's quite possible that most
568 will not initialise at all in typical environments, as
570 are typically used to support specialised hardware.
573 functionality, you need a
576 This kind of reference can be considered a specialised form of
577 structural reference, because each functional reference implicitly
578 contains a structural reference as well - however to avoid
579 difficult-to-find programming bugs, it is recommended to treat the two
580 kinds of reference independently.
581 If you have a functional reference to an
583 you have a guarantee that the
585 has been initialised and is ready to perform cryptographic operations and
586 will remain uninitialised until after you have released your
589 .Em Structural references
591 This basic type of reference is used for instantiating new
593 iterating across OpenSSL's internal linked-list of loaded
595 reading information about an
598 Essentially a structural reference is sufficient if you only need to
599 query or manipulate the data of an
601 implementation rather than use its functionality.
605 function returns a structural reference to a new (empty)
610 API functions that return structural references such as
612 .Fn ENGINE_get_first ,
613 .Fn ENGINE_get_last ,
614 .Fn ENGINE_get_next ,
616 .Fn ENGINE_get_prev .
617 All structural references should be released by a corresponding call
623 object itself will only actually be cleaned up and deallocated when
624 the last structural reference is released.
626 It should also be noted that many
628 API function calls that accept a structural reference will internally
629 obtain another reference.
630 Typically this happens whenever the supplied
632 will be needed by OpenSSL after the function has returned.
633 For example, the function to add a new
635 to OpenSSL's internal list is
637 If this function returns success, OpenSSL will have stored a new
638 structural reference internally so the caller is still responsible for
639 freeing their own reference with
641 when they are finished with it.
642 In a similar way, some functions will automatically release the
643 structural reference passed to it if part of the function's job is
649 functions are used for iterating across the internal
653 will return a new structural reference to the next (or previous)
657 if at the end (or beginning) of the list, but in either case the
658 structural reference passed to the function is released on behalf
661 To clarify a particular function's handling of references, one should
662 always consult that function's manual page, or failing that the
664 header file includes some hints.
666 .Em Functional references
668 As mentioned, functional references exist when the cryptographic
671 is required to be available.
672 A functional reference can be obtained in one of two ways; from an
673 existing structural reference to the required
675 or by asking OpenSSL for the default operational
677 for a given cryptographic purpose.
679 To obtain a functional reference from an existing structural reference,
683 This returns zero if the
685 was not already operational and couldn't be successfully initialised
686 (e.g. lack of system drivers, no special hardware attached),
687 otherwise it will return non-zero to indicate that the
689 is now operational and will have allocated a new
693 All functional references are released by calling
695 which removes the implicit structural reference as well.
697 The second way to get a functional reference is by asking OpenSSL for a
698 default implementation for a given task, e.g.
700 .Fn ENGINE_get_default_RSA ,
701 .Fn ENGINE_get_default_cipher_engine ,
703 These are discussed in the next section, though they are not usually
704 required by application programmers as they are used automatically when
705 creating and using the relevant algorithm-specific types in OpenSSL,
706 such as RSA, DSA, EVP_CIPHER_CTX, etc.
707 .Ss Default implementations
708 For each supported abstraction, the
710 code maintains an internal table of state to control which
711 implementations are available for a given abstraction and which
712 should be used by default.
713 These implementations are registered in the tables and indexed by an
715 value, because abstractions like
719 support many distinct algorithms and modes, and
721 can support arbitrarily many of them.
722 In the case of other abstractions like RSA, DSA, etc., there is
723 only one "algorithm" so all implementations implicitly register
730 is requested for a given abstraction/algorithm/mode, (e.g. when
732 .Fn RSA_new_method NULL ) ,
733 a "get_default" call will be made to the
735 subsystem to process the corresponding state table and return
736 a functional reference to an initialised
738 whose implementation should be used.
741 should (or can) be used, it will return
743 and the caller will operate with a
747 This usually equates to using the conventional software implementation.
748 In the latter case, OpenSSL will from then on behave the way it used to
753 Each state table has a flag to note whether it has processed this
754 "get_default" query since the table was last modified, because to
755 process this question it must iterate across all the registered
757 in the table trying to initialise each of them in turn, in case one of
759 If it returns a functional reference to an
761 it will also cache another reference to speed up processing future
762 queries (without needing to iterate across the table).
763 Likewise, it will cache a
767 was available so that future queries won't repeat the same iteration
768 unless the state table changes.
769 This behaviour can also be changed; if the
770 .Dv ENGINE_TABLE_FLAG_NOINIT
772 .Fn ENGINE_set_table_flags ) ,
773 no attempted initialisations will take place, instead the only way for
774 the state table to return a
777 to the "get_default" query will be if one is expressly set in the table.
779 .Fn ENGINE_set_default_RSA
781 .Fn ENGINE_register_RSA
782 except that it also sets the state table's cached response for the
784 In the case of abstractions like
786 where implementations are indexed by
788 these flags and cached-responses are distinct for each
791 .Ss Application requirements
792 This section will explain the basic things an application programmer
793 should support to make the most useful elements of the
795 functionality available to the user.
796 The first thing to consider is whether the programmer wishes to make
799 modules available to the application and user.
800 OpenSSL maintains an internal linked list of "visible"
802 from which it has to operate.
803 At start-up, this list is empty, and in fact if an application does
806 API calls and it uses static
807 linking against openssl, then the resulting application binary will
808 not contain any alternative
811 So the first consideration is whether any/all available
813 implementations should be made visible to OpenSSL.
814 This is controlled by calling the various "load" functions, e.g.
815 .Fn ENGINE_load_builtin_engines
818 implementations bundled with OpenSSL available.
821 .Fn ENGINE_load_dynamic
822 is a placeholder and does not enable dynamic engine loading support.
824 Having called any of these functions,
826 objects would have been dynamically allocated and populated with
827 these implementations and linked into OpenSSL's internal linked
832 API functions are called at all in an application, then there are
833 no inherent memory leaks to worry about from the
835 functionality, however if any
837 are loaded, even if they are never registered or used, it is necessary
840 function to correspondingly cleanup before program exit, if the caller
841 wishes to avoid memory leaks.
842 This mechanism uses an internal callback registration table so that any
844 API functionality that knows it requires cleanup can register its
845 cleanup details to be called during
849 to clean up after any
851 functionality at all that your program uses, yet doesn't automatically
852 create linker dependencies to all possible
854 functionality - only the cleanup callbacks required by the functionality
855 you do use will be required by the linker.
859 are made visible to OpenSSL (and thus are linked into the program
860 and loaded into memory at run-time) does not mean they are "registered"
861 or called into use by OpenSSL automatically - that behaviour is
862 something for the application to control.
863 Some applications will want to allow the user to specify exactly which
865 they want used if any is to be used at all.
866 Others may prefer to load all support and have OpenSSL automatically use
869 that is able to successfully initialised - i.e. to assume that this
870 corresponds to acceleration hardware attached to the machine or
872 There are probably numerous other ways in which applications may prefer
873 to handle things, so we will simply illustrate the consequences as they
874 apply to a couple of simple cases and leave developers to consider these
875 and the source code to openssl's builtin utilities as guides.
877 .Em Using a specific ENGINE implementation
879 Here we'll assume an application has been configured by its user or
880 admin to want to use the "ACME"
882 if it is available in the version of OpenSSL the application was
884 If it is available, it should be used by default for all RSA, DSA, and
885 symmetric cipher operations, otherwise OpenSSL should use its builtin
887 The following code illustrates how to approach this:
890 const char *engine_id = "ACME";
891 ENGINE_load_builtin_engines();
892 e = ENGINE_by_id(engine_id);
894 /* the engine isn't available */
896 if (!ENGINE_init(e)) {
897 /* the engine couldn't initialise, release 'e' */
901 if (!ENGINE_set_default_RSA(e))
902 /* This should only happen when 'e' can't initialise, but the previous
903 * statement suggests it did. */
905 ENGINE_set_default_DSA(e);
906 ENGINE_set_default_ciphers(e);
907 /* Release the functional reference from ENGINE_init() */
909 /* Release the structural reference from ENGINE_by_id() */
913 .Em Automatically using builtin ENGINE implementations
915 Here we'll assume we want to load and register all
917 implementations bundled with OpenSSL, such that for any cryptographic
918 algorithm required by OpenSSL - if there is an
920 that implements it and can be initialised, it should be used.
921 The following code illustrates how this can work;
923 /* Load all bundled ENGINEs into memory and make them visible */
924 ENGINE_load_builtin_engines();
925 /* Register all of them for every algorithm they collectively implement */
926 ENGINE_register_all_complete();
929 That's all that's required.
930 For example, the next time OpenSSL tries to set up an RSA key, any bundled
936 and if any of those succeed, that
938 will be set as the default for RSA use from then on.
939 .Ss Advanced configuration support
940 There is a mechanism supported by the
942 framework that allows each
944 implementation to define an arbitrary set of configuration
945 "commands" and expose them to OpenSSL and any applications based on
947 This mechanism is entirely based on the use of name-value pairs
948 and assumes ASCII input (no unicode or UTF for now!), so it is ideal if
949 applications want to provide a transparent way for users to provide
950 arbitrary configuration "directives" directly to such
952 It is also possible for the application to dynamically interrogate the
955 implementations for the names, descriptions, and input flags of
956 their available "control commands", providing a more flexible
957 configuration scheme.
958 However, if the user is expected to know which
960 device he/she is using (in the case of specialised hardware, this
961 goes without saying) then applications may not need to concern
962 themselves with discovering the supported control commands and
963 simply prefer to pass settings into
965 exactly as they are provided by the user.
967 Before illustrating how control commands work, it is worth mentioning
968 what they are typically used for.
969 Broadly speaking there are two uses for control commands; the first is
970 to provide the necessary details to the implementation (which may know
971 nothing at all specific to the host system) so that it can be
973 This could include the path to any driver or config files it needs to
974 load, required network addresses, smart-card identifiers, passwords to
975 initialise protected devices, logging information, etc.
976 This class of commands typically needs to be passed to an
979 attempting to initialise it, i.e. before calling
981 The other class of commands consist of settings or operations that tweak
982 certain behaviour or cause certain operations to take place, and these
983 commands may work either before or after
985 or in some cases both.
987 implementations should provide indications of this in the descriptions
988 attached to builtin control commands and/or in external product
991 .Em Issuing control commands to an ENGINE
993 Let's illustrate by example; a function for which the caller supplies
996 it wishes to use, a table of string-pairs for use before initialisation,
997 and another table for use after initialisation.
998 Note that the string-pairs used for control commands consist of a
999 command "name" followed by the command "parameter" - the parameter
1002 in some cases but the name cannot.
1003 This function should initialise the
1005 (issuing the "pre" commands beforehand and the "post" commands
1006 afterwards) and set it as the default for everything except RAND
1007 and then return a boolean success or failure.
1010 generic_load_engine_fn(const char *engine_id,
1011 const char **pre_cmds, int pre_num,
1012 const char **post_cmds, int post_num)
1014 ENGINE *e = ENGINE_by_id(engine_id);
1019 if (!ENGINE_ctrl_cmd_string(e,
1020 pre_cmds[0], pre_cmds[1], 0)) {
1022 "Failed command (%s - %s:%s)\en",
1023 engine_id, pre_cmds[0],
1024 pre_cmds[1] ? pre_cmds[1] : "(NULL)");
1030 if (!ENGINE_init(e)) {
1031 fprintf(stderr, "Failed initialisation\en");
1036 * ENGINE_init() returned a functional reference,
1037 * so free the structural reference from
1041 while (post_num--) {
1042 if (!ENGINE_ctrl_cmd_string(e,
1043 post_cmds[0], post_cmds[1], 0)) {
1045 "Failed command (%s - %s:%s)\en",
1046 engine_id, post_cmds[0],
1047 post_cmds[1] ? post_cmds[1] : "(NULL)");
1053 ENGINE_set_default(e, ENGINE_METHOD_ALL & ~ENGINE_METHOD_RAND);
1060 .Fn ENGINE_ctrl_cmd_string
1061 accepts a boolean argument that can relax the semantics of the function.
1062 If set to non-zero it will only return failure if the
1064 supported the given command name but failed while executing it, if the
1066 doesn't support the command name it will simply return success without
1068 In this case we assume the user is only supplying commands specific to
1071 so we set this to FALSE.
1073 .Em Discovering supported control commands
1075 It is possible to discover at run-time the names, numerical-ids,
1076 descriptions and input parameters of the control commands supported by an
1078 using a structural reference.
1079 Note that some control commands are defined by OpenSSL itself and it
1080 will intercept and handle these control commands on behalf of the
1084 ctrl() handler is not used for the control command.
1085 .In openssl/engine.h
1087 .Dv ENGINE_CMD_BASE ,
1088 that all control commands implemented by
1090 should be numbered from.
1091 Any command value lower than this symbol is considered a "generic"
1092 command is handled directly by the OpenSSL core routines.
1094 It is using these "core" control commands that one can discover the
1095 control commands implemented by a given
1097 specifically the commands:
1099 #define ENGINE_HAS_CTRL_FUNCTION 10
1100 #define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
1101 #define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
1102 #define ENGINE_CTRL_GET_CMD_FROM_NAME 13
1103 #define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
1104 #define ENGINE_CTRL_GET_NAME_FROM_CMD 15
1105 #define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
1106 #define ENGINE_CTRL_GET_DESC_FROM_CMD 17
1107 #define ENGINE_CTRL_GET_CMD_FLAGS 18
1110 Whilst these commands are automatically processed by the OpenSSL
1111 framework code, they use various properties exposed by each
1113 to process these queries.
1116 has 3 properties it exposes that can affect how this behaves;
1117 it can supply a ctrl() handler, it can specify
1118 .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
1121 flags, and it can expose an array of control command descriptions.
1125 .Dv ENGINE_FLAGS_MANUAL_CMD_CTRL
1126 flag, then it will simply pass all these "core" control commands
1129 ctrl() handler (and thus, it must have supplied one), so it is up
1132 to reply to these "discovery" commands itself.
1133 If that flag is not set, then the OpenSSL framework code will work with
1134 the following rules;
1136 .It If no ctrl() handler is supplied:
1137 .Dv ENGINE_HAS_CTRL_FUNCTION
1138 returns FALSE (zero), all other commands fail.
1139 .It If a ctrl() handler was supplied but no array of control commands:
1140 .Dv ENGINE_HAS_CTRL_FUNCTION
1141 returns TRUE, all other commands fail.
1142 .It If a ctrl() handler and array of control commands was supplied:
1143 .Dv ENGINE_HAS_CTRL_FUNCTION
1144 returns TRUE, all other commands proceed processing...
1149 array of control commands is empty, then all other commands will fail.
1151 .Dv ENGINE_CTRL_GET_FIRST_CMD_TYPE
1152 returns the identifier of the first command supported by the
1154 .Dv ENGINE_GET_NEXT_CMD_TYPE
1155 takes the identifier of a command supported by the
1157 and returns the next command identifier or fails if there are no more,
1158 .Dv ENGINE_CMD_FROM_NAME
1159 takes a string name for a command and returns the corresponding
1160 identifier or fails if no such command name exists, and the remaining
1161 commands take a command identifier and return properties of the
1162 corresponding commands.
1164 .Dv ENGINE_CTRL_GET_FLAGS
1165 return the string length of a command name or description, or
1166 populate a supplied character buffer with a copy of the command
1167 name or description.
1168 .Dv ENGINE_CTRL_GET_FLAGS
1169 returns a bitwise-OR'd mask of the following possible values:
1171 #define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
1172 #define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
1173 #define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
1174 #define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
1178 .Dv ENGINE_CMD_FLAG_INTERNAL
1179 flag is set, then any other flags are purely informational to the caller.
1180 This flag will prevent the command being usable for any higher-level
1183 .Fn ENGINE_ctrl_cmd_string .
1184 "INTERNAL" commands are not intended to be exposed to text-based
1185 configuration by applications, administrations, users, etc.
1186 These can support arbitrary operations via
1188 including passing to and/or from the control commands data of any
1190 These commands are supported in the discovery mechanisms simply allow
1191 applications to determine if an
1193 supports certain specific commands it might want to use (e.g.
1194 application "foo" might query various
1196 to see if they implement "FOO_GET_VENDOR_LOGO_GIF" - and
1198 could therefore decide whether or not to support this "foo"-specific
1203 .Xr ENGINE_add_conf_module 3 ,
1204 .Xr ENGINE_set_ex_data 3 ,