kimgr / asn1ate

A Python library for translating ASN.1 into other forms.
Other
69 stars 41 forks source link

Default and Empty value management #32

Closed Mourhamo closed 8 years ago

Mourhamo commented 8 years ago

Hi guys,

In new in the ASN1 parsing

I was trying to parse an example of ASN1 Definition. It the New Sim ASN1 definition. I found it at SIMAlliance. This parsing raise some exception on the original file.

What they call PE-Dummy at line 60 is an Empty element, that seems to not being accepted by asn1ate :(

PE-Dummy ::= SEQUENCE {
}

And at the line 574 an other element called PE-AKAParameter, the asn1ate reject it because of the DEFAULT definition :

PE-AKAParameter ::= SEQUENCE {
aka-header PEHeader,
algoConfiguration CHOICE {
    mappingParameter    MappingParameter,
    algoParameter   AlgoParameter
},

sqnOptions      OCTET STRING (SIZE(1)) DEFAULT '02'H,
sqnDelta        OCTET STRING (SIZE(6)) DEFAULT '000010000000'H,
sqnAgeLimit     OCTET STRING (SIZE(6)) DEFAULT '000010000000'H,

-- Sequence numbers do not include the index (IND)
sqnInit SEQUENCE (SIZE (32)) OF OCTET STRING (SIZE (6)) DEFAULT {
        /* Index 0  */'000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H,'000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H,'000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H,'000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H, '000000000000'H,'000000000000'H, '000000000000'H, '000000000000'H,
        /* Index 31 */'000000000000'H }
}

PEDefinitions V2.0.txt

I am not a ASN1 expert is this ASN1 elements well written. is this case not implemented in ASN1ATE.

is this the Definition of DEFAULT values for a sequence?

results in the following line:

pyparsing.ParseException: Expected "END" (at char 1766), (line:60, col:23)

and

pyparsing.ParseException: Expected "END" (at char 16038), (line:574, col:30)
kimgr commented 8 years ago

(I formatted your examples to make them easier to read).

I think you have two issues here, I broke the first one (empty SEQUENCE) out into #34.

The other is a clean duplicate of #24 -- the parser currently doesn't support braced lists for DEFAULT values.

I don't have much time to work on asn1ate these days, but it looks like this is an issue many people run into, so hopefully there's a solution out there somewhere :-)

Closing this as duplicate of #24 and now #34.