Loading openssl/src/dh/mod.rs +4 −16 Original line number Diff line number Diff line Loading @@ -11,10 +11,7 @@ pub struct DH(*mut ffi::DH); impl DH { pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result<DH, SslError> { let dh = unsafe { ffi::DH_new_from_params(p.raw(), g.raw(), q.raw()) }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_new_from_params(p.raw(), g.raw(), q.raw()) }); mem::forget(p); mem::forget(g); mem::forget(q); Loading @@ -33,28 +30,19 @@ impl DH { #[cfg(feature = "rfc5114")] pub fn get_1024_160() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_1024_160() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_1024_160() }); Ok(DH(dh)) } #[cfg(feature = "rfc5114")] pub fn get_2048_224() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_2048_224() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_2048_224() }); Ok(DH(dh)) } #[cfg(feature = "rfc5114")] pub fn get_2048_256() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_2048_256() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_2048_256() }); Ok(DH(dh)) } Loading openssl/src/ssl/mod.rs +3 −12 Original line number Diff line number Diff line Loading @@ -432,10 +432,7 @@ impl SslContext { pub fn new(method: SslMethod) -> Result<SslContext, SslError> { init(); let ctx = unsafe { ffi::SSL_CTX_new(method.to_raw()) }; if ctx == ptr::null_mut() { return Err(SslError::get()); } let ctx = try_ssl_null!(unsafe { ffi::SSL_CTX_new(method.to_raw()) }); let ctx = SslContext { ctx: ctx }; Loading Loading @@ -690,10 +687,7 @@ impl Drop for Ssl { impl Ssl { pub fn new(ctx: &SslContext) -> Result<Ssl, SslError> { let ssl = unsafe { ffi::SSL_new(ctx.ctx) }; if ssl == ptr::null_mut() { return Err(SslError::get()); } let ssl = try_ssl_null!(unsafe { ffi::SSL_new(ctx.ctx) }); let ssl = Ssl { ssl: ssl }; Ok(ssl) } Loading Loading @@ -1019,10 +1013,7 @@ impl DirectStream<net::TcpStream> { impl<S> DirectStream<S> { fn new_base(ssl: Ssl, stream: S, sock: c_int) -> Result<DirectStream<S>, SslError> { unsafe { let bio = ffi::BIO_new_socket(sock, 0); if bio == ptr::null_mut() { return Err(SslError::get()); } let bio = try_ssl_null!(ffi::BIO_new_socket(sock, 0)); ffi::SSL_set_bio(ssl.ssl, bio, bio); } Loading Loading
openssl/src/dh/mod.rs +4 −16 Original line number Diff line number Diff line Loading @@ -11,10 +11,7 @@ pub struct DH(*mut ffi::DH); impl DH { pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result<DH, SslError> { let dh = unsafe { ffi::DH_new_from_params(p.raw(), g.raw(), q.raw()) }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_new_from_params(p.raw(), g.raw(), q.raw()) }); mem::forget(p); mem::forget(g); mem::forget(q); Loading @@ -33,28 +30,19 @@ impl DH { #[cfg(feature = "rfc5114")] pub fn get_1024_160() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_1024_160() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_1024_160() }); Ok(DH(dh)) } #[cfg(feature = "rfc5114")] pub fn get_2048_224() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_2048_224() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_2048_224() }); Ok(DH(dh)) } #[cfg(feature = "rfc5114")] pub fn get_2048_256() -> Result<DH, SslError> { let dh = unsafe { ffi::DH_get_2048_256() }; if dh == ptr::null_mut() { return Err(SslError::get()); } let dh = try_ssl_null!(unsafe { ffi::DH_get_2048_256() }); Ok(DH(dh)) } Loading
openssl/src/ssl/mod.rs +3 −12 Original line number Diff line number Diff line Loading @@ -432,10 +432,7 @@ impl SslContext { pub fn new(method: SslMethod) -> Result<SslContext, SslError> { init(); let ctx = unsafe { ffi::SSL_CTX_new(method.to_raw()) }; if ctx == ptr::null_mut() { return Err(SslError::get()); } let ctx = try_ssl_null!(unsafe { ffi::SSL_CTX_new(method.to_raw()) }); let ctx = SslContext { ctx: ctx }; Loading Loading @@ -690,10 +687,7 @@ impl Drop for Ssl { impl Ssl { pub fn new(ctx: &SslContext) -> Result<Ssl, SslError> { let ssl = unsafe { ffi::SSL_new(ctx.ctx) }; if ssl == ptr::null_mut() { return Err(SslError::get()); } let ssl = try_ssl_null!(unsafe { ffi::SSL_new(ctx.ctx) }); let ssl = Ssl { ssl: ssl }; Ok(ssl) } Loading Loading @@ -1019,10 +1013,7 @@ impl DirectStream<net::TcpStream> { impl<S> DirectStream<S> { fn new_base(ssl: Ssl, stream: S, sock: c_int) -> Result<DirectStream<S>, SslError> { unsafe { let bio = ffi::BIO_new_socket(sock, 0); if bio == ptr::null_mut() { return Err(SslError::get()); } let bio = try_ssl_null!(ffi::BIO_new_socket(sock, 0)); ffi::SSL_set_bio(ssl.ssl, bio, bio); } Loading