Struct pkcs8::SecretDocument
source · [−]pub struct SecretDocument(_);
Expand description
Secret Document
type.
Useful for formats which represent potentially secret data, such as cryptographic keys.
This type provides additional hardening such as ensuring that the contents are zeroized-on-drop, and also using more restrictive file permissions when writing files to disk.
Implementations
sourceimpl SecretDocument
impl SecretDocument
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Borrow the inner serialized bytes of this document.
sourcepub fn to_bytes(&self) -> Zeroizing<Vec<u8, Global>>
pub fn to_bytes(&self) -> Zeroizing<Vec<u8, Global>>
Return an allocated ASN.1 DER serialization as a byte vector.
sourcepub fn decode_msg<'a, T>(&'a self) -> Result<T, Error> where
T: Decode<'a>,
pub fn decode_msg<'a, T>(&'a self) -> Result<T, Error> where
T: Decode<'a>,
Try to decode the inner ASN.1 DER message as the given type.
sourcepub fn encode_msg<T>(msg: &T) -> Result<SecretDocument, Error> where
T: Encode,
pub fn encode_msg<T>(msg: &T) -> Result<SecretDocument, Error> where
T: Encode,
Encode the provided type as ASN.1 DER.
sourcepub fn from_pem(pem: &str) -> Result<(&str, SecretDocument), Error>
pub fn from_pem(pem: &str) -> Result<(&str, SecretDocument), Error>
Decode ASN.1 DER document from PEM.
sourcepub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<Zeroizing<String>, Error>
pub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<Zeroizing<String>, Error>
Encode ASN.1 DER document as a PEM string.
sourcepub fn read_der_file(path: impl AsRef<Path>) -> Result<SecretDocument, Error>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<SecretDocument, Error>
Read ASN.1 DER document from a file.
sourcepub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER document to a file.
sourcepub fn read_pem_file(
path: impl AsRef<Path>
) -> Result<(String, SecretDocument), Error>
pub fn read_pem_file(
path: impl AsRef<Path>
) -> Result<(String, SecretDocument), Error>
Read PEM-encoded ASN.1 DER document from a file.
sourcepub fn write_pem_file(
&self,
path: impl AsRef<Path>,
label: &'static str,
line_ending: LineEnding
) -> Result<(), Error>
pub fn write_pem_file(
&self,
path: impl AsRef<Path>,
label: &'static str,
line_ending: LineEnding
) -> Result<(), Error>
Write PEM-encoded ASN.1 DER document to a file.
Trait Implementations
sourceimpl Clone for SecretDocument
impl Clone for SecretDocument
sourcefn clone(&self) -> SecretDocument
fn clone(&self) -> SecretDocument
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SecretDocument
impl Debug for SecretDocument
sourceimpl Drop for SecretDocument
impl Drop for SecretDocument
sourceimpl From<Document> for SecretDocument
impl From<Document> for SecretDocument
sourcefn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Converts to this type from the input type.
sourceimpl TryFrom<&'_ EncryptedPrivateKeyInfo<'_>> for SecretDocument
Available on crate features alloc
and pkcs5
only.
impl TryFrom<&'_ EncryptedPrivateKeyInfo<'_>> for SecretDocument
alloc
and pkcs5
only.sourcefn try_from(
encrypted_private_key: &EncryptedPrivateKeyInfo<'_>
) -> Result<SecretDocument>
fn try_from(
encrypted_private_key: &EncryptedPrivateKeyInfo<'_>
) -> Result<SecretDocument>
Performs the conversion.
sourceimpl TryFrom<&'_ PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature alloc
only.
impl TryFrom<&'_ PrivateKeyInfo<'_>> for SecretDocument
alloc
only.sourcefn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument>
fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument>
Performs the conversion.
sourceimpl TryFrom<EncryptedPrivateKeyInfo<'_>> for SecretDocument
Available on crate features alloc
and pkcs5
only.
impl TryFrom<EncryptedPrivateKeyInfo<'_>> for SecretDocument
alloc
and pkcs5
only.sourcefn try_from(
encrypted_private_key: EncryptedPrivateKeyInfo<'_>
) -> Result<SecretDocument>
fn try_from(
encrypted_private_key: EncryptedPrivateKeyInfo<'_>
) -> Result<SecretDocument>
Performs the conversion.
sourceimpl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature alloc
only.
impl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
alloc
only.sourcefn try_from(private_key: PrivateKeyInfo<'_>) -> Result<SecretDocument>
fn try_from(private_key: PrivateKeyInfo<'_>) -> Result<SecretDocument>
Performs the conversion.
impl ZeroizeOnDrop for SecretDocument
Auto Trait Implementations
impl RefUnwindSafe for SecretDocument
impl Send for SecretDocument
impl Sync for SecretDocument
impl Unpin for SecretDocument
impl UnwindSafe for SecretDocument
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more