Hi Conrad,

Thanks for the explanation.

The ASN.1 representaion for the encoding given below is as follows:

Address               SEQUENCE OF Aliases

Aliases ::= CHOICE {
  myString         IA5String(SIZE (1..128))(FROM ("0123456789No. *,")),
  myString1        BMPString(SIZE (1..256)),
  ...,
  myString2        IA5String(SIZE (1..512))
}

The Encoding is 02 40 03 00 74 00 65 00 73 00 74 01 00 43 42

The following is my understanding:

02 represents the number of iterations of Aliases, i.e 2 aliases will be present.

40: 0100 0000 :---- 0 is the extension bit, 1 represents that the first string is myString1. The remaining bits are padding bits.

03: 0000 0011 :-------  Represents that there are 4 characters(3+1) in the string.

Since the string type is BMP, the range of alphabet is 65535, and hence each character requires 32 bits to be encoded. Hence the four characters length is 4*32 = 8 bytes which are

00 74 00 65 00 73 00 74 represent the BMP String "test".

The remaining bytes to be looked are 01 00 43 42 which are explained here again.

------------- 01 00 43 42 --------------

i.e 0000 0001 0000 0000 0100 0011 0100 0010
 
The first two bits(00) are used as extension bit and representing choice value.
Since the string's size can be between 1 to 128, the number of bits used for
decoding length determinant is 7. Hence 00 0001 0 are used for finding length
determinant. That is , the length is equal to 3,(2 + 1).
The string yet to be read is 000 0000 0100 0011 0100 0010.
Since the string can take values from "0123456789No. *,", i.e 13 values , 4 bits
will be used for encoding each character.
Say , is represented by 0,* by 1,. by 2,0 by 3,1 by 4, 2 by 5 and so on.
So, 101 can  be represented as 434 i.e 0100 0011 0100.
 
Please let me know if my understanding is correct.
 
One More thing,
This is an excerpt from ASN.1 complete by John Larmouth,
Padding bits
"When do we get padding bits in the ALIGNED case?
Here we need to look at the combination of the effective
size constraint (which restricts the number of abstract
characters in every value) and the effective alphabet
constraint (which determines the number of bits used to
encode each character). If the combination of these is
such that the total encoding size for a value of this constrained type can never exceed sixteen bits, then there are no padding bits. The character string value is encoded into a bit-field. If, however, there are some values which might require more than 16 bits, then the encoding is into an octetaligned bit-field, and no character will cross an octet boundary (in the ALIGNED case)."

I did not understand the terminology used here.

What is effective size constraint mentioned here?
-- Is it the number of characters in that string or the upper bound value the string can take.
   For Ex: myString OCTETSTRING(FROM 1...128)
           Is effective string constraint equal to 128(Upper bound) or equal to the no of characters in the string obtained by finding the length determinant.
What does this mean ? "Which restricts the number of abstract characters in every value."
Is Total Encoding size equal to the number of characters in the string multiplied by the number of bits required for encoding each character.
Please explain me with an example of encoding strings in the ALIGNED case, where padding bits are required and not required.
 
Thanks again for your quick response.
 
Regards
Surya Santosh
 

From:  Conrad Sigona <[EMAIL PROTECTED]>
To:  surya santosh <[EMAIL PROTECTED]>
CC:  [email protected], [EMAIL PROTECTED]
Subject:  Re: [ASN1] PER Encoding : Length Determinant of strings
Date:  Fri, 21 Oct 2005 10:23:01 -0400 (Eastern Daylight Time)
>>In PER Aligned Encoding of strings, is the length determinant
>>padded so that the
>>string always starts off at a new byte.
>> 
>>myString         IA5String(SIZE (1..128))(FROM ("0123456789No.
>>*,"))
>> 
>>myString = 101
>>What will be the encoding for this?
>> 
>>This is my understanding from a packet capture:
>> 
>>I saw in the packet the encoding for it as follows:
>>------------- 01 00 43 42 --------------
>>i.e 0000 0001 0000 0000 0100 0011 0100 0010
>> 
>>The first two bits(00) are used as extension bit and representing
>>choice value.
>>Since the string's size can be between 1 to 128, the number of bits
>>used for
>>decoding length determinant is 7. Hence 00 0001 0 are used for
>>finding length
>>determinant. That is , the length is equal to 3,(2 + 1).
>>The string yet to be read is 000 0000 0100 0011 0100 0010.
>>Will the string start from 0100 or 000?
>>Since the string can take values from "0123456789No. *,", i.e 13
>>values , 4 bits
>>will be used for encoding each character.
>>Say , is represented by 0,* by 1,. by 2,0 by 3,1 by 4, 2 by 5 and
>>so on.
>>So, 101 can  be represented as 434 i.e 0100 0011 0100.
>>If this is the case, what happens to the seven bits(Marked in
>>Red) in 0000 0001
>>0000 0000 0100 0011 0100 0010.
>>Does it mean that for strings, the length determinant is padded for
>>alignment.
>> 
>>Please explain if my understanding is wrong.
>
>Your understanding is good as far as alignment goes. The string
>itself is indeed aligned and those seven bits (my email reader
>doesn't show red) are just padding. It's not good that you provided
>other stuff, like extension bit and choice index, without showing us
>the accompanying ASN.1. Without the ASN.1, we have to take your word
>for it, and a misunderstanding of the initial bits could be the
>source of your difficulty.
>
>But, given your FROM list, I don't see how 434 could be interpreted
>as "101". It would have to be decoded as "0.0". The three
>half-octets 434 would have to instead be 545 to be decoded as "101".
>Please check that you correctly transcribed the FROM.
>
>If you'd like a more precise response, please send the encoding and
>all the ASN.1 that reflects it.
>
>=====================================================================
>Conrad Sigona                    Voice Mail     : 1-732-302-9669
>x400
>OSS Nokalva                      Fax            : 1-614-388-4156
>[EMAIL PROTECTED]                   My direct line : 1-315-845-1773



Spice up your IM conversations. New colourful, animated emoticons. Go chatting!
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1

Reply via email to