wbond / asn1crypto

Python ASN.1 library with a focus on performance and a pythonic API
MIT License
335 stars 140 forks source link

Constructed wrapper how to? #209

Closed amolofeev closed 3 years ago

amolofeev commented 3 years ago

Hi there!

I'm trying to parse file where part of asn1 structure is https://tools.ietf.org/rfc/rfc3126

   CrlOcspRef ::= SEQUENCE {
       crlids           [0] CRLListID        OPTIONAL,
       ocspids          [1] OcspListID       OPTIONAL,
       otherRev         [2] OtherRevRefs     OPTIONAL
   }

And after couple days of brainstorming i can't figure out how to wrap [0...3] constructable tag over CRLListID/OcspListID/etc... In my case [0..3] can be 0x0, 0x1, 0x2 tag ID.

this is part of data 30 82 01 EB A1 82 01 D6 30 82 01 D2

and tree looks like

SEQUENCE (2 elem)
     [1] (1 elem)
          SEQUENCE (10 elem)

Many thanks,

joernheissler commented 3 years ago

Hello!

Could you try attached code? And could you supply a complete file? How is it generated?

rfc3126.py.txt

amolofeev commented 3 years ago

Hi!

Originally my sources were quite equal your attached file. However, structure in file i have don't fit as expected. Signatures i'm working with specified as CAdES X Long Type 1 and CAdES-T generated by Russian GOST crypto tools. Sorry, i'm able to provide only small part of original file 1.2.840.113549.1.9.16.2.22