Question

In ASN.1, certain types have the same type of value notation. For example, the value 'ABCD'H is a hex string that can represent either an OCTET STRING type, or a BIT STRING type. Similarly, the value 10 is a number that can either be a INTEGER type or a REAL type. But if we assign values to a variable, can we then use that variable in an assignment expression for a compatible type?

For example:

MySchema DEFINITIONS AUTOMATIC TAGS ::= 
BEGIN

   x OCTET STRING ::= 'ABCD'H
   y BIT STRING ::= x          -- is this valid?

   i INTEGER ::= 10
   r REAL ::= i                -- is this valid?

END

At least one implementation of ASN.1 gives an error message here. But I can't find what the actual standard says about this.

Was it helpful?

Solution

No, that is not legal. Your definition of y and r require a BIT STRING value and a REAL value, respectively. x is an OCTET STRING value (it is not the lexical string "'ABCD'H") and i is an INTEGER value (it is not the lexical string "10").

You can refer to X.680 16.2 and Appendix C for more info. 16.2 requires:

The value being assigned to the "valuereference" in the "ValueAssignment" is "Value", and is governed by "Type" and shall be a notation for a value of the type defined by "Type" (as specified in 16.3).

Appendix C discusses type compatibility.

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