aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--openssl-sys/src/lib.rs2
-rw-r--r--openssl/src/rsa.rs9
2 files changed, 10 insertions, 1 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index 00e1208b..d57f4bb7 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -2430,6 +2430,8 @@ extern "C" {
pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *mut *mut u8) -> c_int;
pub fn d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
+ pub fn i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
+ pub fn d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
pub fn i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int;
pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
diff --git a/openssl/src/rsa.rs b/openssl/src/rsa.rs
index 31e1a349..22a9c36f 100644
--- a/openssl/src/rsa.rs
+++ b/openssl/src/rsa.rs
@@ -38,12 +38,16 @@ foreign_type! {
}
impl RsaRef {
+ // FIXME these need to specify output format
private_key_to_pem!(ffi::PEM_write_bio_RSAPrivateKey);
public_key_to_pem!(ffi::PEM_write_bio_RSA_PUBKEY);
private_key_to_der!(ffi::i2d_RSAPrivateKey);
public_key_to_der!(ffi::i2d_RSA_PUBKEY);
+ to_der_inner!(/// Serializes the public key to DER-encoded PKCS#1.
+ public_key_to_der_pkcs1, ffi::i2d_RSAPublicKey);
+
// FIXME should return u32
pub fn size(&self) -> usize {
unsafe {
@@ -255,11 +259,15 @@ impl Rsa {
}
}
+ // FIXME these need to identify input formats
private_key_from_pem!(Rsa, ffi::PEM_read_bio_RSAPrivateKey);
private_key_from_der!(Rsa, ffi::d2i_RSAPrivateKey);
public_key_from_pem!(Rsa, ffi::PEM_read_bio_RSA_PUBKEY);
public_key_from_der!(Rsa, ffi::d2i_RSA_PUBKEY);
+ from_der_inner!(/// Deserializes a public key from DER-encoded PKCS#1 data.
+ public_key_from_der_pkcs1, Rsa, ffi::d2i_RSAPublicKey);
+
#[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")]
pub fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Rsa, ErrorStack>
where F: FnOnce(&mut [c_char]) -> usize
@@ -440,5 +448,4 @@ mod test {
let len = k1.private_decrypt(&emesg, &mut dmesg, PKCS1_PADDING).unwrap();
assert_eq!(msg, &dmesg[..len]);
}
-
}