Question

ASN.1 allows you to declare "sub-types", which basically impose additional constraints on regular types.

So, a regular type would be:

IntType ::= INTEGER

But you could constrain the type, by creating a "subtype" that only allows values within a certain range, such as:

IntType ::= INTEGER (1..100)

This declares IntType as an INTEGER that must fall between 1 and 100.

My question is, once a Sub-Type is declared, how does ASN.1 handle further constraints on the sub type? Suppose I also say:

AnotherIntType ::= IntType (1..50)

Is that valid? I've now created a second SubType which further constrains IntType. But what if the constraints contradict each other, as in:

AnotherIntType ::= IntType (1..200)

Are there specific rules for resolving these contradictions?

Was it helpful?

Solution

According to the standard

47.4.2 A "ValueRange" specifies the values in a range of values which are designated by specifying the values of the endpoints of the range. This notation can only be applied to integer types, the "PermittedAlphabet" of certain restricted character string types (IA5String, NumericString, PrintableString, VisibleString, BMPString, UniversalString and UTF8String only) and real types. All values specified in the "ValueRange" are required to be in the root of the parent type.

Your first example

AnotherIntType ::= IntType (1..50)

is valid. Allowed values are the integers from 1 to 50.

The second example

AnotherIntType ::= IntType (1..200)

is not valid since not all values in the value range are in the parent type. IntType contains only the integers from 1 to 100.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top