Add public interface to access BigNums from RSA keys

This commit is contained in:
Daniel Albert 2016-01-01 19:46:03 +00:00
parent 5e5d24ee25
commit 578fac7e80
1 changed files with 39 additions and 0 deletions

39
openssl/src/crypto/rsa.rs Normal file
View File

@ -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 :(")
}
}