GmSSL-master\include\openssl\engine.h 注释翻译

/*
 * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 * ECDH support in OpenSSL originally developed by
 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
 */

#ifndef HEADER_ENGINE_H
# define HEADER_ENGINE_H

# include <openssl/opensslconf.h>

# ifndef OPENSSL_NO_ENGINE
# if OPENSSL_API_COMPAT < 0x10100000L
#  include <openssl/bn.h>
#  include <openssl/rsa.h>
#  include <openssl/dsa.h>
#  include <openssl/dh.h>
#  include <openssl/ec.h>
#  include <openssl/rand.h>
#  include <openssl/ui.h>
#  include <openssl/err.h>
# endif
# include <openssl/ossl_typ.h>
# include <openssl/symhacks.h>
# include <openssl/x509.h>
# ifdef  __cplusplus
extern "C" {
# endif

/*
 * These flags are used to control combinations of algorithm (methods) by
 * bitwise "OR"ing.
 * 这些标志用于通过按位“或”ing 来控制算法(方法)的组合。
 */
# define ENGINE_METHOD_RSA               (unsigned int)0x0001
# define ENGINE_METHOD_DSA               (unsigned int)0x0002
# define ENGINE_METHOD_DH                (unsigned int)0x0004
# define ENGINE_METHOD_RAND              (unsigned int)0x0008
# define ENGINE_METHOD_CIPHERS           (unsigned int)0x0040
# define ENGINE_METHOD_DIGESTS           (unsigned int)0x0080
# define ENGINE_METHOD_PKEY_METHS        (unsigned int)0x0200
# define ENGINE_METHOD_PKEY_ASN1_METHS   (unsigned int)0x0400
# define ENGINE_METHOD_EC                (unsigned int)0x0800
/* Obvious all-or-nothing cases. */
# define ENGINE_METHOD_ALL               (unsigned int)0xFFFF
# define ENGINE_METHOD_NONE              (unsigned int)0x0000

/*
 * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
 * internally to control registration of ENGINE implementations, and can be
 * set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
 * initialise registered ENGINEs if they are not already initialised.

 * 这个(ese)标志控制内部使用的 ENGINE_TABLE 机制的行为来控制 ENGINE 实现的注册,
 * 并且可以通过 ENGINE_set_table_flags() 设置。 
 * “NOINIT”标志可防止尝试初始化尚未初始化的已注册引擎。
 */
# define ENGINE_TABLE_FLAG_NOINIT        (unsigned int)0x0001

/* ENGINE flags that can be set by ENGINE_set_flags(). */
/* Not used */
/* #define ENGINE_FLAGS_MALLOCED        0x0001 */

/* 可以通过 ENGINE_set_flags() 设置的 ENGINE 标志。 */
/* 不曾用过 */
/* #define ENGINE_FLAGS_MALLOCED 0x0001 */


/*
 * This flag is for ENGINEs that wish to handle the various 'CMD'-related
 * control commands on their own. Without this flag, ENGINE_ctrl() handles
 * these control commands on behalf of the ENGINE using their "cmd_defns"
 * data.

 * 此标志适用于希望自行处理各种与“CMD”相关的控制命令的引擎。 
 * 如果没有此标志,ENGINE_ctrl() 将使用“cmd_defns”数据代表 ENGINE 处理这些控制命令。
 */
# define ENGINE_FLAGS_MANUAL_CMD_CTRL    (int)0x0002

/*
 * This flag is for ENGINEs who return new duplicate structures when found
 * via "ENGINE_by_id()". When an ENGINE must store state (eg. if
 * ENGINE_ctrl() commands are called in sequence as part of some stateful
 * process like key-generation setup and execution), it can set this flag -
 * then each attempt to obtain the ENGINE will result in it being copied into
 * a new structure. Normally, ENGINEs don't declare this flag so
 * ENGINE_by_id() just increments the existing ENGINE's structural reference
 * count.

 * 此标志适用于通过“ENGINE_by_id()”找到时返回新的重复结构的引擎。 当引擎必须存储状态时(例如,如果
 *  ENGINE_ctrl() 命令作为某些有状态过程的一部分(如密钥生成设置和执行)按顺序调用),它可以设置此标志
 *  - 然后每次尝试获取 ENGINE 都会导致它被复制到一个新结构中。 通常,ENGINE 不会声明此标志,
 * 因此 ENGINE_by_id() 只会增加现有 ENGINE 的结构引用计数。
 */
# define ENGINE_FLAGS_BY_ID_COPY         (int)0x0004

/*
 * This flag if for an ENGINE that does not want its methods registered as
 * part of ENGINE_register_all_complete() for example if the methods are not
 * usable as default methods.

 * 如果引擎不希望将其方法注册为 ENGINE_register_all_complete() 的一部分,
 * 例如如果这些方法不能用作默认方法,则此标志。
 */

# define ENGINE_FLAGS_NO_REGISTER_ALL    (int)0x0008

/*
 * ENGINEs can support their own command types, and these flags are used in
 * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input
 * each command expects. Currently only numeric and string input is
 * supported. If a control command supports none of the _NUMERIC, _STRING, or
 * _NO_INPUT options, then it is regarded as an "internal" control command -
 * and not for use in config setting situations. As such, they're not
 * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl()
 * access. Changes to this list of 'command types' should be reflected
 * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().

 * ENGINE 可以支持自己的命令类型,这些标志用于 ENGINE_CTRL_GET_CMD_FLAGS 以向调用者指示每个命令
 * 期望的输入类型。 目前仅支持数字和字符串输入。 如果控制命令不支持 _NUMERIC、_STRING 或 _NO_INPUT 选项,
 * 则它被视为“内部”控制命令 - 而不是用于配置设置情况。 因此,它们对 ENGINE_ctrl_cmd_string() 函数不可用,
 * 只有原始的 ENGINE_ctrl()使用权。 对这个“命令类型”列表的更改应该仔细反映在 ENGINE_cmd_is_executable()
 * 和 ENGINE_ctrl_cmd_string() 中。
 */

/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) 
	接受“长”输入值(ENGINE_ctrl 的第三个参数)
*/
# define ENGINE_CMD_FLAG_NUMERIC         (unsigned int)0x0001
/*
 * accepts string input (cast from 'void*' to 'const char *', 4th parameter
 * to ENGINE_ctrl)

 接受字符串输入(从'void*'转换为'const char *',第四个参数到 ENGINE_ctrl)
 */
# define ENGINE_CMD_FLAG_STRING          (unsigned int)0x0002
/*
 * Indicates that the control command takes *no* input. Ie. the control
 * command is unparameterised.

 表示控制命令接受 *no* 输入。 IE。 控制命令未参数化。
 */
# define ENGINE_CMD_FLAG_NO_INPUT        (unsigned int)0x0004
/*
 * Indicates that the control command is internal. This control command won't
 * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
 * function.

 指示控制命令是内部的。 此控制命令不会显示在任何输出中,并且只能通过 ENGINE_ctrl_cmd() 函数使用。
 */
# define ENGINE_CMD_FLAG_INTERNAL        (unsigned int)0x0008

/*
 * NB: These 3 control commands are deprecated and should not be used.
 * ENGINEs relying on these commands should compile conditional support for
 * compatibility (eg. if these symbols are defined) but should also migrate
 * the same functionality to their own ENGINE-specific control functions that
 * can be "discovered" by calling applications. The fact these control
 * commands wouldn't be "executable" (ie. usable by text-based config)
 * doesn't change the fact that application code can find and use them
 * without requiring per-ENGINE hacking.

 * 注意:这 3 个控制命令已弃用,不应使用。 依赖这些命令的 ENGINE 应该编译有条件的兼容性支持
 (例如,如果定义了这些符号),但也应该将相同的功能迁移到它们自己的特定于 ENGINE 的控制功能,
 这些控制功能可以通过调用应用程序“发现”。 这些控制命令不是“可执行的”(即可由基于文本的配置使用)
 这一事实并没有改变应用程序代码可以找到并使用它们而无需对每个引擎进行黑客攻击的事实。
 */

/*
 * These flags are used to tell the ctrl function what should be done. All
 * command numbers are shared between all engines, even if some don't make
 * sense to some engines.  In such a case, they do nothing but return the
 * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.

 * 这些标志用于告诉 ctrl 函数应该做什么。 所有命令号在所有引擎之间共享,即使有些命令号对某些引擎没有意义。 
 在这种情况下,它们除了返回错误 ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 外什么都不做。
 */
# define ENGINE_CTRL_SET_LOGSTREAM               1
# define ENGINE_CTRL_SET_PASSWORD_CALLBACK       2
# define ENGINE_CTRL_HUP                         3/* Close and reinitialise
                                                   * any handles/connections
                                                   * etc. */   /*关闭并重新初始化任何句柄/连接等 */
# define ENGINE_CTRL_SET_USER_INTERFACE          4/* Alternative to callback */  //回调的替代方法
# define ENGINE_CTRL_SET_CALLBACK_DATA           5/* User-specific data, used
                                                   * when calling the password
                                                   * callback and the user
                                                   * interface */ //用户特定数据,在调用密码回调和用户界面时使用
# define ENGINE_CTRL_LOAD_CONFIGURATION          6/* Load a configuration,
                                                   * given a string that
                                                   * represents a file name
                                                   * or so */ //加载配置,给定一个表示文件名左右的字符串
# define ENGINE_CTRL_LOAD_SECTION                7/* Load data from a given
                                                   * section in the already
                                                   * loaded configuration */ //从已加载配置中的给定部分加载数据

/*
 * These control commands allow an application to deal with an arbitrary
 * engine in a dynamic way. Warn: Negative return values indicate errors FOR
 * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other
 * commands, including ENGINE-specific command types, return zero for an
 * error. An ENGINE can choose to implement these ctrl functions, and can
 * internally manage things however it chooses - it does so by setting the
 * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise
 * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the
 * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's
 * ctrl() handler need only implement its own commands - the above "meta"
 * commands will be taken care of.

 * 这些控制命令允许应用程序以动态方式处理任意引擎。
 警告:负返回值表示这些命令的错误,因为零用于表示“列表结尾”。 
 其他命令,包括特定于 ENGINE 的命令类型,对于错误返回零。 一个 ENGINE 可以选择实现这些 ctrl 函数,
 并且可以在内部管理它选择的东西——它通过设置 ENGINE_FLAGS_MANUAL_CMD_CTRL 标志(使用 ENGINE_set_flags())来实现。
 否则,ENGINE_ctrl() 代码使用 cmd_defns 数据(使用 ENGINE_set_cmd_defns() 设置)代表 ENGINE 处理此问题。 
 这意味着引擎的 ctrl() 处理程序只需要实现它自己的命令——上面的“元”命令将被处理。
 */

/*
 * Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not",
 * then all the remaining control commands will return failure, so it is
 * worth checking this first if the caller is trying to "discover" the
 * engine's capabilities and doesn't want errors generated unnecessarily.

 如果提供的 ENGINE 具有 ctrl() 处理程序,则返回非零值。 如果不”,
  那么所有剩余的控制命令将返回失败,因此如果调用者试图“发现”引擎的功能并且不希望不必要地产生错误,
  那么首先检查这一点是值得的。
 */
# define ENGINE_CTRL_HAS_CTRL_FUNCTION           10
/*
 * Returns a positive command number for the first command supported by the
 * engine. Returns zero if no ctrl commands are supported.

 返回引擎支持的第一个命令的正命令号。 如果不支持 ctrl 命令,则返回零。
 */
# define ENGINE_CTRL_GET_FIRST_CMD_TYPE          11
/*
 * The 'long' argument specifies a command implemented by the engine, and the
 * return value is the next command supported, or zero if there are no more.

 'long' 参数指定引擎实现的命令,返回值是下一个支持的命令,如果没有更多命令则为零。
 */
# define ENGINE_CTRL_GET_NEXT_CMD_TYPE           12
/*
 * The 'void*' argument is a command name (cast from 'const char *'), and the
 * return value is the command that corresponds to it.

 * 'void*' 参数是一个命令名(由'const char *' 转换而来),返回值是它对应的命令。
 */
# define ENGINE_CTRL_GET_CMD_FROM_NAME           13
/*
 * The next two allow a command to be converted into its corresponding string
 * form. In each case, the 'long' argument supplies the command. In the
 * NAME_LEN case, the return value is the length of the command name (not
 * counting a trailing EOL). In the NAME case, the 'void*' argument must be a
 * string buffer large enough, and it will be populated with the name of the
 * command (WITH a trailing EOL).

 接下来的两个允许将命令转换为其相应的字符串形式。 在每种情况下,“long”参数都提供命令。 
 在 NAME_LEN 的情况下,返回值是命令名称的长度(不包括尾随的 EOL)。 在 NAME 的情况下,
 'void*' 参数必须是一个足够大的字符串缓冲区,并且它将填充命令的名称(带有尾随的 EOL)。
 */
# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD       14
# define ENGINE_CTRL_GET_NAME_FROM_CMD           15
/* The next two are similar but give a "short description" of a command. */
// 接下来的两个类似,但给出了命令的“简短描述”。
# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD       16
# define ENGINE_CTRL_GET_DESC_FROM_CMD           17
/*
 * With this command, the return value is the OR'd combination of
 * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
 * engine-specific ctrl command expects.
 * 使用此命令,返回值是 ENGINE_CMD_FLAG_*** 值的 OR 组合,指示给定引擎特定的 ctrl
 命令期望的输入类型。
 */
# define ENGINE_CTRL_GET_CMD_FLAGS               18

/*
 * ENGINE implementations should start the numbering of their own control
 * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).

 ENGINE 实现应该从这个值开始对它们自己的控制命令进行编号。 
 (即 ENGINE_CMD_BASE、ENGINE_CMD_BASE + 1 等)
 */
# define ENGINE_CMD_BASE                         200

/*
 * NB: These 2 nCipher "chil" control commands are deprecated, and their
 * functionality is now available through ENGINE-specific control commands
 * (exposed through the above-mentioned 'CMD'-handling). Code using these 2
 * commands should be migrated to the more general command handling before
 * these are removed.

 * 注意:这 2 个 nCipher“chil”控制命令已弃用,它们的功能现在可通过 ENGINE 特定的控制命令
 (通过上述“CMD”处理公开)获得。 使用这 2 个命令的代码应该在删除之前迁移到更通用的命令处理。
 */

/* Flags specific to the nCipher "chil" engine */
//特定于 nCipher“chil”引擎的标志
# define ENGINE_CTRL_CHIL_SET_FORKCHECK          100
        /*
         * Depending on the value of the (long)i argument, this sets or
         * unsets the SimpleForkCheck flag in the CHIL API to enable or
         * disable checking and workarounds for applications that fork().
         根据 (long)i 参数的值,这会设置或取消设置 CHIL API 中的 SimpleForkCheck 标志,
         以启用或禁用 fork() 应用程序的检查和解决方法。
         */
# define ENGINE_CTRL_CHIL_NO_LOCKING             101
        /*
         * This prevents the initialisation function from providing mutex
         * callbacks to the nCipher library.
         这可以防止初始化函数向 nCipher 库提供互斥回调。
         */

/*
 * If an ENGINE supports its own specific control commands and wishes the
 * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on
 * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN
 * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl()
 * handler that supports the stated commands (ie. the "cmd_num" entries as
 * described by the array). NB: The array must be ordered in increasing order
 * of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element
 * has cmd_num set to zero and/or cmd_name set to NULL.

 如果 ENGINE 支持其自己的特定控制命令并希望框架代表其处理上述“ENGINE_CMD_***”操作命令,
 则它应向 ENGINE_set_cmd_defns() 提供一个以空字符结尾的 ENGINE_CMD_DEFN 条目数组。 
 它还应该实现一个支持指定命令的 ctrl() 处理程序(即数组描述的“cmd_num”条目)。 
 注意:数组必须按 cmd_num 的递增顺序排列。 “null-terminated”意味着最后一个 
 ENGINE_CMD_DEFN 元素将 cmd_num 设置为零和/或 cmd_name 设置为 NULL
 */
typedef struct ENGINE_CMD_DEFN_st {
    unsigned int cmd_num;       /* The command number */  //命令编号
    const char *cmd_name;       /* The command name itself */ //命令名称本身
    const char *cmd_desc;       /* A short description of the command */ //命令的简短描述
    unsigned int cmd_flags;     /* The input the command expects */ //命令期望的输入
} ENGINE_CMD_DEFN;

/* Generic function pointer */  //通用函数指针
typedef int (*ENGINE_GEN_FUNC_PTR) (void);
/* Generic function pointer taking no arguments */ //不带参数的通用函数指针
typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *);
/* Specific control function pointer */  //具体控制函数指针
typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *,
                                     void (*f) (void));
/* Generic load_key function pointer */ //通用 load_key 函数指针
typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
                                         UI_METHOD *ui_method,
                                         void *callback_data);
typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl,
                                           STACK_OF(X509_NAME) *ca_dn,
                                           X509 **pcert, EVP_PKEY **pkey,
                                           STACK_OF(X509) **pother,
                                           UI_METHOD *ui_method,
                                           void *callback_data);
/*-
 * These callback types are for an ENGINE's handler for cipher and digest logic.
 * These handlers have these prototypes;
 这些回调类型用于 ENGINE 的密码和摘要逻辑处理程序。 这些处理程序有这些原型
 *   int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
 *   int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
 * Looking at how to implement these handlers in the case of cipher support, if
 * the framework wants the EVP_CIPHER for 'nid', it will call;
 查看在支持密码的情况下如何实现这些处理程序,如果框架需要“nid”的 EVP_CIPHER,它将调用;
 *   foo(e, &p_evp_cipher, NULL, nid);    (return zero for failure)
 * If the framework wants a list of supported 'nid's, it will call;
 *   foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
 如果框架需要支持的“nid”列表,它将调用;
 */
/*
 * Returns to a pointer to the array of supported cipher 'nid's. If the
 * second parameter is non-NULL it is set to the size of the returned array.
 返回指向支持的密码“nid”数组的指针。 如果第二个参数是非 NULL,则它被设置为返回数组的大小
 */
typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **,
                                   const int **, int);
typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **,
                                   int);
typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **,
                                      const int **, int);
typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **,
                                           const int **, int);
/*
 * STRUCTURE functions ... all of these functions deal with pointers to
 * ENGINE structures where the pointers have a "structural reference". This
 * means that their reference is to allowed access to the structure but it
 * does not imply that the structure is functional. To simply increment or
 * decrement the structural reference count, use ENGINE_by_id and
 * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next
 * as it will automatically decrement the structural reference count of the
 * "current" ENGINE and increment the structural reference count of the
 * ENGINE it returns (unless it is NULL).

 STRUCTURE 函数......所有这些函数都处理指向 ENGINE 结构的指针,其中指针具有“结构引用”。
 这意味着他们的参考是允许访问该结构,但并不意味着该结构是功能性的。
 要简单地增加或减少结构引用计数,请使用 ENGINE_by_id 和 ENGINE_free。 
 注意:使用 ENGINE_get_next 进行迭代时不需要这样做,因为它会自动减少“当前”引擎的
 结构引用计数并增加它返回的引擎的结构引用计数(除非它为 NULL)。
 */

/* Get the first/last "ENGINE" type available. */
//获取第一个/最后一个可用的“ENGINE”类型。
ENGINE *ENGINE_get_first(void);
ENGINE *ENGINE_get_last(void);
/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
//迭代到下一个/上一个“ENGINE”类型(NULL = 列表末尾)。
ENGINE *ENGINE_get_next(ENGINE *e);
ENGINE *ENGINE_get_prev(ENGINE *e);
/* Add another "ENGINE" type into the array. */
//将另一个“ENGINE”类型添加到数组中。
int ENGINE_add(ENGINE *e);
/* Remove an existing "ENGINE" type from the array. */
//从数组中删除现有的“ENGINE”类型。
int ENGINE_remove(ENGINE *e);
/* Retrieve an engine from the list by its unique "id" value. */
//通过其唯一的“id”值从列表中检索引擎。
ENGINE *ENGINE_by_id(const char *id);

#if OPENSSL_API_COMPAT < 0x10100000L
# define ENGINE_load_openssl() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL)
# define ENGINE_load_dynamic() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL)
# ifndef OPENSSL_NO_STATIC_ENGINE
#  define ENGINE_load_padlock() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL)
#  define ENGINE_load_capi() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL)
#  define ENGINE_load_skf() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_SKF, NULL)
#  define ENGINE_load_sdf() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_SDF, NULL)
#  define ENGINE_load_afalg() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL)
# endif
# define ENGINE_load_cryptodev() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL)
# define ENGINE_load_rdrand() \
    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL)
#endif
void ENGINE_load_builtin_engines(void);

/*
 * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
 * "registry" handling.

 获取并设置用于实现“注册表”处理的全局标志 (ENGINE_TABLE_FLAG_***)。
 */
unsigned int ENGINE_get_table_flags(void);
void ENGINE_set_table_flags(unsigned int flags);

/*- Manage registration of ENGINEs per "table". For each type, there are 3
 * functions; 管理每个“表”的引擎注册。 对于每种类型,有 3 功能;
 *   ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
 ENGINE_register_***(e) - 从“e”注册实现(如果有的话)
 *   ENGINE_unregister_***(e) - unregister the implementation from 'e'
 ENGINE_unregister_***(e) - 从“e”注销实现
 *   ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
 ENGINE_register_all_***() - 为列表中的每个“e”调用 ENGINE_register_***()
 * Cleanup is automatically registered from each table when required.
 需要时会自动从每个表中注册清理。
 */

int ENGINE_register_RSA(ENGINE *e);
void ENGINE_unregister_RSA(ENGINE *e);
void ENGINE_register_all_RSA(void);

int ENGINE_register_DSA(ENGINE *e);
void ENGINE_unregister_DSA(ENGINE *e);
void ENGINE_register_all_DSA(void);

int ENGINE_register_EC(ENGINE *e);
void ENGINE_unregister_EC(ENGINE *e);
void ENGINE_register_all_EC(void);

int ENGINE_register_DH(ENGINE *e);
void ENGINE_unregister_DH(ENGINE *e);
void ENGINE_register_all_DH(void);

int ENGINE_register_RAND(ENGINE *e);
void ENGINE_unregister_RAND(ENGINE *e);
void ENGINE_register_all_RAND(void);

int ENGINE_register_ciphers(ENGINE *e);
void ENGINE_unregister_ciphers(ENGINE *e);
void ENGINE_register_all_ciphers(void);

int ENGINE_register_digests(ENGINE *e);
void ENGINE_unregister_digests(ENGINE *e);
void ENGINE_register_all_digests(void);

int ENGINE_register_pkey_meths(ENGINE *e);
void ENGINE_unregister_pkey_meths(ENGINE *e);
void ENGINE_register_all_pkey_meths(void);

int ENGINE_register_pkey_asn1_meths(ENGINE *e);
void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
void ENGINE_register_all_pkey_asn1_meths(void);

/*
 * These functions register all support from the above categories. Note, use
 * of these functions can result in static linkage of code your application
 * may not need. If you only need a subset of functionality, consider using
 * more selective initialisation.
 这些函数注册了上述类别的所有支持。 
 请注意,使用这些函数可能会导致您的应用程序可能不需要代码的静态链接。 
 如果您只需要一部分功能,请考虑使用更具选择性的初始化。
 */
int ENGINE_register_complete(ENGINE *e);
int ENGINE_register_all_complete(void);

/*
 * Send parametrised control commands to the engine. The possibilities to
 * send down an integer, a pointer to data or a function pointer are
 * provided. Any of the parameters may or may not be NULL, depending on the
 * command number. In actuality, this function only requires a structural
 * (rather than functional) reference to an engine, but many control commands
 * may require the engine be functional. The caller should be aware of trying
 * commands that require an operational ENGINE, and only use functional
 * references in such situations.

 向引擎发送参数化控制命令。 向下发送整数、指向数据的指针或函数指针的可能性是
假如。 任何参数可能为 NULL,也可能不为 NULL,具体取决于命令编号。 
实际上,此功能仅需要对引擎的结构(而不是功能)引用,但许多控制命令可能需要引擎具有功能。
调用者应该知道尝试需要运行引擎的命令,并且只在这种情况下使用功能引用。
 */
int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));

/*
 * This function tests if an ENGINE-specific command is usable as a
 * "setting". Eg. in an application's config file that gets processed through
 * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
 * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().

 * 此函数测试特定于 ENGINE 的命令是否可用作“环境”。 例如。 在通过 
 ENGINE_ctrl_cmd_string() 处理的应用程序配置文件中。 如果返回零,
 则它对 ENGINE_ctrl_cmd_string() 不可用,仅对 ENGINE_ctrl() 可用。
 */
int ENGINE_cmd_is_executable(ENGINE *e, int cmd);

/*
 * This function works like ENGINE_ctrl() with the exception of taking a
 * command name instead of a command number, and can handle optional
 * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation
 * on how to use the cmd_name and cmd_optional.

 此函数的工作方式与 ENGINE_ctrl() 类似,只是采用命令名称而不是命令编号,
 并且可以处理可选命令。 有关如何使用 cmd_name 和 cmd_optional 的说明,
 请参阅 ENGINE_ctrl_cmd_string() 的注释。
 */
int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
                    long i, void *p, void (*f) (void), int cmd_optional);

/*
 * This function passes a command-name and argument to an ENGINE. The
 * cmd_name is converted to a command number and the control command is
 * called using 'arg' as an argument (unless the ENGINE doesn't support such
 * a command, in which case no control command is called). The command is
 * checked for input flags, and if necessary the argument will be converted
 * to a numeric value. If cmd_optional is non-zero, then if the ENGINE
 * doesn't support the given cmd_name the return value will be success
 * anyway. This function is intended for applications to use so that users
 * (or config files) can supply engine-specific config data to the ENGINE at
 * run-time to control behaviour of specific engines. As such, it shouldn't
 * be used for calling ENGINE_ctrl() functions that return data, deal with
 * binary data, or that are otherwise supposed to be used directly through
 * ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl()
 * operation in this function will be lost - the return value is interpreted
 * as failure if the return value is zero, success otherwise, and this
 * function returns a boolean value as a result. In other words, vendors of
 * 'ENGINE'-enabled devices should write ENGINE implementations with
 * parameterisations that work in this scheme, so that compliant ENGINE-based
 * applications can work consistently with the same configuration for the
 * same ENGINE-enabled devices, across applications.

 * 此函数将命令名称和参数传递给 ENGINE。 
 cmd_name 被转换为命令编号,并使用“arg”作为参数调用控制命令(除非 ENGINE 不支持此类命令,
 在这种情况下不会调用控制命令)。 检查命令的输入标志,如有必要,参数将转换为数值。 
 如果 cmd_optional 不为零,那么如果 ENGINE 不支持给定的 cmd_name,则返回值无论如何都会成功。
 此函数旨在供应用程序使用,以便用户(或配置文件)可以在运行时向 ENGINE 提供特定于引擎的配置
 数据,以控制特定引擎的行为。 因此,它不应该用于调用返回数据、处理二进制数据的 ENGINE_ctrl()
 函数,或者应该在应用程序代码中直接通过 ENGINE_ctrl() 使用的函数。 此函数中来自 ENGINE_ctrl
 () 操作的任何“返回”数据都将丢失 - 如果返回值为零,则返回值被解释为失败,否则为成功,并且此
 函数返回一个布尔值作为结果。 换句话说,启用“ENGINE”的设备的供应商应该编写具有在此方案中工
 作的参数化的 ENGINE 实现,以便基于 ENGINE 的兼容应用程序可以跨应用程序与相同的启用 ENGINE 
 的设备的相同配置一致地工作。
 */
int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
                           int cmd_optional);

/*
 * These functions are useful for manufacturing new ENGINE structures. They
 * don't address reference counting at all - one uses them to populate an
 * ENGINE structure with personalised implementations of things prior to
 * using it directly or adding it to the builtin ENGINE list in OpenSSL.
 * These are also here so that the ENGINE structure doesn't have to be
 * exposed and break binary compatibility!

 这些功能对于制造新的 ENGINE 结构很有用。 
 它们根本不解决引用计数问题——在直接使用它或将其添加到 OpenSSL 中的内置引擎列表之前,
 人们使用它们来填充具有事物的个性化实现的引擎结构。 
 这些也在这里,因此不必暴露 ENGINE 结构并破坏二进制兼容性!
 */
ENGINE *ENGINE_new(void);
int ENGINE_free(ENGINE *e);
int ENGINE_up_ref(ENGINE *e);
int ENGINE_set_id(ENGINE *e, const char *id);
int ENGINE_set_name(ENGINE *e, const char *name);
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);
int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
int ENGINE_set_load_privkey_function(ENGINE *e,
                                     ENGINE_LOAD_KEY_PTR loadpriv_f);
int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
                                             ENGINE_SSL_CLIENT_CERT_PTR
                                             loadssl_f);
int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
int ENGINE_set_flags(ENGINE *e, int flags);
int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
/* These functions allow control over any per-structure ENGINE data. */
//这些函数允许控制任何基于结构的 ENGINE 数据
#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \
    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef)
int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
void *ENGINE_get_ex_data(const ENGINE *e, int idx);

#if OPENSSL_API_COMPAT < 0x10100000L
/*
 * This function previously cleaned up anything that needs it. Auto-deinit will
 * now take care of it so it is no longer required to call this function.
 此功能以前清除了任何需要它的东西。 Auto-deinit 现在会处理它,因此不再需要调用此函数。
 */
# define ENGINE_cleanup() while(0) continue
#endif

/*
 * These return values from within the ENGINE structure. These can be useful
 * with functional references as well as structural references - it depends
 * which you obtained. Using the result for functional purposes if you only
 * obtained a structural reference may be problematic!
 这些从 ENGINE 结构中返回值。 这些对于功能参考和结构参考可能很有用
 这取决于您获得的是什么。 如果仅获得结构参考,将结果用于功能目的可能会出现问题!
 */
const char *ENGINE_get_id(const ENGINE *e);
const char *ENGINE_get_name(const ENGINE *e);
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);
const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE
                                                               *e);
ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
                                                          const char *str,
                                                          int len);
const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
                                                      const char *str,
                                                      int len);
const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
int ENGINE_get_flags(const ENGINE *e);

/*
 * FUNCTIONAL functions. These functions deal with ENGINE structures that
 * have (or will) be initialised for use. Broadly speaking, the structural
 * functions are useful for iterating the list of available engine types,
 * creating new engine types, and other "list" operations. These functions
 * actually deal with ENGINEs that are to be used. As such these functions
 * can fail (if applicable) when particular engines are unavailable - eg. if
 * a hardware accelerator is not attached or not functioning correctly. Each
 * ENGINE has 2 reference counts; structural and functional. Every time a
 * functional reference is obtained or released, a corresponding structural
 * reference is automatically obtained or released too.
 功能性功能。 这些函数处理已经(或将要)初始化使用的 ENGINE 结构。 
 从广义上讲,结构函数对于迭代可用引擎类型列表、创建新引擎类型和其他“列表”操作很有用。
 这些函数实际上处理要使用的引擎。 因此,当特定引擎不可用时,这些功能可能会失败(如果适用)
 - 例如。 如果硬件加速器未连接或未正常运行。 每个 ENGINE 有 2 个引用计数;结构和功能。
 每次获取或释放功能引用时,也会自动获取或释放相应的结构引用。 
 */

/*
 * Initialise a engine type for use (or up its reference count if it's
 * already in use). This will fail if the engine is not currently operational
 * and cannot initialise.
 初始化一个引擎类型以供使用(如果它已经在使用中,则增加它的引用计数)。 
 如果引擎当前未运行且无法初始化,这将失败。
 */
int ENGINE_init(ENGINE *e);
/*
 * Free a functional reference to a engine type. This does not require a
 * corresponding call to ENGINE_free as it also releases a structural
 * reference.
 释放对引擎类型的功能引用。 这不需要对 ENGINE_free 的相应调用,因为它还会释放结构引用。
 */
int ENGINE_finish(ENGINE *e);

/*
 * The following functions handle keys that are stored in some secondary
 * location, handled by the engine.  The storage may be on a card or
 * whatever.以下函数处理存储在某个次要位置的键,由引擎处理。 
 存储可以在卡上或其他任何东西上。
 */
EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
                                  UI_METHOD *ui_method, void *callback_data);
EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
                                 UI_METHOD *ui_method, void *callback_data);
int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
                                STACK_OF(X509_NAME) *ca_dn, X509 **pcert,
                                EVP_PKEY **ppkey, STACK_OF(X509) **pother,
                                UI_METHOD *ui_method, void *callback_data);

/*
 * This returns a pointer for the current ENGINE structure that is (by
 * default) performing any RSA operations. The value returned is an
 * incremented reference, so it should be free'd (ENGINE_finish) before it is
 * discarded.
 这将返回当前 ENGINE 结构的指针,该结构(默认情况下)正在执行任何 RSA 操作。 
 返回的值是一个递增的引用,所以它应该在被丢弃之前被释放(ENGINE_finish)。
 */
ENGINE *ENGINE_get_default_RSA(void);
/* Same for the other "methods" */ //其他“方法”也一样
ENGINE *ENGINE_get_default_DSA(void);
ENGINE *ENGINE_get_default_EC(void);
ENGINE *ENGINE_get_default_DH(void);
ENGINE *ENGINE_get_default_RAND(void);
/*
 * These functions can be used to get a functional reference to perform
 * ciphering or digesting corresponding to "nid".
 这些函数可用于获取函数引用以执行与“nid”对应的加密或摘要
 */
ENGINE *ENGINE_get_cipher_engine(int nid);
ENGINE *ENGINE_get_digest_engine(int nid);
ENGINE *ENGINE_get_pkey_meth_engine(int nid);
ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);

/*
 * This sets a new default ENGINE structure for performing RSA operations. If
 * the result is non-zero (success) then the ENGINE structure will have had
 * its reference count up'd so the caller should still free their own
 * reference 'e'.
 这为执行 RSA 操作设置了一个新的默认 ENGINE 结构。 如果结果不为零(成功),
 则 ENGINE 结构的引用计数将增加,因此调用者仍应释放他们自己的引用 'e'
 */
int ENGINE_set_default_RSA(ENGINE *e);
int ENGINE_set_default_string(ENGINE *e, const char *def_list);
/* Same for the other "methods" */
int ENGINE_set_default_DSA(ENGINE *e);
int ENGINE_set_default_EC(ENGINE *e);
int ENGINE_set_default_DH(ENGINE *e);
int ENGINE_set_default_RAND(ENGINE *e);
int ENGINE_set_default_ciphers(ENGINE *e);
int ENGINE_set_default_digests(ENGINE *e);
int ENGINE_set_default_pkey_meths(ENGINE *e);
int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);

/*
 * The combination "set" - the flags are bitwise "OR"d from the
 * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
 * function, this function can result in unnecessary static linkage. If your
 * application requires only specific functionality, consider using more
 * selective functions.
 组合“设置”- 标志是来自上面定义的 ENGINE_METHOD_*** 的按位“或”。 
 与“ENGINE_register_complete()”函数一样,该函数会导致不必要的静态链接。 
 如果您的应用程序只需要特定的功能,请考虑使用更具选择性的功能。
 */
int ENGINE_set_default(ENGINE *e, unsigned int flags);

void ENGINE_add_conf_module(void);

/* Deprecated functions ... */ //弃用的功能...
/* int ENGINE_clear_defaults(void); */

/**************************/
/* DYNAMIC ENGINE SUPPORT */ //动态引擎支持
/**************************/

/* Binary/behaviour compatibility levels */ //二进制/行为兼容性级别
# define OSSL_DYNAMIC_VERSION            (unsigned long)0x00030000
/*
 * Binary versions older than this are too old for us (whether we're a loader
 * or a loadee) 
 比这更旧的二进制版本对我们来说太旧了(无论我们是加载程序还是加载程序
 */
# define OSSL_DYNAMIC_OLDEST             (unsigned long)0x00030000

/*
 * When compiling an ENGINE entirely as an external shared library, loadable
 * by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns'
 * structure type provides the calling application's (or library's) error
 * functionality and memory management function pointers to the loaded
 * library. These should be used/set in the loaded library code so that the
 * loading application's 'state' will be used/changed in all operations. The
 * 'static_state' pointer allows the loaded library to know if it shares the
 * same static data as the calling application (or library), and thus whether
 * these callbacks need to be set or not.

 当将 ENGINE 完全编译为外部共享库时,可由“动态”ENGINE 加载,需要这些类型。
 'dynamic_fns'结构类型提供调用应用程序(或库)的错误功能和指向加载库的内存管理函数指针。
 这些应该在加载的库代码中使用/设置,以便在所有操作中使用/更改加载应用程序的“状态”。
 “static_state”指针允许加载的库知道它是否与调用应用程序(或库)共享相同的静态数据,
 因此是否需要设置这些回调。
 */
typedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int);
typedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int);
typedef void (*dyn_MEM_free_fn) (void *, const char *, int);
typedef struct st_dynamic_MEM_fns {
    dyn_MEM_malloc_fn malloc_fn;
    dyn_MEM_realloc_fn realloc_fn;
    dyn_MEM_free_fn free_fn;
} dynamic_MEM_fns;
/*
 * FIXME: Perhaps the memory and locking code (crypto.h) should declare and
 * use these types so we (and any other dependent code) can simplify a bit??
 FIXME:也许内存和锁定代码 (crypto.h) 应该声明和使用这些类型,
 以便我们(和任何其他相关代码)可以稍微简化一下?
 */
/* The top-level structure */ //顶层结构
typedef struct st_dynamic_fns {
    void *static_state;
    dynamic_MEM_fns mem_fns;
} dynamic_fns;

/*
 * The version checking function should be of this prototype. NB: The
 * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading
 * code. If this function returns zero, it indicates a (potential) version
 * incompatibility and the loaded library doesn't believe it can proceed.
 * Otherwise, the returned value is the (latest) version supported by the
 * loading library. The loader may still decide that the loaded code's
 * version is unsatisfactory and could veto the load. The function is
 * expected to be implemented with the symbol name "v_check", and a default
 * implementation can be fully instantiated with
 * IMPLEMENT_DYNAMIC_CHECK_FN().
 版本检查功能应该是这个原型。 注意:传入的ossl_version值为加载代码的OSSL_DYNAMIC_VERSION。
 如果此函数返回零,则表示(潜在)版本不兼容,并且加载的库认为它无法继续。
 否则,返回值是加载库支持的(最新)版本。 加载器可能仍决定加载代码的版本不令人满意,
 并可能否决加载。 该函数预计将使用符号名称“v_check”实现,并且可以使用 
 IMPLEMENT_DYNAMIC_CHECK_FN() 完全实例化默认实现。
 */
typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version);
# define IMPLEMENT_DYNAMIC_CHECK_FN() \
        OPENSSL_EXPORT unsigned long v_check(unsigned long v); \
        OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \
                if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
                return 0; }

/*
 * This function is passed the ENGINE structure to initialise with its own
 * function and command settings. It should not adjust the structural or
 * functional reference counts. If this function returns zero, (a) the load
 * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto
 * the structure, and (c) the shared library will be unloaded. So
 * implementations should do their own internal cleanup in failure
 * circumstances otherwise they could leak. The 'id' parameter, if non-NULL,
 * represents the ENGINE id that the loader is looking for. If this is NULL,
 * the shared library can choose to return failure or to initialise a
 * 'default' ENGINE. If non-NULL, the shared library must initialise only an
 * ENGINE matching the passed 'id'. The function is expected to be
 * implemented with the symbol name "bind_engine". A standard implementation
 * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter
 * 'fn' is a callback function that populates the ENGINE structure and
 * returns an int value (zero for failure). 'fn' should have prototype;
 * [static] int fn(ENGINE *e, const char *id);
 该函数通过 ENGINE 结构进行初始化功能和命令设置。 它不应该调整结构或功能引用计数。
 如果此函数返回零,(a) 负载将被中止,(b) 先前的 ENGINE 状态将被 memcpy 回到结构中,
 并且 (c) 共享库将被卸载。 所以实现应该在失败情况下进行自己的内部清理,否则它们可能会泄漏。
 'id' 参数,如果非 NULL,则表示加载程序正在寻找的 ENGINE id。 如果这是 NULL,
 共享库可以选择返回失败或初始化一个“默认”引擎。 如果非 NULL,共享库必须只初始化一个
  ENGINE 匹配传递的“id”。 该函数预计以符号名称“bind_engine”实现。 
  可以使用 IMPLEMENT_DYNAMIC_BIND_FN(fn) 实例化标准实现,其中参数“fn”是填充
  ENGINE 结构并返回 int 值(失败为零)的回调函数。 'fn' 应该有原型; 
  [静态] int fn(ENGINE *e, const char *id);
 */
typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
                                    const dynamic_fns *fns);
# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
        OPENSSL_EXPORT \
        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \
        OPENSSL_EXPORT \
        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
            if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \
            CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \
                                     fns->mem_fns.realloc_fn, \
                                     fns->mem_fns.free_fn); \
        skip_cbs: \
            if (!fn(e, id)) return 0; \
            return 1; }

/*
 * If the loading application (or library) and the loaded ENGINE library
 * share the same static data (eg. they're both dynamically linked to the
 * same libcrypto.so) we need a way to avoid trying to set system callbacks -
 * this would fail, and for the same reason that it's unnecessary to try. If
 * the loaded ENGINE has (or gets from through the loader) its own copy of
 * the libcrypto static data, we will need to set the callbacks. The easiest
 * way to detect this is to have a function that returns a pointer to some
 * static data and let the loading application and loaded ENGINE compare
 * their respective values.

 如果加载应用程序(或库)和加载的 ENGINE 库共享相同的静态数据(例如,它们都动态链接
 到相同的 libcrypto.so),我们需要一种方法来避免尝试设置系统回调——这会失败, 
 出于同样的原因,没有必要尝试。 如果加载的 ENGINE 有(或通过加载器获得)
 它自己的 libcrypto 静态数据副本,我们将需要设置回调。 检测这一点的最简单方法是使用
 一个函数返回指向某些静态数据的指针,并让加载应用程序和加载引擎比较它们各自的值。
 */
void *ENGINE_get_static_state(void);

# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void))
# endif

/* BEGIN ERROR CODES */
/*
 * The following lines are auto generated by the script mkerr.pl. Any changes
 * made after this point may be overwritten when the script is next run.
 以下行由脚本 mkerr.pl 自动生成。 下次运行脚本时,在此之后所做的任何更改都可能被覆盖。
 */

int ERR_load_ENGINE_strings(void);

/* Error codes for the ENGINE functions. */

/* Function codes. */
# define ENGINE_F_DYNAMIC_CTRL                            180
# define ENGINE_F_DYNAMIC_GET_DATA_CTX                    181
# define ENGINE_F_DYNAMIC_LOAD                            182
# define ENGINE_F_DYNAMIC_SET_DATA_CTX                    183
# define ENGINE_F_ENGINE_ADD                              105
# define ENGINE_F_ENGINE_BY_ID                            106
# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE                170
# define ENGINE_F_ENGINE_CTRL                             142
# define ENGINE_F_ENGINE_CTRL_CMD                         178
# define ENGINE_F_ENGINE_CTRL_CMD_STRING                  171
# define ENGINE_F_ENGINE_FINISH                           107
# define ENGINE_F_ENGINE_GET_CIPHER                       185
# define ENGINE_F_ENGINE_GET_DIGEST                       186
# define ENGINE_F_ENGINE_GET_FIRST                        195
# define ENGINE_F_ENGINE_GET_LAST                         196
# define ENGINE_F_ENGINE_GET_NEXT                         115
# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH               193
# define ENGINE_F_ENGINE_GET_PKEY_METH                    192
# define ENGINE_F_ENGINE_GET_PREV                         116
# define ENGINE_F_ENGINE_INIT                             119
# define ENGINE_F_ENGINE_LIST_ADD                         120
# define ENGINE_F_ENGINE_LIST_REMOVE                      121
# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY                 150
# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY                  151
# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT             194
# define ENGINE_F_ENGINE_NEW                              122
# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR               197
# define ENGINE_F_ENGINE_REMOVE                           123
# define ENGINE_F_ENGINE_SET_DEFAULT_STRING               189
# define ENGINE_F_ENGINE_SET_ID                           129
# define ENGINE_F_ENGINE_SET_NAME                         130
# define ENGINE_F_ENGINE_TABLE_REGISTER                   184
# define ENGINE_F_ENGINE_UNLOCKED_FINISH                  191
# define ENGINE_F_ENGINE_UP_REF                           190
# define ENGINE_F_INT_CTRL_HELPER                         172
# define ENGINE_F_INT_ENGINE_CONFIGURE                    188
# define ENGINE_F_INT_ENGINE_MODULE_INIT                  187

/* Reason codes. */
# define ENGINE_R_ALREADY_LOADED                          100
# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER                133
# define ENGINE_R_CMD_NOT_EXECUTABLE                      134
# define ENGINE_R_COMMAND_TAKES_INPUT                     135
# define ENGINE_R_COMMAND_TAKES_NO_INPUT                  136
# define ENGINE_R_CONFLICTING_ENGINE_ID                   103
# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED            119
# define ENGINE_R_DSO_FAILURE                             104
# define ENGINE_R_DSO_NOT_FOUND                           132
# define ENGINE_R_ENGINES_SECTION_ERROR                   148
# define ENGINE_R_ENGINE_CONFIGURATION_ERROR              102
# define ENGINE_R_ENGINE_IS_NOT_IN_LIST                   105
# define ENGINE_R_ENGINE_SECTION_ERROR                    149
# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY              128
# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY               129
# define ENGINE_R_FINISH_FAILED                           106
# define ENGINE_R_ID_OR_NAME_MISSING                      108
# define ENGINE_R_INIT_FAILED                             109
# define ENGINE_R_INTERNAL_LIST_ERROR                     110
# define ENGINE_R_INVALID_ARGUMENT                        143
# define ENGINE_R_INVALID_CMD_NAME                        137
# define ENGINE_R_INVALID_CMD_NUMBER                      138
# define ENGINE_R_INVALID_INIT_VALUE                      151
# define ENGINE_R_INVALID_STRING                          150
# define ENGINE_R_NOT_INITIALISED                         117
# define ENGINE_R_NOT_LOADED                              112
# define ENGINE_R_NO_CONTROL_FUNCTION                     120
# define ENGINE_R_NO_INDEX                                144
# define ENGINE_R_NO_LOAD_FUNCTION                        125
# define ENGINE_R_NO_REFERENCE                            130
# define ENGINE_R_NO_SUCH_ENGINE                          116
# define ENGINE_R_UNIMPLEMENTED_CIPHER                    146
# define ENGINE_R_UNIMPLEMENTED_DIGEST                    147
# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD         101
# define ENGINE_R_VERSION_INCOMPATIBILITY                 145

#  ifdef  __cplusplus
}
#  endif
# endif
#endif

猜你喜欢

转载自blog.csdn.net/CHYabc123456hh/article/details/129013918