pub struct SecretDocument(/* private fields */);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§
Source§impl SecretDocument
impl SecretDocument
Sourcepub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
pub fn to_bytes(&self) -> Zeroizing<Vec<u8>>
Return an allocated ASN.1 DER serialization as a byte vector.
Sourcepub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T, T::Error>
pub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T, T::Error>
Try to decode the inner ASN.1 DER message as the given type.
§Errors
Returns T::Error if a decoding error occurred.
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>
Sourcepub fn read_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Self, Error>
Read ASN.1 DER document from a file.
§Errors
If file could not be read, or a decoding error occurred.
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.
§Errors
If file could not be written, or an encoding error occurred.
Sourcepub fn read_pem_file(path: impl AsRef<Path>) -> Result<(String, Self), Error>
pub fn read_pem_file(path: impl AsRef<Path>) -> Result<(String, Self), Error>
Read PEM-encoded ASN.1 DER document from a file.
§Errors
If file could not be read, or a decoding error occurred.
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.
§Errors
If file could not be written, or an encoding error occurred.
Trait Implementations§
Source§impl Clone for SecretDocument
impl Clone for SecretDocument
Source§fn clone(&self) -> SecretDocument
fn clone(&self) -> SecretDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecretDocument
Available on crate feature zeroize only.
impl Debug for SecretDocument
zeroize only.Source§impl Drop for SecretDocument
Available on crate feature zeroize only.
impl Drop for SecretDocument
zeroize only.Source§impl From<Document> for SecretDocument
Available on crate feature zeroize only.
impl From<Document> for SecretDocument
zeroize only.Source§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Source§impl TryFrom<&[u8]> for SecretDocument
Available on crate feature zeroize only.
impl TryFrom<&[u8]> for SecretDocument
zeroize only.impl ZeroizeOnDrop for SecretDocument
zeroize only.