aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/crypto/rsa.rs
diff options
context:
space:
mode:
authorBenjamin Fry <[email protected]>2016-02-28 22:05:19 -0800
committerBenjamin Fry <[email protected]>2016-02-28 22:05:19 -0800
commit3fb2c48c9834acafe8a1dfe33a5500430f332ebc (patch)
treeecf306807222f0c305da55e56a1aee0dc9ebc8f5 /openssl/src/crypto/rsa.rs
parentreview fixes, keep raw RSA initiallization private (diff)
downloadrust-openssl-3fb2c48c9834acafe8a1dfe33a5500430f332ebc.tar.xz
rust-openssl-3fb2c48c9834acafe8a1dfe33a5500430f332ebc.zip
added public key material to the constructor
Diffstat (limited to 'openssl/src/crypto/rsa.rs')
-rw-r--r--openssl/src/crypto/rsa.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/openssl/src/crypto/rsa.rs b/openssl/src/crypto/rsa.rs
index 80eec7da..3cd3ce75 100644
--- a/openssl/src/crypto/rsa.rs
+++ b/openssl/src/crypto/rsa.rs
@@ -20,14 +20,16 @@ impl Drop for RSA {
impl RSA {
/// only useful for associating the key material directly with the key, it's safer to use
/// the supplied load and save methods for DER formatted keys.
- pub fn new() -> Result<RSA, SslError> {
+ pub fn from_public_components(n: BigNum, e: BigNum) -> Result<RSA, SslError> {
unsafe {
let rsa = try_ssl_null!(ffi::RSA_new());
+ (*rsa).n = n.into_raw();
+ (*rsa).e = e.into_raw();
Ok(RSA(rsa))
}
}
- pub fn with_raw(rsa: *mut ffi::RSA) -> RSA {
+ pub fn from_raw(rsa: *mut ffi::RSA) -> RSA {
RSA(rsa)
}
@@ -74,13 +76,6 @@ impl RSA {
}
}
- /// set the key modulus
- pub fn set_n(&mut self, n: BigNum) {
- unsafe {
- (*self.0).n = n.into_raw();
- }
- }
-
pub fn has_n(&self) -> bool {
unsafe {
!(*self.0).n.is_null()
@@ -99,13 +94,6 @@ impl RSA {
}
}
- /// set the exponent
- pub fn set_e(&mut self, e: BigNum) {
- unsafe {
- (*self.0).e = e.into_raw();
- }
- }
-
pub fn has_e(&self) -> bool {
unsafe {
!(*self.0).e.is_null()