pub struct Document { /* private fields */ }
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§
source§impl Document
impl Document
sourcepub fn into_secret(self) -> SecretDocument
Available on crate feature zeroize
only.
pub fn into_secret(self) -> SecretDocument
zeroize
only.Convert to a SecretDocument
.
sourcepub 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.
sourcepub 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
.
sourcepub 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.
sourcepub 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
).
sourcepub 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.
sourcepub 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.
sourcepub 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.
sourcepub 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§
source§impl Encode for Document
impl Encode for Document
source§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Writer
.source§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>
source§impl PartialEq for Document
impl PartialEq for Document
source§impl<'a: 'k, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Documentwhere
Params: Choice<'a> + Encode,
Key: Decode<'a> + Encode + FixedTag + 'k,
BitStringRef<'a>: From<&'k Key>,
impl<'a: 'k, 'k, Params, Key> TryFrom<&SubjectPublicKeyInfo<Params, Key>> for Documentwhere Params: Choice<'a> + Encode, Key: Decode<'a> + Encode + FixedTag + 'k, BitStringRef<'a>: From<&'k Key>,
source§impl<'a: 'k, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Documentwhere
Params: Choice<'a> + Encode,
Key: Decode<'a> + Encode + FixedTag + 'k,
BitStringRef<'a>: From<&'k Key>,
impl<'a: 'k, 'k, Params, Key> TryFrom<SubjectPublicKeyInfo<Params, Key>> for Documentwhere Params: Choice<'a> + Encode, Key: Decode<'a> + Encode + FixedTag + 'k, BitStringRef<'a>: From<&'k Key>,
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§
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
source§impl<T> DecodePublicKey for Twhere
T: for<'a> TryFrom<SubjectPublicKeyInfo<AnyRef<'a>, BitStringRef<'a>>, Error = Error>,
impl<T> DecodePublicKey for Twhere T: for<'a> TryFrom<SubjectPublicKeyInfo<AnyRef<'a>, BitStringRef<'a>>, Error = Error>,
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>
pem
only.SubjectPublicKeyInfo
. Read more