P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
381 stars 132 forks source link

Question about ASN.1 size constraints on SEQUENCE OF #157

Closed russhousley closed 2 years ago

russhousley commented 2 years ago

I put this line in a module:

  Foos ::= SEQUENCE OF Foo (SIZE (0..4))

The compiler does not complain about the syntax, but the Obj that gets created by the compiler has:

   ..., '_const': [], ...

Am I correct that the size constraint is being ignored?

p1-bmu commented 2 years ago

When you write this Foos definition like this, I believe the size constraint applies to the Foo object, and not the SEQUENCE OF one.

russhousley commented 2 years ago

You are correct. The proper ASN.1 definition would be:

   Foos ::= SEQUENCE SIZE (0..4) OF Foo