diff options
| author | Steven Fackler <[email protected]> | 2016-08-08 19:04:30 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-08-08 19:04:30 -0700 |
| commit | e4b97921a9ff2f1bddd49f4a64981ccfeadd9b04 (patch) | |
| tree | 7a7eef4ce053268991c7155f6fa6ea582bc02442 /openssl/src/crypto/dsa.rs | |
| parent | Fix build on 1.9 (diff) | |
| download | rust-openssl-e4b97921a9ff2f1bddd49f4a64981ccfeadd9b04.tar.xz rust-openssl-e4b97921a9ff2f1bddd49f4a64981ccfeadd9b04.zip | |
Clean up RSA and DSA accessors
Diffstat (limited to 'openssl/src/crypto/dsa.rs')
| -rw-r--r-- | openssl/src/crypto/dsa.rs | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/openssl/src/crypto/dsa.rs b/openssl/src/crypto/dsa.rs index 099657da..7852d391 100644 --- a/openssl/src/crypto/dsa.rs +++ b/openssl/src/crypto/dsa.rs @@ -145,7 +145,7 @@ impl DSA { } pub fn size(&self) -> Option<u32> { - if self.has_q() { + if self.q().is_some() { unsafe { Some(ffi::DSA_size(self.0) as u32) } } else { None @@ -189,31 +189,37 @@ impl DSA { self.0 } - pub fn p<'a>(&'a self) -> BigNumRef<'a> { - assert!(self.has_p()); - unsafe { BigNumRef::from_handle((*self.0).p) } - } - - pub fn has_p(&self) -> bool { - unsafe { !(*self.0).p.is_null() } - } - - pub fn q<'a>(&'a self) -> BigNumRef<'a> { - assert!(self.has_q()); - unsafe { BigNumRef::from_handle((*self.0).q) } - } - - pub fn has_q(&self) -> bool { - unsafe { !(*self.0).q.is_null() } + pub fn p<'a>(&'a self) -> Option<BigNumRef<'a>> { + unsafe { + let p = (*self.0).p; + if p.is_null() { + None + } else { + Some(BigNumRef::from_handle((*self.0).p)) + } + } } - pub fn g<'a>(&'a self) -> BigNumRef<'a> { - assert!(self.has_g()); - unsafe { BigNumRef::from_handle((*self.0).g) } + pub fn q<'a>(&'a self) -> Option<BigNumRef<'a>> { + unsafe { + let q = (*self.0).q; + if q.is_null() { + None + } else { + Some(BigNumRef::from_handle((*self.0).q)) + } + } } - pub fn has_g(&self) -> bool { - unsafe { !(*self.0).q.is_null() } + pub fn g<'a>(&'a self) -> Option<BigNumRef<'a>> { + unsafe { + let g = (*self.0).g; + if g.is_null() { + None + } else { + Some(BigNumRef::from_handle((*self.0).g)) + } + } } pub fn has_public_key(&self) -> bool { |