IBM Support

The difference between BER.DEFINITE-LENGTH and BER.INDEFINITE-LENGTH encoding/decoding

Question & Answer


Question

What is the difference between BER.DEFINITE-LENGTH and BER.INDEFINITE-LENGTH encoding/decoding?

Answer

The difference between definite length and indefinite length encoding, is:

  • With definite length encoding, the length of the content is known at the beginning of the encoding
  • With indefinite length, the length is not known until the entire content has been traversed and the end of the content has been reached.

BER has indefinite and definite length:

In the definite form, the length  of octets consists of one or more octets and represents the number of octets in the content octet using either the short form or the long form as a sender's option. The short form can only be used if the number of octets in the content octet is less than or equal to 127.

For the indefinite form, the length of octets indicates that the content octets are terminated by end-of-content octets, and consist of a single octet.

Short form: 
In the short form, the length octets shall consist of a single octet in which bit 8 is zero and bits 7 to 1 encode the number of octets in the contents octets (which may be zero), as an unsigned binary integer with bit 7 as the most significant bit.

Example from standard:

L = 38 can be encoded as 001001102

Long form: 
In the long form, the length octets shall consist of an initial octet and one or more subsequent octets. The initial octet shall be encoded as follows: 

  • Bit 8 shall be one; 
  • Bits 7 to 1 shall encode the number of subsequent octets in the length octets, as an unsigned binary integer with bit 7 as the most significant bit; 
  • The value 111111112 shall not be used. 
    Bits 8 to 1 of the first subsequent octet, followed by bits 8 to 1 of the second subsequent octet, followed in turn by bits 8 to 1 of each further octet up to and including the last subsequent octet, shall be the encoding of an unsigned binary integer equal to the number of octets in the contents octets, with bit 8 of the first subsequent octet as the most significant bit.

Example from standard:

L = 201 can be encoded as: 
100000012 
110010012

Encoding attributes are:

"BER:1997", with variant: "length form 3"

Compilation Switchs in Tau Tester:

BER-Definite-Length

-t3rt "-confbool t3asn.MESSAGES.BER.DEFINITE-LENGTH true"

BER-Indefinite-Length

-t3rt "-confbool t3asn.MESSAGES.BER.INDEFINITE-LENGTH true"

[{"Product":{"code":"SSYQGX","label":"Rational Tau"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"General Information","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"4.0;4.1;4.2;4.3","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

KB7049
TAUTEST-FAQ-04

Document Information

More support for:
Rational Tau

Software version:
4.0, 4.1, 4.2, 4.3

Operating system(s):
Linux, Solaris, Windows

Document number:
364357

Modified date:
16 June 2018

UID

swg21325472