diff options
| author | Steven Fackler <[email protected]> | 2015-09-16 01:13:24 -0400 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-09-16 01:13:24 -0400 |
| commit | 1c3f04138fcf7efd28d3c4b83327b8333944d01b (patch) | |
| tree | 5bfc7371a6f53ba2409b61a0cf9c886142d4fac4 /openssl/src/dh | |
| parent | Merge pull request #262 from jedisct1/read_dhparams (diff) | |
| parent | Use try_ssl_null!() when relevant (diff) | |
| download | rust-openssl-1c3f04138fcf7efd28d3c4b83327b8333944d01b.tar.xz rust-openssl-1c3f04138fcf7efd28d3c4b83327b8333944d01b.zip | |
Merge pull request #261 from jedisct1/try_ssl_null
Use try_ssl_null!() when relevant
Diffstat (limited to 'openssl/src/dh')
| -rw-r--r-- | openssl/src/dh/mod.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/openssl/src/dh/mod.rs b/openssl/src/dh/mod.rs index 7be5dd04..e774abd1 100644 --- a/openssl/src/dh/mod.rs +++ b/openssl/src/dh/mod.rs @@ -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); @@ -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)) } |