pub struct Reader<'a> { /* private fields */ }Expand description
A cursor over a DER input that yields borrowed value contents.
The reader is checked: every method validates the tag, the length, and the available input before returning, so it never panics on malformed data.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
Sourcepub fn peek_tag(&self) -> Result<u8, DerError>
pub fn peek_tag(&self) -> Result<u8, DerError>
Returns the tag of the next value without consuming it.
Returns DerError::Truncated when no value remains.
Sourcepub fn read_tlv(&mut self) -> Result<(u8, &'a [u8]), DerError>
pub fn read_tlv(&mut self) -> Result<(u8, &'a [u8]), DerError>
Reads one tag-length-value, returning its tag and content.
Returns DerError when the value is truncated, uses an indefinite or
non-minimal length, or has a high-tag-number form.
Sourcepub fn read_expected(&mut self, tag: u8) -> Result<&'a [u8], DerError>
pub fn read_expected(&mut self, tag: u8) -> Result<&'a [u8], DerError>
Reads one value and requires it to have tag, returning its content.
Sourcepub fn read_sequence(&mut self) -> Result<Reader<'a>, DerError>
pub fn read_sequence(&mut self) -> Result<Reader<'a>, DerError>
Reads a SEQUENCE and returns a reader over its content.
Sourcepub fn read_integer(&mut self) -> Result<&'a [u8], DerError>
pub fn read_integer(&mut self) -> Result<&'a [u8], DerError>
Reads an INTEGER, returning its canonical content bytes.
The content may start with a single 0x00 when required to keep the
sign bit clear. Empty or non-minimal encodings are rejected.
Sourcepub fn read_octet_string(&mut self) -> Result<&'a [u8], DerError>
pub fn read_octet_string(&mut self) -> Result<&'a [u8], DerError>
Reads an OCTET STRING, returning its content bytes.
Sourcepub fn read_bit_string(&mut self) -> Result<&'a [u8], DerError>
pub fn read_bit_string(&mut self) -> Result<&'a [u8], DerError>
Reads a BIT STRING, returning its bytes with the unused-bits count
byte removed.
Returns DerError::Unsupported when the value declares unused bits
(only byte-aligned bit strings are supported).
Sourcepub fn read_oid(&mut self) -> Result<&'a [u8], DerError>
pub fn read_oid(&mut self) -> Result<&'a [u8], DerError>
Reads an OBJECT IDENTIFIER, returning its content bytes (without the
leading tag/length). Compare against known OID byte strings.