Struct ed25519::pkcs8::SecretDocument
pub struct SecretDocument(/* private fields */);
Available on crate features
alloc
and zeroize
and pkcs8
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 len(&self) -> Length
pub fn len(&self) -> Length
Get the length of the encoded ASN.1 DER in bytes.
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.
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
source§impl TryFrom<&PrivateKeyInfo<'_>> for SecretDocument
impl TryFrom<&PrivateKeyInfo<'_>> for SecretDocument
source§fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
fn try_from(private_key: &PrivateKeyInfo<'_>) -> Result<SecretDocument, Error>
Performs the conversion.
source§impl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
impl TryFrom<PrivateKeyInfo<'_>> for SecretDocument
source§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
source§impl<T> DecodePrivateKey for Twhere
T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,
impl<T> DecodePrivateKey for Twhere T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,
source§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).
source§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