pub struct PrivateKeyDocument(/* private fields */);
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.

Trait Implementations§

source§

impl AsRef<[u8]> for PrivateKeyDocument

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for PrivateKeyDocument

source§

fn clone(&self) -> PrivateKeyDocument

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PrivateKeyDocument

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DecodePrivateKey for PrivateKeyDocument

source§

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

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

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

Deserialize PKCS#8-encoded private key from PEM. Read more
source§

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

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

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

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

fn from_pkcs8_doc(doc: &PrivateKeyDocument) -> Result<Self>

Deserialize PKCS#8 private key from a PrivateKeyDocument.
source§

impl<'a> Document<'a> for PrivateKeyDocument

§

type Message = PrivateKeyInfo<'a>

ASN.1 message type this document decodes to.
source§

const SENSITIVE: bool = true

Does this type contain potentially sensitive data? Read more
source§

fn as_der(&self) -> &[u8]

Borrow the inner serialized bytes of this document.
source§

fn to_der(&self) -> Box<[u8]>

Return an allocated ASN.1 DER serialization as a boxed slice.
source§

fn decode(&'a self) -> Self::Message

Decode this document as ASN.1 DER.
source§

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

Create a new document from the provided ASN.1 DER bytes.
source§

fn from_msg(msg: &Self::Message) -> Result<Self, Error>

Encode the provided type as ASN.1 DER.
source§

fn from_pem(s: &str) -> Result<Self, Error>
where Self: PemLabel,

Decode ASN.1 DER document from PEM.
source§

fn to_pem(&self, line_ending: LineEnding) -> Result<String, Error>
where Self: PemLabel,

Encode ASN.1 DER document as a PEM string.
source§

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

Read ASN.1 DER document from a file.
source§

fn read_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>
where Self: PemLabel,

Read PEM-encoded ASN.1 DER document from a file.
source§

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

Write ASN.1 DER document to a file.
source§

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.
source§

impl EncodePrivateKey for PrivateKeyDocument

source§

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

Serialize a PrivateKeyDocument containing a PKCS#8-encoded private key.
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 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
source§

impl FromStr for PrivateKeyDocument

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
source§

impl PemLabel for PrivateKeyDocument

source§

const TYPE_LABEL: &'static str = "PRIVATE KEY"

Expected PEM type label for a given document, e.g. "PRIVATE KEY"
source§

impl TryFrom<&[u8]> for PrivateKeyDocument

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(bytes: &[u8]) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<&PrivateKeyInfo<'_>> for PrivateKeyDocument

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(private_key_info: &PrivateKeyInfo<'_>) -> Result<PrivateKeyDocument>

Performs the conversion.
source§

impl TryFrom<PrivateKeyInfo<'_>> for PrivateKeyDocument

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(private_key_info: PrivateKeyInfo<'_>) -> Result<PrivateKeyDocument>

Performs the conversion.
source§

impl TryFrom<Vec<u8>> for PrivateKeyDocument

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(bytes: Vec<u8>) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.