Hi,
Please review the following problem and let me know incase I am wrong
in understanding. This is very much needed for me to solve the problem which I am currently facing.

Problem:
      I have a char *buffer to which I need to encode lrsn which is a 4 byte ASN int. The lrsn value to be encoded is greater than 127.
Here I am trying to encode the lrsn value manuaaly.(just like the
way the encoding routines does).

Solution:
    Assuming lrsn value to be encoded is 222.

buffer[0] = Tag-----> In the first byte I encode the Tag.
buffer[1] = 0x81----> Since lrsn value is 128(>127), set MSB bit
                      to 1 and the remaining bits
                      indicates how many bytes contain the length of
                      contents length.Since 1 byte is sufficient to
                      hold 222 LSB bit is also set to 1. Hence 0x81.
buffer[2] = 1-------> this byte indicates the actual length
buffer[3] == 222.

For lrsn > 256

buffer[0] = Tag;
buffer[1] = 0x81---> since 1 byte is required to say the actual
                    length of contents which is 2 bytes.
buffer[2] = 2;----> since 2 bytes are required to hold 256 value.
buffer[3] and buffer[4] ---> contains 256 value.

Please review my above understanding and give me u'r comments as I have to understand this to solve the original problem which I have.

Thanks,
Raju.

                   






_______________________________________________
Asn1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1

Reply via email to