Skip to main content

📏 BER Length Encoding

This Structural rule checks whether complete MISB ST 0601 packets use the shortest Basic Encoding Rules (BER) representation for their length fields. It checks the outer length after the universal key and the length of each top-level item after its tag. The rule is enabled by default. Lengths within nested sets and opaque item values are outside its scope.

How BER encodes a length​

Lengths from 0 through 127 fit in one byte. For example, 08 is the shortest encoding for 8, while 81 08 uses an extra byte.

For lengths of 128 or more, the low seven bits of the first byte give the number of length bytes that follow. In 81 99, 81 means one byte follows and 99 is 153 in hexadecimal. In 82 00 99, 82 means two bytes follow. The leading 00 is redundant, so both encodings describe the same 153-byte value.

Hex dump of a MISB ST 0601 packet with 82 00 99 highlighted in pink

The highlighted outer length starts at offset 0x10 within the KLV packet, immediately after the 16-byte universal key. The top-level items start after the length field, at 02 08 in this example.

Reading the result​

  • Passed means every checked length used the shortest encoding. If there were no complete ST 0601 packets to inspect, the result explicitly says so.
  • Passed with warning means at least one length was readable but used extra bytes. The packet can still decode and pass the separate Checksum test, which uses the original packet bytes. The Raw KLV Decode test checks for malformed or truncated lengths.

A warning gives the total number of non-minimal length fields and the number of affected packets out of all checked packets. A single packet can contribute several length warnings. For the first occurrence, the report shows the source packet's byte offset and index when available, identifies the outer length or item tag, and gives both encodings. For example, outer packet length 153 uses 82 00 99 identifies a packet whose outer length field should use 81 99.

Select Open first affected packet on the warning in Process or Report to inspect the original bytes in the Raw KLV window.

MISB ST 0601.8-07, cited in RPASDCSPIN-181, requires minimal BER item lengths.