Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

Pkcs8DecodePrivateKey

Trait Pkcs8DecodePrivateKey 

Source
pub trait Pkcs8DecodePrivateKey: Sized {
    // Required method
    fn from_pkcs8_der(bytes: &[u8]) -> Result<Self, Error>;

    // Provided methods
    fn from_pkcs8_encrypted_der(
        bytes: &[u8],
        password: impl AsRef<[u8]>,
    ) -> Result<Self, Error> { ... }
    fn from_pkcs8_pem(s: &str) -> Result<Self, Error> { ... }
    fn from_pkcs8_encrypted_pem(
        s: &str,
        password: impl AsRef<[u8]>,
    ) -> Result<Self, Error> { ... }
    fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error> { ... }
    fn read_pkcs8_pem_file(path: impl AsRef<Path>) -> Result<Self, Error> { ... }
}
Expand description

Parse a private key object from a PKCS#8 encoded document.

Required Methods§

Source

fn from_pkcs8_der(bytes: &[u8]) -> Result<Self, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).

§Errors

Returns format-specific errors in the event the document failed to parse.

Provided Methods§

Source

fn from_pkcs8_encrypted_der( bytes: &[u8], password: impl AsRef<[u8]>, ) -> Result<Self, Error>

Deserialize encrypted PKCS#8 private key from ASN.1 DER-encoded data (binary format) and attempt to decrypt it using the provided password.

§Errors
  • Returns errors if the DER failed to decode
  • Returns errors if the ciphertext failed to decrypt under the given password
Source

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#8-encoded private key from PEM.

Keys in this format begin with the following delimiter:

-----BEGIN PRIVATE KEY-----
§Errors
Source

fn from_pkcs8_encrypted_pem( s: &str, password: impl AsRef<[u8]>, ) -> Result<Self, Error>

Deserialize encrypted PKCS#8-encoded private key from PEM and attempt to decrypt it using the provided password.

Keys in this format begin with the following delimiter:

-----BEGIN ENCRYPTED PRIVATE KEY-----
§Errors
Source

fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from an ASN.1 DER-encoded file (binary format) on the local filesystem.

§Errors
Source

fn read_pkcs8_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Load PKCS#8 private key from a PEM-encoded file on the local filesystem.

§Errors

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§