pub struct Document { /* private fields */ }
Available on crate features
pkcs8
and alloc
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 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 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
.
Trait Implementations§
§impl Encode for Document
impl Encode for Document
§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this value in bytes when encoded as ASN.1 DER.
§fn encode(&self, writer: &mut dyn Writer) -> Result<(), Error>
fn encode(&self, writer: &mut dyn Writer) -> Result<(), Error>
Encode this value as ASN.1 DER using the provided [
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>
Encode this value to the provided byte slice, returning a sub-slice
containing the encoded message.
§impl From<Document> for SecretDocument
Available on crate feature zeroize
only.
impl From<Document> for SecretDocument
Available on crate feature
zeroize
only.§fn from(doc: Document) -> SecretDocument
fn from(doc: Document) -> SecretDocument
Converts to this type from the input type.
impl Eq for Document
impl StructuralEq 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§
§impl<'a, T> Choice<'a> for Twhere
T: Decode<'a> + FixedTag,
impl<'a, T> Choice<'a> for Twhere
T: Decode<'a> + FixedTag,
§fn can_decode(tag: Tag) -> bool
fn can_decode(tag: Tag) -> bool
Is the provided [
Tag
] decodable as a variant of this CHOICE
?