I would like to make sure if my understanding of BIT STRING encoding is
correct.

Let's assume in the following expamle that only ellipsoid point is
supported, i.e. bit 0 is set to 1.

supportedGADShapes    [6] IMPLICIT BIT STRING {
        ellipsoidPoint  (0 ),
        ellipsoidPointWithUncertaintyCircle  (1 ),
        ellipsoidPointWithUncertaintyEllipse  (2 ),
        polygon  (3 ),
        ellipsoidPointWithAltitude  (4 ),
        ellipsoidPointWithAltitudeAndUncertaintyElipsoid  (5 ),
        ellipsoidArc  (6 )} ( SIZE( 7 .. 16 ) ) OPTIONAL}

In my opinion this encodes (BER) into:

03 02 01 (= 1 unused bit) 80

I would very much appreciate if anybody could confirm this.

It depends upon how precise you would like it to be. BER is less exacting
about the encoding of trailing 0s than DER. For BER

03 02 01 80 means '1000000'B
03 02 07 80 means '1'B

In both cases the first bit is set; the difference, as you can see, is
whether we bother encoding the remaining bits. If this were DER, trailing
zeroes are removed from named bit BIT STRINGs, so the only possible
encoding would be 03020780; in BER, both are acceptable. Actually, for BER
even 03020280, 03020380, 03020480, 03020580, and 03020680 would be
acceptable.

I guess, due to the size constraint, the value must have at least 7
bits. The smallest valid encoding is therefore 03 02 01 80.
Unfortunately, the standard is not very clear about this so I am not
sure. For a non-normative example see X.680 (07/2002), E.2.5.4 where a
value of a BIT STRING defined with a NamedBitList is rejected because it
is too short for the size constraint.

That is not quite the case. E.2.5.4 refers to value notation, not encodings. A size constraint affects not the BER encoding, but what's allowed as the abstract value, that is, the value in memory before it's encoded or after it's decoded. A '1000000'B could be passed to an encoder with the result being 03020780 and this would be entirely valid. It would be equally valid encoded as 03020180 for BER.

In DER there is only one way of encoding a value. For the example above, that one way would be 03020780.

=====================================================================
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