Hi,
Encoding of the length of an integer in BER is based on the actual
value, not on the limits/constraints on the integer.
Any integer value must be encoded in the minimum number of octets.
I.e. actual integer values in the range:
-128..127 will be encode in one octet
-32768..-129 | 128..32767 will be encode in two octets
etc.
So the determination of length is not done at compile-time, but in
run-time.
Best regards
Egon Andersen
Ajay Bhagwan Dudani [T] wrote:
>
> Hello
>
> I have a doubt about the ASN.1/BER encoding and decoding.
> The ASN specification does not say anything about length of any data type. So it is
>dependent on the implementation on how to limit it.
>
> Say there is an INTEGER data type for some value in some PROTO protocol definition
>which has a value that occupies 10 octets. The BER encoding would simply put the tag
>for INTEGER, length = 10 and value = value for those octets. But how would the
> compiler handle this thing. On what rules would the physical implementation limit
>the size of the INTEGER. Also if it is for the compiler to decide this, then in the
>absence of any general specification for limiting the length, if there are two
> different compilers doing encoding and decoding at different ends and if the
>encoding and decoing follows different rules to limit the integer, then how would
>both sides decides out on this.
>
> I think that I have missed out on some part of the specification that talks about
>this.
>
> TIA
>
> Ajay Dudani
> Engineer-Trainee
> Motorola India Electronics Limited
--
* Talura ApS * Phone: +45 43 52 50 00 *
* Baldershøj 24 B * mailto:[EMAIL PROTECTED] *
* DK-2635 Ishøj * http://www.talura.dk *