aboutsummaryrefslogtreecommitdiff
path: root/openssl/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2017-07-04 20:57:00 -0700
committerSteven Fackler <[email protected]>2017-07-04 20:57:00 -0700
commit51a226eb4b4977ce26945cf608d1be34b10d6286 (patch)
treee6401763ae3e668709777d35d4402435c560c0f7 /openssl/src
parentMerge pull request #655 from ltratt/master (diff)
downloadrust-openssl-51a226eb4b4977ce26945cf608d1be34b10d6286.tar.xz
rust-openssl-51a226eb4b4977ce26945cf608d1be34b10d6286.zip
Support PKCS#1 RSA public keys
Closes #656
Diffstat (limited to 'openssl/src')
-rw-r--r--openssl/src/rsa.rs9
1 files changed, 8 insertions, 1 deletions
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]);
}
-
}