rocket::mtls::x509::ber

Function parse_ber

Source
pub fn parse_ber(i: &[u8]) -> Result<(&[u8], BerObject<'_>), Err<Error>>
Available on crate feature mtls only.
Expand description

Parse BER object recursively

Return a tuple containing the remaining (unparsed) bytes and the BER Object, or an error.

Note: this is the same as calling parse_ber_recursive with MAX_RECURSION.

ยงExample

use der_parser::ber::{parse_ber, Tag};

let bytes = &[0x02, 0x03, 0x01, 0x00, 0x01];
let (_, obj) = parse_ber(bytes).expect("parsing failed");

assert_eq!(obj.header.tag(), Tag::Integer);