Struct pkcs8::PrivateKeyDocument [−][src]
pub struct PrivateKeyDocument(_);
alloc
only.Expand description
PKCS#8 private key document.
This type provides storage for PrivateKeyInfo
encoded as ASN.1 DER
with the invariant that the contained-document is “well-formed”, i.e. it
will parse successfully according to this crate’s parsing rules.
Implementations
pub fn encrypt(
&self,
rng: impl CryptoRng + RngCore,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
This is supported on crate feature encryption
only.
pub fn encrypt(
&self,
rng: impl CryptoRng + RngCore,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
encryption
only.Encrypt this private key using a symmetric encryption key derived from the provided password.
Uses the following algorithms for encryption:
- PBKDF: scrypt with default parameters:
- log₂(N): 15
- r: 8
- p: 1
- Cipher: AES-256-CBC (best available option for PKCS#5 encryption)
pub fn encrypt_with_params(
&self,
pbes2_params: Parameters<'_>,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
This is supported on crate feature encryption
only.
pub fn encrypt_with_params(
&self,
pbes2_params: Parameters<'_>,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
encryption
only.Encrypt this private key using a symmetric encryption key derived
from the provided password and pbes2::Parameters
.
Trait Implementations
Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format). Read more
pem
only.Deserialize PKCS#8-encoded private key from PEM. Read more
std
only.Load PKCS#8 private key from an ASN.1 DER-encoded file on the local filesystem (binary format). Read more
pem
and std
only.Load PKCS#8 private key from a PEM-encoded file on the local filesystem.
encryption
only.Deserialize encrypted PKCS#8 private key from ASN.1 DER-encoded data (binary format) and attempt to decrypt it using the provided password. Read more
alloc
only.Deserialize PKCS#8 private key from a PrivateKeyDocument
.
type Message = PrivateKeyInfo<'a>
type Message = PrivateKeyInfo<'a>
ASN.1 message type this document decodes to.
Borrow the inner serialized bytes of this document.
Return an allocated ASN.1 DER serialization as a boxed slice.
Create a new document from the provided ASN.1 DER bytes.
Decode ASN.1 DER document from PEM.
Encode ASN.1 DER document as a PEM string.
Read ASN.1 DER document from a file.
Read PEM-encoded ASN.1 DER document from a file.
Write ASN.1 DER document to a file.
fn write_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<(), Error> where
Self: PemLabel,
fn write_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding
) -> Result<(), Error> where
Self: PemLabel,
Write PEM-encoded ASN.1 DER document to a file.
alloc
only.Serialize a PrivateKeyDocument
containing a PKCS#8-encoded private key.
alloc
and pem
only.Serialize this private key as PEM-encoded PKCS#8 with the given LineEnding
.
alloc
and std
only.Write ASN.1 DER-encoded PKCS#8 private key to the given path
pem
and std
and alloc
only.Write ASN.1 DER-encoded PKCS#8 private key to the given path
fn to_pkcs8_encrypted_der(
&self,
rng: impl CryptoRng + RngCore,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
fn to_pkcs8_encrypted_der(
&self,
rng: impl CryptoRng + RngCore,
password: impl AsRef<[u8]>
) -> Result<EncryptedPrivateKeyDocument>
alloc
and encryption
only.Create an EncryptedPrivateKeyDocument
containing the ciphertext of
a PKCS#8 encoded private key encrypted under the given password
. Read more
encryption
and pem
and alloc
only.Serialize this private key as an encrypted PEM-encoded PKCS#8 private
key using the provided
to derive an encryption key. Read more
Expected PEM type label for a given document, e.g. "PRIVATE KEY"
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for PrivateKeyDocument
impl Send for PrivateKeyDocument
impl Sync for PrivateKeyDocument
impl Unpin for PrivateKeyDocument
impl UnwindSafe for PrivateKeyDocument
Blanket Implementations
Mutably borrows from an owned value. Read more