The values of ANY type are all of the values of all possible ASN.1 types, whether biult-in or defined. Thus, it is useful do describe a 'hole' in specification, where cannot be determined what type should be placed at present time.
The basic type notation consist simply of keyword ANY. The value notation besides reference and value must then include also type reference:
var1 ANY ::= INTEGER 134
var2 ANY ::= SET {a BOOLEAN, b NULL OPTIONAL} {a TRUE}
Because ANY type can express any possible ASN.1 type, it is implicitly not distinct from the other types. That's why it cannot be used in types, where distinction is needed, such as CHOICE. On the other hand it can be useful for describing the last component of SEQUENCE types:
Protocol ::= SEQUENCE {
head CommonProtocolHead,
length INTEGER (0..65535),
body ANY OPTIONAL
}
Normally, there is some information about what a kind of information the variable of ANY type carries, as one may expect also in previous example. ASN.1 offers special syntax for describing that:
AttributeValueAssertion ::= SEQUENCE {
attributeType INTEGER,
attributeValue ANY DEFINED BY attributeType
}
The keyword DEFINED BY estabilishes a link to the decsription identifier, which can be an INTEGER or OBJECT IDENTIFIER type.
It is also possible to use single value and contained subtyping, but it can lead to some bizare definitions, and thus is commonly avoided.