Skip to content

APER decoder when decoding SEQUENCE after reading header is not byte-aligning if OCTET STRING is followed #506

@ErvinsK

Description

@ErvinsK

Simple ASN.1 definition:

BEGIN
    A ::= SEQUENCE {
	i			OCTET STRING (SIZE(3)),
	t			OCTET STRING (SIZE(2)),
	e			INTEGER OPTIONAL,
	...
}
END

Resulting in:

#[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct A {
    pub i: FixedOctetString<3>,
    pub t: FixedOctetString<2>,
    pub e: Option<Integer>,
}

APER encoder properly encodes the following SEQUENCE:

let original = A {
        i: FixedOctetString::from([0x19, 0xf0, 0x45]),
        t: FixedOctetString::from([0x00, 0x01]),
        e: None,
    };

Result is -> [0x00, 0x19, 0xf0, 0x45, 0x00, 0x01]

Howerver, APER decoder fails to properly decode -> after reading SEQUENCE header the input is not byte-aligned!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions