> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 01, 2002 2:24 PM
> To: [EMAIL PROTECTED]
> Subject: [ASN.1] Length octets
> 
> Hi all,
> 
> I have a doubt regarding Length octets in BER.
> My question is, How to specify length octets, if it's value is greater
> than
> '255'.
> Because we cannot specify it in a single octet.
> 
> For Example,
> I want to specify a Length value as '302'.
> Can i specify it in two octets, in this case value will be  01 2E.
> 
> T = some value
> L =  01 2E

The length of the Contents uses the short, long or indefinite form.

If the length is less than 128 octets, the short form is used.
In the short form, bit H(the most significant bit) is coded 0, and
The length is encoded as a binary number using bits A to G bit.

If the Length of the contents is greater than 127 octets, 
then the long form of the Length of the contents is used.
The long form length is from 2 to 127 octets long. 
Bit H of the first octet is coded 1, 
and bit A to G of the first octet encode a number on less than 
the size of the Length in octets as an unsigned binary number
whose MSB and LSB are bit H of the second octet and bit A 
of the last octet, respectively.
This binary number should be encoded in the fewest possible octets,
With no leading octets having the value 0.

So, L = 0x82 01 2E

If the length is 0x112233 then L = 0x83 11 22 33.


> V = some value
> 
> while interpreting, the boundry between L and V is not very clear.
> My mistaken, there is a chance to  read only '01' as length and 2E as
> value.
> 
> how to avoid this ?
> 
> It would be really helpful for me if somebady tells the answer.
> 
> Thanks in advance.
> 
> -Salai.g
> www.icope.com
> 
> 


Reply via email to