diff options
| author | Steven Fackler <[email protected]> | 2016-08-07 14:19:44 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-08-07 14:33:18 -0700 |
| commit | 05089bacb3cde8fe3ec9f68b5682668d4f63383c (patch) | |
| tree | e2f7d2bb028e02504e1eecb62b4f91e2f83adb9c /openssl/src/crypto/dsa.rs | |
| parent | Clean up asn1time (diff) | |
| download | rust-openssl-05089bacb3cde8fe3ec9f68b5682668d4f63383c.tar.xz rust-openssl-05089bacb3cde8fe3ec9f68b5682668d4f63383c.zip | |
Refactor BigNum
Diffstat (limited to 'openssl/src/crypto/dsa.rs')
| -rw-r--r-- | openssl/src/crypto/dsa.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/openssl/src/crypto/dsa.rs b/openssl/src/crypto/dsa.rs index 40702627..84024379 100644 --- a/openssl/src/crypto/dsa.rs +++ b/openssl/src/crypto/dsa.rs @@ -4,7 +4,7 @@ use error::ErrorStack; use std::ptr; use libc::{c_uint, c_int, c_char, c_void}; -use bn::BigNum; +use bn::BigNumRef; use bio::{MemBio, MemBioSlice}; use crypto::hash; use crypto::HashTypeInternals; @@ -189,25 +189,27 @@ impl DSA { self.0 } - // The following getters are unsafe, since BigNum::new_from_ffi fails upon null pointers - pub fn p(&self) -> Result<BigNum, ErrorStack> { - unsafe { BigNum::new_from_ffi((*self.0).p) } + 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(&self) -> Result<BigNum, ErrorStack> { - unsafe { BigNum::new_from_ffi((*self.0).q) } + 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 g(&self) -> Result<BigNum, ErrorStack> { - unsafe { BigNum::new_from_ffi((*self.0).g) } + pub fn g<'a>(&'a self) -> BigNumRef<'a> { + assert!(self.has_g()); + unsafe { BigNumRef::from_handle((*self.0).g) } } pub fn has_g(&self) -> bool { |