Struct ed25519_dalek::pkcs8::spki::der::SecretDocument
pub struct SecretDocument(/* private fields */);
Available on crate features
pkcs8
and zeroize
only.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§
§impl SecretDocument
impl SecretDocument
pub 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.
pub 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.
pub 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.
pub fn from_pem(pem: &str) -> Result<(&str, SecretDocument), Error>
Available on crate feature pem
only.
pub fn from_pem(pem: &str) -> Result<(&str, SecretDocument), Error>
pem
only.Decode ASN.1 DER document from PEM.
pub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<Zeroizing<String>, Error>
Available on crate feature pem
only.
pub fn to_pem( &self, label: &'static str, line_ending: LineEnding ) -> Result<Zeroizing<String>, Error>
pem
only.Encode ASN.1 DER document as a PEM string.
pub fn read_der_file(path: impl AsRef<Path>) -> Result<SecretDocument, Error>
Available on crate feature std
only.
pub fn read_der_file(path: impl AsRef<Path>) -> Result<SecretDocument, Error>
std
only.Read ASN.1 DER document from a file.
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Available on crate feature std
only.
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
std
only.Write ASN.1 DER document to a file.
pub fn read_pem_file(
path: impl AsRef<Path>
) -> Result<(String, SecretDocument), Error>
Available on crate features pem
and std
only.
pub fn read_pem_file( path: impl AsRef<Path> ) -> Result<(String, SecretDocument), Error>
pem
and std
only.Read PEM-encoded ASN.1 DER document from a file.
pub fn write_pem_file(
&self,
path: impl AsRef<Path>,
label: &'static str,
line_ending: LineEnding
) -> Result<(), Error>
Available on crate features pem
and std
only.
pub fn write_pem_file( &self, path: impl AsRef<Path>, label: &'static str, line_ending: LineEnding ) -> Result<(), Error>
pem
and std
only.Write PEM-encoded ASN.1 DER document to a file.
Trait Implementations§
§impl Clone for SecretDocument
impl Clone for SecretDocument
§fn clone(&self) -> SecretDocument
fn clone(&self) -> SecretDocument
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for SecretDocument
impl Debug for SecretDocument
§impl From<Document> for SecretDocument
impl From<Document> for SecretDocument
§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Converts to this type from the input type.
§impl TryFrom<&[u8]> for SecretDocument
impl TryFrom<&[u8]> for SecretDocument
§impl TryFrom<&PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature alloc
only.
impl TryFrom<&PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature
alloc
only.§fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
Performs the conversion.
§impl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature alloc
only.
impl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
Available on crate feature
alloc
only.§fn try_from(private_key: PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
fn try_from(private_key: PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
Performs the conversion.
§impl TryFrom<Vec<u8>> for SecretDocument
impl TryFrom<Vec<u8>> for SecretDocument
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> DecodePrivateKey for T
impl<T> DecodePrivateKey for T
§fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
Deserialize PKCS#8 private key from ASN.1 DER-encoded data
(binary format).
§fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
Available on crate feature
pem
only.Deserialize PKCS#8-encoded private key from PEM. Read more