To answer your questions:
1. The bit field should not be octet aligned.
2. The encoding is wrong for both cases. Only
2 bits are needed to express the octet count (remember, the offset is from 1 so
the number 3 indicates 4 octets which is the max for the first value).
Consider the following:
TestSeq ::= SEQUENCE {
b
BOOLEAN,
i INTEGER(0..4294967295),
i2
INTEGER (0..16777215)
}
We get the
following encoding when setting all members to zero:
Binary dump:
IntType.b boolean
0-------
-------- -------- -------- --------
----
IntType.i ConsUnsigned length
-00xxxxx --------
-------- -------- 00------ .---
IntType.i ConsUnsigned
-------- 00000000
-------- -------- --00---- -.--
IntType.i2 ConsUnsigned length
-------- --------
00xxxxxx -------- ----00-- --.-
IntType.i2 ConsUnsigned
-------- --------
-------- 00000000 ------00 ---.
This is explained quite nicely in section 17.11.3
of ASN.1 Complete by John Larmouth. It is easier to read than the
standard.
Regards,
Ed Day
Objective Systems, Inc.
----- Original Message -----
Sent: Friday, May 21, 2004 1:08 AM
Subject: [ASN.1] Encoding of an Integer -
Indefinite length case
Hi,
I would like know to more about the encoding of
an Integer (Indefinite length) case.
Actually, the confusion lies in the
Alignment of the octet.
Example :
One ::= INTEGER
(0..4294967295)
Suppose the given value is : 0. In this
case, I presume that the encoded stream in PER Aligned variant is -
000xxxxx 00000000, 'xxxxx' are zero padding bits.
1. Is it
necessary to Align the octet before encoding this Integer? Means, if a byte is
filled upto 4th bit, then should it be octet aligned before appending the
Integer
bitstream.
2. Two ::= INTEGER
(0..16777215).
Suppose in this case also, the value entered is '0',
will the encoding (bitstream) is same as above one?
Please clarify my
doubts.
I am refering ITU-T 691 document.
Thank you very
much.
Regards,
Murali.
--
Muralikrishna N.
SYNERGY INFOTECH PVT. LTD.
Web Site :- http://www.synergy-infotech.com
Phone : 080 6780026/27/28, 6689904 Extn: 51.
My Home page :- http://www.geocities.com/nidugala
-------------------------------------------------------------
Information contained and transmitted by this E-MAIL is
proprietary to Synergy Infotech Private Limited and is
intended for use only by the individual or entity to which it
is addressed, and may contain information that is privileged,
confidential or exempt from disclosure under applicable law.
If this is a forwarded message, the content of this E-MAIL may
not have been sent with the authority of the Company. If you
are not the intended recipient, an agent of the intended
recipient or a person responsible for delivering the
information to the named recipient, you are notified that any
use, distribution, transmission, printing, copying or
dissemination of this information in any way or in any manner
is strictly prohibited. We have taken precautions to minimize
the risk of transmitting software viruses, but we advise you
to carry out your own virus checks on any attachment to this
message. We cannot accept liability for any loss or damage
caused by software viruses. If you have received this
communication in error, please delete this mail & notify us
immediately at mailto:[EMAIL PROTECTED]
--------------------------------------------------------------