pub struct DerReader<'a> { /* private fields */ }rustcrypto only.Expand description
A cursor over a sequence of DER elements.
Implementations§
Source§impl<'a> DerReader<'a>
impl<'a> DerReader<'a>
Sourcepub fn peek_tag(&self) -> Option<u8>
pub fn peek_tag(&self) -> Option<u8>
Returns the next element’s identifier octet without consuming it.
Sourcepub fn next_element(&mut self) -> Result<Element<'a>>
pub fn next_element(&mut self) -> Result<Element<'a>>
Reads the next element, whatever it is.
Sourcepub fn expect(&mut self, tag: u8) -> Result<Element<'a>>
pub fn expect(&mut self, tag: u8) -> Result<Element<'a>>
Reads the next element and requires it to have this identifier octet.
Sourcepub fn expect_sequence(&mut self) -> Result<Self>
pub fn expect_sequence(&mut self) -> Result<Self>
Reads a SEQUENCE and returns a reader over its members.
Sourcepub fn expect_set(&mut self) -> Result<Self>
pub fn expect_set(&mut self) -> Result<Self>
Reads a SET and returns a reader over its members.
Sourcepub fn expect_oid(&mut self, expected: &[u8]) -> Result<()>
pub fn expect_oid(&mut self, expected: &[u8]) -> Result<()>
Reads an OBJECT IDENTIFIER and requires it to be expected.
Sourcepub fn expect_unsigned(&mut self) -> Result<&'a [u8]>
pub fn expect_unsigned(&mut self) -> Result<&'a [u8]>
Reads a non-negative INTEGER and returns its magnitude with the sign octet removed.
DER’s INTEGER is two’s-complement and minimally encoded, which means a positive
value whose top bit is set carries a leading 0x00 so that it does not read as
negative. That octet is part of the encoding, not of the number, so a 256-bit scalar
arrives as 33 octets about half the time.
Both minimality rules are enforced: a leading 0x00 is legal only when the next
octet has its top bit set, and a leading 0x80-or-above is a negative number.
Sourcepub fn expect_uint(&mut self) -> Result<u64>
pub fn expect_uint(&mut self) -> Result<u64>
Reads a non-negative INTEGER that must fit in a u64.
Sourcepub fn take_if(&mut self, tag: u8) -> Result<Option<Element<'a>>>
pub fn take_if(&mut self, tag: u8) -> Result<Option<Element<'a>>>
Reads the next element only if it has this identifier octet.
This is how an OPTIONAL or a DEFAULT field is read: a look before the leap, since
what follows an absent field is the next field and consuming it would desynchronise
the parse.