Lev,
Lev Walkin wrote:
Steven Legg wrote:
Lev,
Lev Walkin wrote:
Rick Berge wrote:
Bertil Karlsson wrote:
Hello,
I wonder if someone knows the right BER encoding of the following
example:
Seq ::= SEQUENCE{
a [PRIVATE 1] IMPLICIT OCTET STRING
}
If the component is encoded with value 1,2,3 (three octets) in
constructed form what would
the encoding of the inner OCTET STRING be?
Which of the following is right for Seq?
a 48,7,225,5,4,3,1,2,3 [UNIVERSAL 4] as inner tag
b 48,7,225,5,193,3,1,2,3 [PRIVATE 1] as inner tag
Lev Walkin wrote:
Second form is correct.
...but unless I'm missing something, you have an extra tag (225)
between
SEQUENCE (48) and [PRIVATE 1] (193).
You are missing something. The constructed [private 1](225) is not
necessary, as there is a primitive [private 1] (193). It is would
be necessary only in case of nested tags, which is not the case.
I think you have missed Note 2 on Clause 8.7.3.2 of X.690 (07/2002):
"In particular, the tags in the contents octets are always
universal class, number 4."
The "contents octets" being the contents octets of the constructed
(outer) OCTET STRING encoding.
This makes the first form (case a) the correct encoding.
We don't have a constructed encoding here.
Sure we do. Bertil's original question stated "in constructed form" and
his alternative encodings for the "a" component both have tag 225, i.e.
with the constructed bit set.
We do have primitive encoding
here.
Nested inside the contents octets of the constructed encoding for the
"a" component.
You are right that the [UNIVERSAL 4] tag applies to the inner
tags, but this is only when the string is encoded using indefinite
length.
How do you reach the conclusion that the [UNIVERSAL 4] tag only applies
when the string is indefinite length encoded ? I can't find anything in
X.690 to support that view.
If DER or CER is used, for such string there will be a primitive
encoding with a known length.
You can have a constructed OCTET STRING in CER.
That is, you can't possibly receive or
transmit string of this length with [UNIVERSAL 4] tag, if using CER or
DER.
With BER, you can do that, but the #a form will still be invalid.
The correct forms for BER are (note, hexadecimal encodings):
1. Primitive, known-length string:
30, 05, C1, 03, 1, 2, 3
^^<- [PRIVATE 1], primitive
2. Constructed, indefinite length string "a":
30, 09, E1, 80, 04, 03, 1, 2, 3, 0, 0
^^<- [PRIVATE 1], constructed
^^<- [UNIVERSAL 4], primitive
3. Constructed, indefinite length string "a" in two blocks:
30, 0B, E1, 80, 04, 01, 1, 04, 02, 2, 3, 0, 0
4. Constructed, indefinite length string "a" in three blocks:
30, 0D, E1, 80, 04, 01, 1, 04, 01, 2, 04, 01, 3, 0, 0
5. Consructed, indefinite length sequence Seq and string a:
30, 80, E1, 80, 04, 3, 1, 2, 3, 0, 0, 0, 0
6. And other derivatives.
The following form is never valid:
>>>>> a 48,7,225,5,4,3,1,2,3 [UNIVERSAL 4] as inner tag
I completely disagree. The "a" form is consistent with clauses 8.1.3.2, 8.14
and 8.7
of X.690. The "b" form violates 8.7.3.2 and 8.14.3.
Regards,
Steven
=== Here's how unber(1) display #4 form of encoding ===
[EMAIL PROTECTED]:~]> echo "30,0D,E1,80,04,01,01,04,01,02,04,01,03,00,00" | \
xxd -r -p | unber -m -
<C T="[UNIVERSAL 16]" TL="2" V="13">
<I T="[PRIVATE 1]" TL="2" V="Indefinite">
<P T="[UNIVERSAL 4]" TL="2" V="1"></P>
<P T="[UNIVERSAL 4]" TL="2" V="1"></P>
<P T="[UNIVERSAL 4]" TL="2" V="1"></P>
</I T="[UNIVERSAL 0]">
</C T="[UNIVERSAL 16]">
=== cut ===
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1