pub struct Document { /* private fields */ }
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§
source§impl Document
impl Document
sourcepub fn into_secret(self) -> SecretDocument
pub fn into_secret(self) -> SecretDocument
Convert to a SecretDocument
.
sourcepub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T>
pub fn decode_msg<'a, T: Decode<'a>>(&'a self) -> Result<T>
Try to decode the inner ASN.1 DER message contained in this
Document
as the given type.
sourcepub fn encode_msg<T: Encode>(msg: &T) -> Result<Self>
pub fn encode_msg<T: Encode>(msg: &T) -> Result<Self>
Encode the provided type as ASN.1 DER, storing the resulting encoded DER
as a Document
.
sourcepub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
Read ASN.1 DER document from a file.
Trait Implementations§
source§impl Encode for Document
impl Encode for Document
source§fn encoded_len(&self) -> Result<Length>
fn encoded_len(&self) -> Result<Length>
Compute the length of this value in bytes when encoded as ASN.1 DER.
source§fn encode(&self, writer: &mut dyn Writer) -> Result<()>
fn encode(&self, writer: &mut dyn Writer) -> Result<()>
Encode this value as ASN.1 DER using the provided
Writer
.source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Encode this value to the provided byte slice, returning a sub-slice
containing the encoded message. Read more
source§impl From<Document> for SecretDocument
impl From<Document> for SecretDocument
source§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Converts to this type from the input type.