Add PKey::private_key_from_der
This commit is contained in:
parent
223e8e3689
commit
575e682da3
|
|
@ -2412,6 +2412,7 @@ extern "C" {
|
|||
pub fn i2d_X509_REQ_bio(b: *mut BIO, x: *mut X509_REQ) -> c_int;
|
||||
pub fn i2d_X509_REQ(x: *mut X509_REQ, buf: *mut *mut u8) -> c_int;
|
||||
|
||||
pub fn d2i_AutoPrivateKey(a: *mut *mut EVP_PKEY, pp: *mut *const c_uchar, length: c_long) -> *mut EVP_PKEY;
|
||||
pub fn d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY;
|
||||
pub fn i2d_PUBKEY_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int;
|
||||
pub fn i2d_PrivateKey_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ impl PKey {
|
|||
private_key_from_pem!(PKey, ffi::PEM_read_bio_PrivateKey);
|
||||
public_key_from_pem!(PKey, ffi::PEM_read_bio_PUBKEY);
|
||||
public_key_from_der!(PKey, ffi::d2i_PUBKEY);
|
||||
private_key_from_der!(PKey, ffi::d2i_AutoPrivateKey);
|
||||
|
||||
/// Deserializes a DER-formatted PKCS#8 private key, using a callback to retrieve the password
|
||||
/// if the key is encrpyted.
|
||||
|
|
@ -317,6 +318,12 @@ mod tests {
|
|||
PKey::public_key_from_der(key).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_private_key_from_der() {
|
||||
let key = include_bytes!("../test/key.der");
|
||||
PKey::private_key_from_der(key).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pem() {
|
||||
let key = include_bytes!("../test/key.pem");
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue