diff options
| author | Cyberunner23 <[email protected]> | 2016-01-09 14:36:01 -0500 |
|---|---|---|
| committer | Cyberunner23 <[email protected]> | 2016-01-09 14:36:01 -0500 |
| commit | c0b9a4c8ecafc212cd9a0418751b9df89fec9d1f (patch) | |
| tree | 4481359b788713fb0872e94e1106fee7570c4664 | |
| parent | Added private_rsa_key_from_pem and public_rsa_key_from_pem. (diff) | |
| download | rust-openssl-c0b9a4c8ecafc212cd9a0418751b9df89fec9d1f.tar.xz rust-openssl-c0b9a4c8ecafc212cd9a0418751b9df89fec9d1f.zip | |
Added tests for private_rsa_key_from_pem() and public_rsa_key_from_pem()
| -rw-r--r-- | openssl-sys/src/lib.rs | 2 | ||||
| -rw-r--r-- | openssl/src/crypto/pkey.rs | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 22c40d29..5554d478 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -527,7 +527,7 @@ extern "C" { pub fn PEM_read_bio_PUBKEY(bio: *mut BIO, out: *mut *mut EVP_PKEY, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut X509; - pub fn PEM_read_bio_RSAPrivateKey(bio: *mut BIO, rsa: *mut *mut RSA, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut RSA; + pub fn PEM_read_bio_RSAPrivateKey(bio: *mut BIO, rsa: *mut *mut RSA, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut RSA; pub fn PEM_read_bio_RSA_PUBKEY(bio: *mut BIO, rsa: *mut *mut RSA, callback: Option<PasswordCallback>, user_data: *mut c_void) -> *mut RSA; pub fn PEM_write_bio_PrivateKey(bio: *mut BIO, pkey: *mut EVP_PKEY, cipher: *const EVP_CIPHER, diff --git a/openssl/src/crypto/pkey.rs b/openssl/src/crypto/pkey.rs index d6f09931..fafee78b 100644 --- a/openssl/src/crypto/pkey.rs +++ b/openssl/src/crypto/pkey.rs @@ -662,6 +662,26 @@ mod tests { } #[test] + fn test_private_rsa_key_from_pem() { + let key_path = Path::new("test/key.pem"); + let mut file = File::open(&key_path) + .ok() + .expect("Failed to open `test/key.pem`"); + + super::PKey::private_rsa_key_from_pem(&mut file).unwrap(); + } + + #[test] + fn test_public_rsa_key_from_pem() { + let key_path = Path::new("test/key.pem.pub"); + let mut file = File::open(&key_path) + .ok() + .expect("Failed to open `test/key.pem.pub`"); + + super::PKey::public_rsa_key_from_pem(&mut file).unwrap(); + } + + #[test] fn test_private_encrypt() { let mut k0 = super::PKey::new(); let mut k1 = super::PKey::new(); |