diff --git a/openssl-sys/src/crypto.rs b/openssl-sys/src/crypto.rs index 6d8096f73a..d7281210ab 100644 --- a/openssl-sys/src/crypto.rs +++ b/openssl-sys/src/crypto.rs @@ -128,3 +128,9 @@ extern "C" { pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; } + +#[repr(C)] +pub struct CRYPTO_EX_DATA { + sk: *mut c_void, + dummy: c_int +} diff --git a/openssl-sys/src/engine.rs b/openssl-sys/src/engine.rs new file mode 100644 index 0000000000..496f1d845a --- /dev/null +++ b/openssl-sys/src/engine.rs @@ -0,0 +1,62 @@ +use libc::*; +use *; + +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 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 c_void, ui_method: *mut UI_METHOD, callback_data: *mut c_void + ) -> c_int; +} + +#[repr(C)] +pub struct UI_METHOD { + name: *const c_char, + ui_open_session: extern fn(ui: *mut UI) -> c_int, + ui_write_string: extern fn(ui: *mut UI, uis: *mut UI_STRING) -> c_int, + ui_flush: extern fn(ui: *mut UI) -> c_int, + ui_read_string: extern fn(ui: *mut UI, uis: *mut UI_STRING) -> c_int, + ui_close_session: extern fn(ui: *mut UI) -> c_int, + ui_construct_prompt: extern 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 struct UI { + meth: *const UI_METHOD, + strings: *mut c_void, + user_data: *mut c_void, + ex_data: CRYPTO_EX_DATA, + flags: c_int, +} + +#[repr(C)] +pub struct UI_STRING { + string_type: UI_string_types, + out_string: *const c_char, + input_flags: c_int, + result_buf: *mut c_char, +} + +#[repr(C)] +pub enum UI_string_types { + UIT_NONE=0, + UIT_PROMPT, + UIT_VERIFY, + UIT_BOOLEAN, + UIT_INFO, + UIT_ERROR, +} diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 9596a59b5b..0453c55e1f 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -29,6 +29,7 @@ pub use dtls1::*; pub use ec::*; pub use err::*; pub use evp::*; +pub use engine::*; pub use hmac::*; pub use obj_mac::*; pub use object::*; @@ -66,6 +67,7 @@ mod dtls1; mod ec; mod err; mod evp; +mod engine; mod hmac; mod obj_mac; mod object; diff --git a/openssl-sys/src/ssl.rs b/openssl-sys/src/ssl.rs index f60b129bc7..1c7d9b43a8 100644 --- a/openssl-sys/src/ssl.rs +++ b/openssl-sys/src/ssl.rs @@ -1149,6 +1149,8 @@ extern "C" { #[cfg(not(libressl))] pub fn SSL_CTX_add_client_CA(ctx: *mut SSL_CTX, cacert: *mut X509) -> c_int; + pub fn SSL_CTX_set_client_cert_cb(ctx: *mut SSL_CTX, client_cert_cb: extern fn(ssl: *mut SSL, x509: *mut*mut X509, pkey: *mut*mut EVP_PKEY)); + pub fn SSL_CTX_set_default_verify_paths(ctx: *mut SSL_CTX) -> c_int; pub fn SSL_CTX_load_verify_locations( ctx: *mut SSL_CTX,