kimgr / asn1ate

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

Default value output as variable #26

Closed viraptor closed 8 years ago

viraptor commented 8 years ago

When parsing rfc3281, the following fragment:

             Clearance  ::=  SEQUENCE {                                          
                   policyId       [0] OBJECT IDENTIFIER,                         
                   classList      [1] ClassList DEFAULT {unclassified},                                                                                                                                                                                                        
                   securityCategories                                            
                                  [2] SET OF SecurityCategory  OPTIONAL          
             }                                                                   

             ClassList  ::=  BIT STRING {                                        
                   unmarked       (0),                                           
                   unclassified   (1),                                           
                   restricted     (2),                                           
                   confidential   (3),                                           
                   secret         (4),                                           
                   topSecret      (5)                                            
             }

results in the following line

    namedtype.DefaultedNamedType('classList', ClassList().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(value={unclassified})),                                                                                                            

With unclassified being used as a variable rather than string / ClassList value.

kimgr commented 8 years ago

Thanks, I think this is similar to #24. Handling of default values seems to be pretty poor overall, I missed a lot of details in the spec when I added them.

I'll try to take a look at this at some point, but I'm a little swamped at the moment, and it might be a while till I get to it.

kimgr commented 8 years ago

Closing this as a duplicate of #24, and adding a comment there to capture this case.