Hello, thanks for your answer. I think now i got it right.

Now that i have corrected the encoding of the restricted IA5String, it
seems that i have messed up a little more. The IA5String i have declared
earlier is part of an extension:

Let us assume the following:

mytype ::= SEQUENCE
{
 a              Type1,
 ...,
 b              SEQUENCE OF Type2 OPTIONAL
 c              Type3 OPTIONAL,
 d              Type3 OPTIONAL,
 e              Type3 OPTIONAL,
 f              Type3 OPTIONAL,
 g              Type3 OPTIONAL,
 h              Type3 OPTIONAL,
 i              Type3 OPTIONAL,
 j              Type3 OPTIONAL,
 k              Type3 OPTIONAL,
 l              Type3 OPTIONAL,
 m              Type3 OPTIONAL,
 n              Type3 OPTIONAL,
 o              Type3 OPTIONAL,
 p              Type3 OPTIONAL,
 q              Type3 OPTIONAL,
 r              Type3 OPTIONAL,
}

Type2 ::= CHOICE
{
 mystring       IA5String (SIZE (1..128)) (FROM ("01234567890#*,"),
 c              Type3
}

The encoding of the Sequence mytype seems to be correct up to the
extension marker (there are some more types, i left them out till
Ethereal shows me that encode them correctly). In the Extension Group
only b will be used, so the rest are dummy types to show the quantity.

Following i will show my understanding how the extension group should be
encoded with 1 item of type mystring = "55#12" in b.

First i have to encode the number of components in the extensions (which
is 16.

What about the extension flag? There should be a single 1 bit to show that we'll be dealing with extensions.

In any case, I count 17, not 16, but the number of components you show below is correct for 17.

0010000  Number of Components in extension

This is for 17. 0 represents 1, 1 represents 2, etc.

1.       Item 0 (b) is used
00000000.  No other Item is used
00000000.

OK, but when you include the extension flag as the first bit, you'll end up with padding between here and the next field.

00000110.  Byte Length of component b

Probably too large in light of the corrections below.

00000001. Items in Sequence of: 1

Yes.

00000000. Selection of Choice mystring (index 0)

Only 1 bit for the index. There are only two possibilities.

0000100x. Length of IA5String 5
1000      5
1000.     5
0000      #
0100.     1
0101      2
xxxx.     padding

This part is OK, but that was yesterday's lesson!

In Hex

21 00 00 06 01 00 08 88 80 04 50

This is the Output of my encoding.

Ethereal say that the byte length of type b is 3 byte and tells that
mystring only consists of 5.

My guess that i have missencoded the length determinant in the extension
preamble. I have read again and again section 18 of X.691 but i didn't
find out what i have misunderstood.

So that we can be precise, let's define Type1 and Type3 as NULL. It doesn't much matter what Type3 is, but Type1 is not OPTIONAL in your example. In such a case, if we were to encode

  m Mytype ::= { a NULL, b { mystring : "55#12" }}

we would see 90800000 05010488 0450 broken down as shown in the diagram below. In my bit diagrams, x does not mean pad; it means we-don't-care-about-this-bit-for-this-field.

Note that it will be easier to figure out the layout if you display this email using a fixed font.

90 1001 0000
   1xxx xxxx  extension bit to denote that the data contains extensions
   x001 0000  number of bits (17) in the extension bit mask

80 1000 0000
   1xxx xxxx  b is present
   x0xx xxxx  c is absent
   xx0x xxxx  d is absent
   xxx0 xxxx  e is absent
   xxxx 0xxx  f is absent
   xxxx x0xx  g is absent
   xxxx xx0x  h is absent
   xxxx xxx0  i is absent

00 0000 0000
   0xxx xxxx  j is absent
   x0xx xxxx  k is absent
   xx0x xxxx  l is absent
   xxx0 xxxx  m is absent
   xxxx 0xxx  n is absent
   xxxx x0xx  o is absent
   xxxx xx0x  p is absent
   xxxx xxx0  q is absent

00 0000 0000
   0xxx xxxx  r is absent
   x000 0000  padding

05 0000 0101  length of b extension

01 0000 0001  number of iterations of the SEQUENCE OF

04 0000 0100
   0xxx xxxx  0 = choice index for mystring
   x000 0100  4 --> 5 length of mystring

88 1000 1000
   1000 xxxx  5
   xxxx 1000  5

04 0000 0100
   0000 xxxx  #
   xxxx 0100  1

50 0101 0000
   0101 xxxx  2
   xxxx 0000  padding



=====================================================================
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
_______________________________________________
Asn1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1

Reply via email to