You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some scenarios, I want to peek into a DER, parse an early element (think of an OID), and return it. It appears that I cannot do that with BERReader without reading the whole DER.
My best try was to ignore the remainder with the following
fn extract_oid(der: &[u8]) {
let oid = yasna::parse_der(der, |r| {
// Let's say we have a SEQUENCE
r.read_sequence(|r| {
// The OID I want is embedded inside an inner SEQUENCE:
let oid = r.next().read_sequence(|r| {
let oid = r.next().read_oid()?;
let _remainder = r.next().read_der(); // Ignore the remainder of that sequence
Ok(oid)
})?;
let _remainder = r.next().read_der(); // Ignore the rest of the sequence
Ok(oid)
})
});
println!("extracted OID {:?}", oid);
}
Without checking the remainder, yasna fails with Err(ASN1Error { kind: Extra }), and I would like to ignore this error.
The text was updated successfully, but these errors were encountered:
In some scenarios, I want to peek into a DER, parse an early element (think of an OID), and return it. It appears that I cannot do that with
BERReader
without reading the whole DER.My best try was to ignore the remainder with the following
Without checking the remainder,
yasna
fails withErr(ASN1Error { kind: Extra })
, and I would like to ignore this error.The text was updated successfully, but these errors were encountered: