diff options
| author | Daniel Albert <[email protected]> | 2016-01-01 19:46:03 +0000 |
|---|---|---|
| committer | Daniel Albert <[email protected]> | 2016-01-01 19:46:03 +0000 |
| commit | 578fac7e80bf20da802815d890cb6b54e280eb6b (patch) | |
| tree | 8388d379d6c1a87a08b1b1c983e73fa558bc26ed /openssl/src | |
| parent | Implement the possibility to create BigNums from their ffi counterpart (diff) | |
| download | rust-openssl-578fac7e80bf20da802815d890cb6b54e280eb6b.tar.xz rust-openssl-578fac7e80bf20da802815d890cb6b54e280eb6b.zip | |
Add public interface to access BigNums from RSA keys
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/crypto/rsa.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/openssl/src/crypto/rsa.rs b/openssl/src/crypto/rsa.rs new file mode 100644 index 00000000..ef59a07e --- /dev/null +++ b/openssl/src/crypto/rsa.rs @@ -0,0 +1,39 @@ +use ffi; +use bn::BigNum; +use std::fmt; + +pub struct RSA { + pub rsa_obj : ffi::RSA +} + +impl RSA { + pub unsafe fn get_n(&self) -> BigNum { + BigNum::new_from_ffi(self.rsa_obj.n).unwrap() + } + + pub unsafe fn get_d(&self) -> BigNum { + BigNum::new_from_ffi(self.rsa_obj.d).unwrap() + } + + pub unsafe fn get_e(&self) -> BigNum { + BigNum::new_from_ffi(self.rsa_obj.e).unwrap() + } + + pub unsafe fn get_p(&self) -> BigNum { + BigNum::new_from_ffi(self.rsa_obj.p).unwrap() + } + + pub unsafe fn get_q(&self) -> BigNum { + BigNum::new_from_ffi(self.rsa_obj.q).unwrap() + } + + pub fn get_type(&self) -> &str { + "rsa" + } +} + +impl fmt::Debug for RSA { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Currently no debug output. Sorry :(") + } +} |