diff options
| author | Benjamin Fry <[email protected]> | 2016-02-28 22:05:19 -0800 |
|---|---|---|
| committer | Benjamin Fry <[email protected]> | 2016-02-28 22:05:19 -0800 |
| commit | 3fb2c48c9834acafe8a1dfe33a5500430f332ebc (patch) | |
| tree | ecf306807222f0c305da55e56a1aee0dc9ebc8f5 /openssl/src/crypto/rsa.rs | |
| parent | review fixes, keep raw RSA initiallization private (diff) | |
| download | rust-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.rs | 20 |
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() |