Add SslRef::set_{tmp_dh,tmp_ecdh,ecdh_auto}
This commit is contained in:
parent
2a1d7b2bcb
commit
96d24c8957
|
|
@ -1233,6 +1233,14 @@ pub unsafe fn SSL_CTX_set_tmp_ecdh(ctx: *mut SSL_CTX, key: *mut EC_KEY) -> c_lon
|
|||
SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
|
||||
}
|
||||
|
||||
pub unsafe fn SSL_set_tmp_dh(ssl: *mut SSL, dh: *mut DH) -> c_long {
|
||||
SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void)
|
||||
}
|
||||
|
||||
pub unsafe fn SSL_set_tmp_ecdh(ssl: *mut SSL, key: *mut EC_KEY) -> c_long {
|
||||
SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void)
|
||||
}
|
||||
|
||||
pub unsafe fn SSL_CTX_add_extra_chain_cert(ctx: *mut SSL_CTX, x509: *mut X509) -> c_long {
|
||||
SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, x509 as *mut c_void)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -533,11 +533,17 @@ fn set_id_callback() {
|
|||
fn set_id_callback() {}
|
||||
|
||||
// macros
|
||||
|
||||
#[cfg(ossl102)]
|
||||
pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int {
|
||||
::SSL_CTX_ctrl(ctx, SSL_CTRL_SET_ECDH_AUTO, onoff as c_long, ::std::ptr::null_mut()) as c_int
|
||||
}
|
||||
|
||||
#[cfg(ossl102)]
|
||||
pub unsafe fn SSL_set_ecdh_auto(ssl: *mut ::SSL, onoff: c_int) -> c_int {
|
||||
::SSL_ctrl(ssl, SSL_CTRL_SET_ECDH_AUTO, onoff as c_long, ::std::ptr::null_mut()) as c_int
|
||||
}
|
||||
|
||||
extern {
|
||||
pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO;
|
||||
pub fn BIO_s_file() -> *mut BIO_METHOD;
|
||||
|
|
|
|||
|
|
@ -1083,6 +1083,10 @@ impl SslRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_tmp_dh(&mut self, dh: &DhRef) -> Result<(), ErrorStack> {
|
||||
unsafe { cvt(ffi::SSL_set_tmp_dh(self.as_ptr(), dh.as_ptr()) as c_int).map(|_| ()) }
|
||||
}
|
||||
|
||||
pub fn set_tmp_dh_callback<F>(&mut self, callback: F)
|
||||
where F: Fn(&mut SslRef, bool, u32) -> Result<Dh, ErrorStack> + Any + 'static + Sync + Send
|
||||
{
|
||||
|
|
@ -1096,6 +1100,10 @@ impl SslRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_tmp_ecdh(&mut self, key: &EcKeyRef) -> Result<(), ErrorStack> {
|
||||
unsafe { cvt(ffi::SSL_set_tmp_ecdh(self.as_ptr(), key.as_ptr()) as c_int).map(|_| ()) }
|
||||
}
|
||||
|
||||
/// Requires the `v101` feature and OpenSSL 1.0.1, or the `v102` feature and OpenSSL 1.0.2.
|
||||
#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))]
|
||||
pub fn set_tmp_ecdh_callback<F>(&mut self, callback: F)
|
||||
|
|
@ -1111,6 +1119,16 @@ impl SslRef {
|
|||
}
|
||||
}
|
||||
|
||||
/// If `onoff` is set to `true`, enable ECDHE for key exchange with
|
||||
/// compatible clients, and automatically select an appropriate elliptic
|
||||
/// curve.
|
||||
///
|
||||
/// Requires the `v102` feature and OpenSSL 1.0.2.
|
||||
#[cfg(all(feature = "v102", ossl102))]
|
||||
pub fn set_ecdh_auto(&mut self, onoff: bool) -> Result<(), ErrorStack> {
|
||||
unsafe { cvt(ffi::SSL_set_ecdh_auto(self.as_ptr(), onoff as c_int)).map(|_| ()) }
|
||||
}
|
||||
|
||||
pub fn current_cipher(&self) -> Option<&SslCipherRef> {
|
||||
unsafe {
|
||||
let ptr = ffi::SSL_get_current_cipher(self.as_ptr());
|
||||
|
|
|
|||
Loading…
Reference in New Issue