From 76c784340c3851f402abc38dff8fa5f008cdc4d4 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 25 Feb 2019 13:32:05 +0800 Subject: support NO_ENGINE (#4763) * support OPENSSL_NO_ENGINE * support some new openssl config args * sigh --- src/_cffi_src/openssl/engine.py | 68 +++++++++++++++++++++++++++++++++++++++++ src/_cffi_src/openssl/ssl.py | 1 - 2 files changed, 68 insertions(+), 1 deletion(-) (limited to 'src/_cffi_src') diff --git a/src/_cffi_src/openssl/engine.py b/src/_cffi_src/openssl/engine.py index c255bbbc..8996f0c8 100644 --- a/src/_cffi_src/openssl/engine.py +++ b/src/_cffi_src/openssl/engine.py @@ -27,6 +27,7 @@ typedef ... UI_METHOD; static const unsigned int ENGINE_METHOD_RAND; static const int ENGINE_R_CONFLICTING_ENGINE_ID; +static const long Cryptography_HAS_ENGINE; """ FUNCTIONS = """ @@ -69,4 +70,71 @@ void ENGINE_cleanup(void); """ CUSTOMIZATIONS = """ +#ifdef OPENSSL_NO_ENGINE +static const long Cryptography_HAS_ENGINE = 0; +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *); +typedef void *ENGINE_CTRL_FUNC_PTR; +typedef void *ENGINE_LOAD_KEY_PTR; +typedef void *ENGINE_CIPHERS_PTR; +typedef void *ENGINE_DIGESTS_PTR; +typedef struct ENGINE_CMD_DEFN_st { + unsigned int cmd_num; + const char *cmd_name; + const char *cmd_desc; + unsigned int cmd_flags; +} ENGINE_CMD_DEFN; + +/* This section is so osrandom_engine.c can successfully compile even + when engine support is disabled */ +#define ENGINE_CMD_BASE 0 +#define ENGINE_CMD_FLAG_NO_INPUT 0 +#define ENGINE_F_ENGINE_CTRL 0 +#define ENGINE_R_INVALID_ARGUMENT 0 +#define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 0 +int (*ENGINE_set_cmd_defns)(ENGINE *, const ENGINE_CMD_DEFN *) = NULL; + +static const unsigned int ENGINE_METHOD_RAND = 0; +static const int ENGINE_R_CONFLICTING_ENGINE_ID = 0; + +ENGINE *(*ENGINE_get_first)(void) = NULL; +ENGINE *(*ENGINE_get_last)(void) = NULL; +int (*ENGINE_add)(ENGINE *) = NULL; +int (*ENGINE_remove)(ENGINE *) = NULL; +ENGINE *(*ENGINE_by_id)(const char *) = NULL; +int (*ENGINE_init)(ENGINE *) = NULL; +int (*ENGINE_finish)(ENGINE *) = NULL; +void (*ENGINE_load_builtin_engines)(void) = NULL; +ENGINE *(*ENGINE_get_default_RAND)(void) = NULL; +int (*ENGINE_set_default_RAND)(ENGINE *) = NULL; +int (*ENGINE_register_RAND)(ENGINE *) = NULL; +void (*ENGINE_unregister_RAND)(ENGINE *) = NULL; +void (*ENGINE_register_all_RAND)(void) = NULL; +int (*ENGINE_ctrl)(ENGINE *, int, long, void *, void (*)(void)) = NULL; +int (*ENGINE_ctrl_cmd)(ENGINE *, const char *, long, void *, + void (*)(void), int) = NULL; +int (*ENGINE_ctrl_cmd_string)(ENGINE *, const char *, const char *, + int) = NULL; + +ENGINE *(*ENGINE_new)(void) = NULL; +int (*ENGINE_free)(ENGINE *) = NULL; +int (*ENGINE_up_ref)(ENGINE *) = NULL; +int (*ENGINE_set_id)(ENGINE *, const char *) = NULL; +int (*ENGINE_set_name)(ENGINE *, const char *) = NULL; +int (*ENGINE_set_RAND)(ENGINE *, const RAND_METHOD *) = NULL; +int (*ENGINE_set_destroy_function)(ENGINE *, ENGINE_GEN_INT_FUNC_PTR) = NULL; +int (*ENGINE_set_init_function)(ENGINE *, ENGINE_GEN_INT_FUNC_PTR) = NULL; +int (*ENGINE_set_finish_function)(ENGINE *, ENGINE_GEN_INT_FUNC_PTR) = NULL; +int (*ENGINE_set_ctrl_function)(ENGINE *, ENGINE_CTRL_FUNC_PTR) = NULL; +const char *(*ENGINE_get_id)(const ENGINE *) = NULL; +const char *(*ENGINE_get_name)(const ENGINE *) = NULL; +const RAND_METHOD *(*ENGINE_get_RAND)(const ENGINE *) = NULL; + +void (*ENGINE_add_conf_module)(void) = NULL; +/* these became macros in 1.1.0 */ +void (*ENGINE_load_openssl)(void) = NULL; +void (*ENGINE_load_dynamic)(void) = NULL; +void (*ENGINE_cleanup)(void) = NULL; +#else +static const long Cryptography_HAS_ENGINE = 1; +#endif """ diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py index 2218095c..92fd1e3e 100644 --- a/src/_cffi_src/openssl/ssl.py +++ b/src/_cffi_src/openssl/ssl.py @@ -334,7 +334,6 @@ int SSL_SESSION_print(BIO *, const SSL_SESSION *); const COMP_METHOD *SSL_get_current_compression(SSL *); const COMP_METHOD *SSL_get_current_expansion(SSL *); const char *SSL_COMP_get_name(const COMP_METHOD *); -int SSL_CTX_set_client_cert_engine(SSL_CTX *, ENGINE *); unsigned long SSL_set_mode(SSL *, unsigned long); unsigned long SSL_get_mode(SSL *); -- cgit v1.2.3