1

Using asn1 PER encoding, is there some way to encode data using only content bits i.e without tag and length information? I am trying to fit a legacy binary protocol onto an asn1 specification, and that would only be possible if there was an encoding that contains the content bits alone.

Ajoy
  • 525
  • 1
  • 9
  • 20

2 Answers2

2

Yes, PER is used at times in trying to retrofit ASN.1 to legacy protocols. There are a few things you need to be aware of when doing this. One is the difference between "ALIGNED" and "UNALIGNED" PER (sometimes referred to as octet-aligned and bit-aligned respectively). Creating your ASN.1 requires some knowledge about how PER works. In particular, if you have a field which has a fixed size, no length prefix is added. PER never sends "tags" across the line, but does use a "discriminator" for CHOICE types. For SEQUENCES with OPTIONAL or DEFAULT components, it adds a bitmask before the first component to indicate which optional components are present (one bit for each optional or default component with the bit set to 1 for present and 0 for absent).

A great way to test the ASN.1 specification you are creating against the legacy encoding is to try it for free at http://asn1-playground.oss.com, which is a free online ASN.1 compiler and encoder/decoder. You can easily see how changes to your ASN.1 affect the PER encodings.

Paul Thorpe
  • 1,930
  • 17
  • 23
1

In general, no: PER encodings include a preamble, length, and value contents. The preamble and length may be omitted, however, in cases where they can be derived from the specification. For this to happen, you musn't use OPTIONAL and DEFAULT elements, and you must generally use fixed-length values. Even following these guidelines, though, you'll probably run into problems.

See X.691 section 9.5 (PDF download) for the structure of PER encodings. Section 10.9 describes the encoding of length determinants.

Ethan
  • 11
  • 1