diff options
| author | Steven Fackler <[email protected]> | 2018-02-13 17:25:16 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-02-13 17:25:16 -0800 |
| commit | 41598534b6b1119aaa3f81ccdd91d784b4d88bfc (patch) | |
| tree | 78c2e245583cdfedf473907fee1ef4157afe0e8b /openssl/src | |
| parent | Release openssl 0.10.3 and openssl-sys 0.9.25 (diff) | |
| parent | Added binding for PEM_read_bio_RSAPublicKey (diff) | |
| download | rust-openssl-41598534b6b1119aaa3f81ccdd91d784b4d88bfc.tar.xz rust-openssl-41598534b6b1119aaa3f81ccdd91d784b4d88bfc.zip | |
Merge pull request #838 from olehermanse/master
Added binding for PEM_read_bio_RSAPublicKey
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/rsa.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs index 472ca94f..dfa56d70 100644 --- a/openssl/src/rsa.rs +++ b/openssl/src/rsa.rs @@ -428,6 +428,19 @@ impl Rsa<Public> { ffi::PEM_read_bio_RSA_PUBKEY } + from_pem! { + /// Decodes a PEM-encoded PKCS#1 RSAPublicKey structure. + /// + /// The input should have a header of `-----BEGIN RSA PUBLIC KEY-----`. + /// + /// This corresponds to [`PEM_read_bio_RSAPublicKey`]. + /// + /// [`PEM_read_bio_RSAPublicKey`]: https://www.openssl.org/docs/man1.0.2/crypto/PEM_read_bio_RSAPublicKey.html + public_key_from_pem_pkcs1, + Rsa<Public>, + ffi::PEM_read_bio_RSAPublicKey + } + from_der! { /// Decodes a DER-encoded SubjectPublicKeyInfo structure containing an RSA key. /// @@ -732,4 +745,18 @@ mod test { .unwrap(); assert_eq!(msg, &dmesg[..len]); } + + #[test] + fn test_public_key_from_pem_pkcs1() { + let key = include_bytes!("../test/pkcs1.pem.pub"); + Rsa::public_key_from_pem_pkcs1(key).unwrap(); + } + + #[test] + #[should_panic] + fn test_public_key_from_pem_pkcs1_panic() { + let key = include_bytes!("../test/key.pem.pub"); + Rsa::public_key_from_pem_pkcs1(key).unwrap(); + } + } |