Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To find the correct settings for the tagType and berConstruct attributes of a Tag Node (with type set to BERTag), first convert the tag value into binary. The top 2 bits of the binary result represent the tag type - the value to set for the attribute tagType:

tagType

Bit 1

Bit 2

Universal

0

0

Application

0

1

Context

1

0

Private

1

1

The next (3rd) bit determines whether this tag represents a simple or constructed value, and therefore the value to set for the attribute berConstruct:

berConstruct

Bit 3

T

1

F

0

The remaining 5 bits represent the actual tag value. For example, if the given tag value is A5, in binary this is 10100101, and so:

...

So the grammar for this Tag Node is:

Code Block
languagexml
<Tag name="tagValue" type="BERTag" discriminator="5" tagType="Context" berConstruct="T"/>


If the tag is specified as more than one byte, e.g. BF3B or 48955, then the actual tag value is greater than or equal to 31 (5 bits are not enough to encode values greater than 31; and the binary value for 31 is reserved, as described below). The remaining 5 bits on the first byte are all set to 1 indicating that the actual tag value is stored in the following bytes. To determine the actual tag value:

...

For example, a tag specified as BF3B in hex or 48955 in decimal converts to binary as:

Code Block
languagexml
10111111 00111011


The top three bits indicate that the tagType is Context and berConstruct is T. The next 5 bits indicate that the tag value is greater than or equal to 31, and is encoded in subsequent bytes. The top bit of the next byte is 0, which indicates that this byte contains the whole tag value. The remaining 7 bits evaluate to the decimal value 59. The grammar for this tag is:

Code Block
languagexml
<Tag name="tagValue" type="BERTag" discriminator="59" tagType="Context" berConstruct="T"/>

Other pages

Page Tree
rootPhixFlow Binary File Grammar Guide