Slide 29 of 41
Notes:
Slightly more formally, a tag consists of a class identification (which encodes into two bits in BER) and a non-negative value.
The non-negative value can be arbitrarily large, and encodes in as many octets as it takes, so if BER is being used, tag values should (and are) normally be kept small. In PER the actual value does not matter, and a recent specification bust an ASN.1 tool that could not handle tag values above 32K (because nobody had ever written them before!)
The most common “colour” of tag is context-specific, the name implying that it only truly identifies the type within some specific context (for example, among the alternatives of a CHOICE, or the elements of a SET.
The APPLICATION class of tag can also be used in a context-specific way, and can be assigned multiple times to different types, but as a matter of style, such tags are normally assigned only once for any given application, and hence identify a specific type throughout the entire encoding of that application. They are commonly assigned to the alternatives of the top-level type if that type is a CHOICE type (which it usually is), and to any type that is frequently used within the application - often a simple INTEGER or BOOLEAN that has some highly application-specific semantics associated with it.
PRIVATE class tags are never seen in international specifications. They have been used in company-specific protocols based on international standards, where added elements or alternatives are given PRIVATE class tags to avoid problems if the company moves to a later version of the international specification as its base.
Finally, as stated earlier, UNIVERSAL class tags are reserved for use in the ASN.1 specification itself, and this tutorial does not even show the syntax for assigning them (but the reader can no doubt guess!)