Function yasna::parse_der

source ·
pub fn parse_der<'a, T, F>(buf: &'a [u8], callback: F) -> ASN1Result<T>where
    F: for<'b> FnOnce(BERReader<'a, 'b>) -> ASN1Result<T>,
Expand description

Parses DER-encoded data.

This function uses the loan pattern: callback is called back with a BERReader, from which the ASN.1 value is read.

If you want to parse BER-encoded data in general, use parse_ber.

Examples

use yasna;
let data = &[48, 6, 2, 1, 10, 1, 1, 255];
let asn = yasna::parse_der(data, |reader| {
    reader.read_sequence(|reader| {
        let i = reader.next().read_i64()?;
        let b = reader.next().read_bool()?;
        return Ok((i, b));
    })
}).unwrap();
println!("{:?} = [48, 6, 2, 1, 10, 1, 1, 255]", asn);