rocket::mtls::x509::der_parser::ber

Function ber_read_element_content_as

Source
pub fn ber_read_element_content_as(
    i: &[u8],
    tag: Tag,
    length: Length,
    constructed: bool,
    max_depth: usize,
) -> Result<(&[u8], BerObjectContent<'_>), Err<Error>>
Available on crate feature mtls only.
Expand description

Parse the next bytes as the content of a BER object.

Content type is not checked to match tag, caller is responsible of providing the correct tag

This function is mostly used when parsing implicit tagged objects, when reading primitive types.

max_depth is the maximum allowed recursion for objects.

ยงExample

let (i, hdr) = ber_read_element_header(bytes).expect("could not read header");
let (_, content) = ber_read_element_content_as(
    i, hdr.tag(), hdr.length(), hdr.is_constructed(), 5
).expect("parsing failed");