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

EncodePrivateKey

Trait EncodePrivateKey 

Source
pub trait EncodePrivateKey {
    // Required method
    fn to_pkcs8_der(&self) -> Result<SecretDocument>;

    // Provided methods
    fn to_pkcs8_encrypted_der(
        &self,
        rng: impl CryptoRng + RngCore,
        password: impl AsRef<[u8]>,
    ) -> Result<SecretDocument> { ... }
    fn to_pkcs8_pem(&self, line_ending: LineEnding) -> Result<Zeroizing<String>> { ... }
    fn to_pkcs8_encrypted_pem(
        &self,
        rng: impl CryptoRng + RngCore,
        password: impl AsRef<[u8]>,
        line_ending: LineEnding,
    ) -> Result<Zeroizing<String>> { ... }
    fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<()> { ... }
    fn write_pkcs8_pem_file(
        &self,
        path: impl AsRef<Path>,
        line_ending: LineEnding,
    ) -> Result<()> { ... }
}
Expand description

Serialize a private key object to a PKCS#8 encoded document.

Required Methods§

Source

fn to_pkcs8_der(&self) -> Result<SecretDocument>

Serialize a SecretDocument containing a PKCS#8-encoded private key.

Provided Methods§

Source

fn to_pkcs8_encrypted_der( &self, rng: impl CryptoRng + RngCore, password: impl AsRef<[u8]>, ) -> Result<SecretDocument>

Create an SecretDocument containing the ciphertext of a PKCS#8 encoded private key encrypted under the given password.

Source

fn to_pkcs8_pem(&self, line_ending: LineEnding) -> Result<Zeroizing<String>>

Serialize this private key as PEM-encoded PKCS#8 with the given LineEnding.

Source

fn to_pkcs8_encrypted_pem( &self, rng: impl CryptoRng + RngCore, password: impl AsRef<[u8]>, line_ending: LineEnding, ) -> Result<Zeroizing<String>>

Serialize this private key as an encrypted PEM-encoded PKCS#8 private key using the provided to derive an encryption key.

Source

fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<()>

Write ASN.1 DER-encoded PKCS#8 private key to the given path

Source

fn write_pkcs8_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<()>

Write ASN.1 DER-encoded PKCS#8 private key to the given path

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§