Commit 7427dd72 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #654 from sfackler/pkey-private-key-from-der

Add PKey::private_key_from_der
parents 223e8e36 575e682d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+7 −0
Original line number Diff line number Diff line
@@ -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");

openssl/test/key.der

0 → 100644
+1.17 KiB

File added.

No diff preview for this file type.