Added binding for PEM_read_bio_RSAPublicKey
Signed-off-by: Ole Herman Schumacher Elgesem <oleherman93@gmail.com>
This commit is contained in:
parent
9f35b74c1d
commit
041d473c0a
|
|
@ -2111,6 +2111,14 @@ extern "C" {
|
||||||
callback: Option<PasswordCallback>,
|
callback: Option<PasswordCallback>,
|
||||||
user_data: *mut c_void,
|
user_data: *mut c_void,
|
||||||
) -> *mut RSA;
|
) -> *mut RSA;
|
||||||
|
|
||||||
|
pub fn PEM_read_bio_RSAPublicKey(
|
||||||
|
bio: *mut BIO,
|
||||||
|
rsa: *mut *mut RSA,
|
||||||
|
callback: Option<PasswordCallback>,
|
||||||
|
user_data: *mut c_void,
|
||||||
|
) -> *mut RSA;
|
||||||
|
|
||||||
pub fn PEM_read_bio_RSA_PUBKEY(
|
pub fn PEM_read_bio_RSA_PUBKEY(
|
||||||
bio: *mut BIO,
|
bio: *mut BIO,
|
||||||
rsa: *mut *mut RSA,
|
rsa: *mut *mut RSA,
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,19 @@ impl Rsa<Public> {
|
||||||
ffi::PEM_read_bio_RSA_PUBKEY
|
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! {
|
from_der! {
|
||||||
/// Decodes a DER-encoded SubjectPublicKeyInfo structure containing an RSA key.
|
/// Decodes a DER-encoded SubjectPublicKeyInfo structure containing an RSA key.
|
||||||
///
|
///
|
||||||
|
|
@ -732,4 +745,18 @@ mod test {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(msg, &dmesg[..len]);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
-----BEGIN RSA PUBLIC KEY-----
|
||||||
|
MIIBCgKCAQEAyrcf7lv42BCoiDd3LYmF8eaGO4rhmGzGgi+NSZowkEuLhibHGQle
|
||||||
|
FkZC7h1VKsxKFgy7Fx+GYHkv9OLm9H5fdp3HhYlo19bZVGvSJ66OJe/Bc4S02bBb
|
||||||
|
Y8vwpc/N5O77m5J/nHLuL7XJtpfSKkX+3NPiX1X2L99iipt7F0a7hNws3G3Lxg6t
|
||||||
|
P3Yc55TPjXzXvDIgjt/fag6iF8L/bR3augJJdDhLzNucR8A5HcvPtIVo51R631Zq
|
||||||
|
MCh+dZvgz9zGCXwsvSky/iOJTHN3wnpsWuCAzS1iJMfjR783Tfv6sWFs19FH7pHP
|
||||||
|
xBA3b2enPM9KBzINGOly0eM4h0fh+VBltQIDAQAB
|
||||||
|
-----END RSA PUBLIC KEY-----
|
||||||
Loading…
Reference in New Issue