From 1da47a7e9af19a40d5752cb7f5bd25af982b6541 Mon Sep 17 00:00:00 2001 From: Q Date: Sat, 21 Oct 2023 16:49:16 +0100 Subject: [PATCH] merge --- openssl-sys/src/engine.rs | 90 +++++++++++++++++++++++++++++++++++++++ openssl-sys/src/lib.rs | 2 + 2 files changed, 92 insertions(+) create mode 100644 openssl-sys/src/engine.rs diff --git a/openssl-sys/src/engine.rs b/openssl-sys/src/engine.rs new file mode 100644 index 0000000000..5f46aa523a --- /dev/null +++ b/openssl-sys/src/engine.rs @@ -0,0 +1,90 @@ +use libc::*; +use crate::{ENGINE, EVP_PKEY, SSL, stack_st_X509, stack_st_X509_NAME, X509}; + +extern "C" { + pub fn ENGINE_load_builtin_engines(); + pub fn ENGINE_by_id(id: *const c_char) -> *mut ENGINE; + + pub fn ENGINE_init(e: *mut ENGINE) -> c_int; + pub fn ENGINE_finish(e: *mut ENGINE) -> c_int; + pub fn ENGINE_free(e: *mut ENGINE) -> c_int; + + pub fn ENGINE_ctrl_cmd( + e: *mut ENGINE, + cmd_name: *const c_char, + i: c_long, + p: *mut c_void, + f: extern "C" fn() -> (), + cmd_optional: c_int, + ) -> c_int; + pub fn ENGINE_ctrl_cmd_string( + e: *mut ENGINE, + cmd_name: *const c_char, + arg: *const c_char, + cmd_optional: c_int, + ) -> c_int; + + pub fn ENGINE_load_private_key( + e: *mut ENGINE, + key_id: *const c_char, + ui_method: *mut UI_METHOD, + callback_data: *mut c_void, + ) -> *mut EVP_PKEY; + pub fn ENGINE_load_public_key( + e: *mut ENGINE, + key_id: *const c_char, + ui_method: *mut UI_METHOD, + callback_data: *mut c_void, + ) -> *mut EVP_PKEY; + pub fn ENGINE_load_ssl_client_cert( + e: *mut ENGINE, + ssl: *mut SSL, + ca_dn: *mut stack_st_X509_NAME, + pcert: *mut *mut X509, + ppkey: *mut *mut EVP_PKEY, + pother: *mut *mut stack_st_X509, + ui_method: *mut UI_METHOD, + callback_data: *mut c_void, + ) -> c_int; + + pub fn UI_set_default_method(meth: *const UI_METHOD); + pub fn UI_get_default_method() -> *const UI_METHOD; + pub fn UI_get_method(ui: *mut UI) -> *const UI_METHOD; + pub fn UI_set_method(ui: *mut UI, meth: *const UI_METHOD) -> *const UI_METHOD; + + pub fn UI_OpenSSL() -> *mut UI_METHOD; + pub fn UI_null() -> *const UI_METHOD; +} + +type UI = c_int; +type UI_STRING = c_int; + +pub enum UI_METHOD {} + +// #[repr(C)] +// pub struct UI_METHOD { +// name: *const c_char, +// ui_open_session: extern "C" fn(ui: *mut UI) -> c_int, +// ui_write_string: extern "C" fn(ui: *mut UI, uis: *mut UI_STRING) -> c_int, +// ui_flush: extern "C" fn(ui: *mut UI) -> c_int, +// ui_read_string: extern "C" fn(ui: *mut UI, uis: *mut UI_STRING) -> c_int, +// ui_close_session: extern "C" fn(ui: *mut UI) -> c_int, +// ui_construct_prompt: extern "C" fn( +// ui: *mut UI, +// object_desc: *const c_char, +// object_name: *const c_char, +// ) -> *mut c_char, +// } + +const UI_FLAG_REDOABLE: c_int = 0x0001; +const UI_FLAG_PRINT_ERRORS: c_int = 0x0100; + +#[repr(C)] +pub enum UI_string_types { + UIT_NONE = 0, + UIT_PROMPT, + UIT_VERIFY, + UIT_BOOLEAN, + UIT_INFO, + UIT_ERROR, +} \ No newline at end of file diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 0e23386fd3..1673d0fbc7 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -66,6 +66,7 @@ mod openssl { pub use self::x509::*; pub use self::x509_vfy::*; pub use self::x509v3::*; + pub use self::engine::*; #[macro_use] mod macros; @@ -96,6 +97,7 @@ mod openssl { mod x509; mod x509_vfy; mod x509v3; + mod engine; use std::sync::Once; // explicitly initialize to work around https://github.com/openssl/openssl/issues/3505