Struct ed25519_dalek::pkcs8::spki::der::Document
pub struct Document { /* private fields */ }
pkcs8
only.Expand description
ASN.1 DER-encoded document.
This type wraps an encoded ASN.1 DER message. The document checked to
ensure it contains a valid DER-encoded SEQUENCE
.
It implements common functionality related to encoding/decoding such documents, such as PEM encapsulation as well as reading/writing documents from/to the filesystem.
The SecretDocument
provides a wrapper for this type with additional
hardening applied.
Implementations§
§impl Document
impl Document
pub fn into_secret(self) -> SecretDocument
Available on crate feature zeroize
only.
pub fn into_secret(self) -> SecretDocument
zeroize
only.Convert to a SecretDocument
.
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 contained in this
Document
as the given type.
pub fn encode_msg<T>(msg: &T) -> Result<Document, Error>where
T: Encode,
pub fn encode_msg<T>(msg: &T) -> Result<Document, Error>where
T: Encode,
Encode the provided type as ASN.1 DER, storing the resulting encoded DER
as a Document
.
pub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
Available on crate feature pem
only.
pub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
pem
only.Decode ASN.1 DER document from PEM.
Returns the PEM label and decoded Document
on success.
pub fn to_pem(
&self,
label: &'static str,
line_ending: LineEnding
) -> Result<String, Error>
Available on crate feature pem
only.
pub fn to_pem( &self, label: &'static str, line_ending: LineEnding ) -> Result<String, Error>
pem
only.Encode ASN.1 DER document as a PEM string with encapsulation boundaries
containing the provided PEM type label
(e.g. CERTIFICATE
).
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Document, Error>
Available on crate feature std
only.
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Document, 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, Document), Error>
Available on crate features pem
and std
only.
pub fn read_pem_file( path: impl AsRef<Path> ) -> Result<(String, Document), 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 Encode for Document
impl Encode for Document
§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Writer
.§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>
§impl From<Document> for SecretDocument
Available on crate feature zeroize
only.
impl From<Document> for SecretDocument
zeroize
only.§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
§impl<'a, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
Available on crate feature alloc
only.
impl<'a, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
alloc
only.§impl<'a, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
Available on crate feature alloc
only.
impl<'a, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
alloc
only.impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
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
§impl<'a, T> Choice<'a> for T
impl<'a, T> Choice<'a> for T
§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Tag
decodable as a variant of this CHOICE
?§impl<T> DecodePublicKey for T
impl<T> DecodePublicKey for T
§fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
SubjectPublicKeyInfo
]
(binary format).§fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
pem
only.SubjectPublicKeyInfo
]. Read more