Title: DER decoding extensions in SEQUENCE

Hi,

I have written a simple Asn1 library that is used for managing Asn1 structures and coding/decoding them. Lot of things should be done still and one of them is handling extensions. This seems to me as a great obstacle, so I decided to ask here.

Please let me outline the problem I see in (DER) decoding of SEQUENCE:

My application knows the structure of SEQUENCE including optional elemets and the "position" of possible extensions. See the example:

CommonCertificateAttributes ::= SEQUENCE {
        iD Identifier,
        authority               BOOLEAN DEFAULT FALSE,
        identifier              CredentialIdentifier {{KeyIdentifiers}} OPTIONAL,
        certHash                [0] OOBCertHash OPTIONAL,
        ...,
        trustedUsage    [1] Usage OPTIONAL,
        identifiers     [2] SEQUENCE OF CredentialIdentifier{{KeyIdentifiers}} OPTIONAL,
        implicitTrust   [3] BOOLEAN DEFAULT FALSE
        }

The aplication decodes the elements sequntialy. First step of decoding is to check the Tag. If a mandatory element is awaited, then the Tag must correspond, otherwise an error is reported.

If an optional element is awaited, then the Tag doesn't have to correspond (since the element doesn't have to be present). If it so, the application just shifts to the next possible element. If the tag corresponds, the optional element is decoded.

Now the application knows that extensions can be present in the following code. But it doesn't know the possible tag (or tags). If the first element after the extensions is to be mandatory, then the application could look for it's tag and could skip (or save) all preceeding elements as extensions.

But as in the example, there can be optional elements following the extension and thus the application would have to consider all possible (all optional and first mandatory) following tags.

And if there is not a mandatory element anywhere in the SEQUENCE after the extension (as in the example), the application would even have to consider all possible tags following the sequence.

Finaly, if another extension would be present in these following possible elements, than it is not feasible to collect all the possible folowing tags.

I hope you understand my chaotic explanation :-)

My questions is, if I am right about considering all the following tags and if yes, how to resolve the unambiguity with more extensions with optional elements between them.

Regards
Vit Novak

Reply via email to