Struct Document
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§
§impl Document
impl Document
pub fn into_secret(self) -> SecretDocument
pub fn into_secret(self) -> SecretDocument
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.
pub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
pub fn from_pem(pem: &str) -> Result<(&str, Document), Error>
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>
pub fn to_pem( &self, label: &'static str, line_ending: LineEnding, ) -> Result<String, Error>
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>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Document, Error>
Read ASN.1 DER document from a file.
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn write_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write 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>
§fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, Error>
fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, Error>
Source§impl<'a: 'k, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
Available on crate feature alloc only.
impl<'a: 'k, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Document
alloc only.Source§impl<'a: 'k, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
Available on crate feature alloc only.
impl<'a: 'k, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Document
alloc only.impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin 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 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
Tag] decodable as a variant of this CHOICE?Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodePublicKey for T
impl<T> DecodePublicKey for T
Source§fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
SubjectPublicKeyInfo
(binary format).Source§fn from_public_key_pem(s: &str) -> Result<Self>
fn from_public_key_pem(s: &str) -> Result<Self>
SubjectPublicKeyInfo. Read more