parent
026ed1fa07
commit
51a226eb4b
|
|
@ -2421,6 +2421,8 @@ extern "C" {
|
||||||
|
|
||||||
pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *mut *mut u8) -> c_int;
|
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 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 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;
|
pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,16 @@ foreign_type! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RsaRef {
|
impl RsaRef {
|
||||||
|
// FIXME these need to specify output format
|
||||||
private_key_to_pem!(ffi::PEM_write_bio_RSAPrivateKey);
|
private_key_to_pem!(ffi::PEM_write_bio_RSAPrivateKey);
|
||||||
public_key_to_pem!(ffi::PEM_write_bio_RSA_PUBKEY);
|
public_key_to_pem!(ffi::PEM_write_bio_RSA_PUBKEY);
|
||||||
|
|
||||||
private_key_to_der!(ffi::i2d_RSAPrivateKey);
|
private_key_to_der!(ffi::i2d_RSAPrivateKey);
|
||||||
public_key_to_der!(ffi::i2d_RSA_PUBKEY);
|
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
|
// FIXME should return u32
|
||||||
pub fn size(&self) -> usize {
|
pub fn size(&self) -> usize {
|
||||||
unsafe {
|
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_pem!(Rsa, ffi::PEM_read_bio_RSAPrivateKey);
|
||||||
private_key_from_der!(Rsa, ffi::d2i_RSAPrivateKey);
|
private_key_from_der!(Rsa, ffi::d2i_RSAPrivateKey);
|
||||||
public_key_from_pem!(Rsa, ffi::PEM_read_bio_RSA_PUBKEY);
|
public_key_from_pem!(Rsa, ffi::PEM_read_bio_RSA_PUBKEY);
|
||||||
public_key_from_der!(Rsa, ffi::d2i_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")]
|
#[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>
|
pub fn private_key_from_pem_cb<F>(buf: &[u8], pass_cb: F) -> Result<Rsa, ErrorStack>
|
||||||
where F: FnOnce(&mut [c_char]) -> usize
|
where F: FnOnce(&mut [c_char]) -> usize
|
||||||
|
|
@ -440,5 +448,4 @@ mod test {
|
||||||
let len = k1.private_decrypt(&emesg, &mut dmesg, PKCS1_PADDING).unwrap();
|
let len = k1.private_decrypt(&emesg, &mut dmesg, PKCS1_PADDING).unwrap();
|
||||||
assert_eq!(msg, &dmesg[..len]);
|
assert_eq!(msg, &dmesg[..len]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue